Getting error when compiling kernel for page table walk

只愿长相守 提交于 2020-06-09 02:03:12

问题


I am doing a page table walk. When I am getting ready to update the kernel I get an error:

kernel/sys.c: In function ‘__do_sys_get_page_info’:
kernel/sys.c:2745:23: error: passing argument 1 of ‘pud_offset’ from incompatible pointer type [-Werror=incompatible-pointer-types]
      pud = pud_offset(pgd, vmpage);
                       ^
In file included from ./include/linux/mm.h:99:0,
                 from kernel/sys.c:19:
./arch/x86/include/asm/pgtable.h:905:22: note: expected ‘p4d_t * {aka struct <anonymous> *}’ but argument is of type ‘pgd_t * {aka struct <anonymous> *}’
 static inline pud_t *pud_offset(p4d_t *p4d, unsigned long address)
                      ^

This is where the code is being used:

....
int loc, ref, dirty;
struct vm_area_struct *vma;
unsigned long vmpage;
struct mm_struct *task_mm = task->mm;
if ((task_mm && task_mm->mmap))
{
    int i;
    pgd_t *pgd;
    pud_t *pud;
    pmd_t *pmd;
    pte_t *ptep, pte;

    vma = task_mm->mmap;

    while (vma)
    {
        for (vmpage = vma->vm_start, i = 1; vmpage < vma->vm_end; vmpage += PAGE_SIZE, i++)
        {
            pgd = pgd_offset(task_mm, vmpage);
            if (pgd_none(*pgd) || pgd_bad(*pgd))
                return 0;

            pud = pud_offset(pgd, vmpage);
            if (pud_none(*pud) || pud_bad(*pud))
                return 0;

            pmd = pmd_offset(pud, vmpage);
            if (pmd_none(*pmd) || pmd_bad(*pmd))
                return 0;

            ptep = pte_offset_kernel(pmd, vmpage);
            if (!ptep)
                return 0;

            pte = *ptep;
            ...
}

I looked up the errors and notes but didn't find anything about resolving this problem. Is this a well known problem or am I doing something wrong?

updated*


回答1:


I recently got the same problem and I found that just like pgd_offset and pud_offset, there is a p4d_offset. Put it between pgd and pud:

pgd_t *pgd;
p4d_t* p4d;
pud_t *pud;
pmd_t *pmd;
pte_t *ptep, pte;

...

pgd = pgd_offset(task_mm, vmpage);
if (pgd_none(*pgd) || pgd_bad(*pgd))
    return 0;

p4d = p4d_offset(pgd, vmpage);
if (p4d_none(*p4d) || p4d_bad(*p4d))
    return 0;

pud = pud_offset(p4d, vmpage);
if (pud_none(*pud) || pud_bad(*pud))
    return 0;

...

Edit: Here is some information about the additional level: Five-level page tables.

It has been implemented in kernel version 4.11.



来源:https://stackoverflow.com/questions/58743052/getting-error-when-compiling-kernel-for-page-table-walk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!