为页面 table walk 编译内核时出错

Getting error when compiling kernel for page table walk

我正在浏览页面 table。当我准备更新内核时出现错误:

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)
                      ^

这是使用代码的地方:

....
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;
            ...
}

我查看了错误和注释,但没有找到任何有关解决此问题的信息。这是一个众所周知的问题还是我做错了什么?

已更新*

我最近遇到了同样的问题,我发现就像pgd_offset和pud_offset一样,还有一个p4d_offset。放在 pgd 和 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;

...

编辑:这里是一些关于附加级别的信息:Five-level page tables

已在4.11内核版本实现。