Here is the relevant piece of source code: ......
static unsigned long vaddr2paddr(struct seq_file *m, unsigned long vaddr,int pid)
{
pte_t *pte_tmp = NULL;
pmd_t *pmd_tmp = NULL;
pud_t *pud_tmp = NULL;
pgd_t *pgd_tmp = NULL;
struct task_struct *pcb_tmp = NULL;
unsigned long paddr = 0;
printk(KERN_INFO"in vaddr2paddr try to find the task %d .\n",pid);
pcb_tmp =pid_task(find_get_pid(pid),PIDTYPE_PID);
if(!pcb_tmp) {
printk(KERN_INFO"Can't find the task %d .\n",pid);
return 0;
}
pgd_tmp = pgd_offset(pcb_tmp->mm, vaddr);
if (pgd_none(*pgd_tmp)) {
printk("not mapped in pgd\n");
return -1;
}
/73/
pud_tmp = pud_offset(pgd_tmp, vaddr);
if (pud_none(*pud_tmp)) {
printk("not mapped in pud\n");
return -1;
}
pmd_tmp = pmd_offset(pud_tmp, vaddr);
if (pmd_none(*pmd_tmp)) {
printk("not mapped in pmd\n");
return -1;
}
//pte = pte_offset_kernel(pmd, vaddr);
pte_tmp = pte_offset_kernel(pmd_tmp, vaddr);
if (pte_none(*pte_tmp)) {
printk("not mapped in pte\n");
return -1;
}
......
}
error: passing argument 1 of ‘pud_offset’ from incompatible pointer type [-Werror=incompatible-pointer-types]
73 | pud_tmp = pud_offset(pgd_tmp, vaddr);
pgd_t * {aka struct <anonymous> *}
expected ‘p4d_t *’ {aka ‘struct *’} but argument is of type ‘pgd_t *’ {aka ‘struct *’}
925 | static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
I have made the following changes, but there was a segfault later.
static unsigned long vaddr2paddr(struct seq_file *m, unsigned long vaddr,int pid)
{
pte_t *pte_tmp = NULL;
pmd_t *pmd_tmp = NULL;
pud_t *pud_tmp = NULL;
p4d_t* p4d_tmp = NULL;
pgd_t *pgd_tmp = NULL;
struct task_struct *pcb_tmp = NULL;
unsigned long paddr = 0;
printk(KERN_INFO"in vaddr2paddr try to find the task %d .\n",pid);
pcb_tmp =pid_task(find_get_pid(pid),PIDTYPE_PID);
if(!pcb_tmp) {
printk(KERN_INFO"Can't find the task %d .\n",pid);
return 0;
}
pgd_tmp = pgd_offset(pcb_tmp->mm, vaddr);
if (pgd_none(*pgd_tmp)) {
printk("not mapped in pgd\n");
return -1;
}
p4d_tmp = p4d_offset(pgd_tmp, vaddr);
if (p4d_none(*p4d_tmp))
return 0;
pud_tmp = pud_offset(p4d_tmp, vaddr);
if (pud_none(*pud_tmp)) {
printk("not mapped in pud\n");
return -1;
}
pmd_tmp = pmd_offset(pud_tmp, vaddr);
if (pmd_none(*pmd_tmp)) {
printk("not mapped in pmd\n");
return -1;
}
//pte = pte_offset_kernel(pmd, vaddr);
pte_tmp = pte_offset_kernel(pmd_tmp, vaddr);
if (pte_none(*pte_tmp)) {
printk("not mapped in pte\n");
return -1;
}
}
If you can directly help modify the code, I would be very grateful.