• Martin Schwidefsky's avatar
    s390/mm: make the pxd_offset functions more robust · d1874a0c
    Martin Schwidefsky authored
    Change the way how pgd_offset, p4d_offset, pud_offset and pmd_offset
    walk the page tables. pgd_offset now always calculates the index for
    the top-level page table and adds it to the pgd, this is either a
    segment table offset for a 2-level setup, a region-3 offset for 3-levels,
    region-2 offset for 4-levels, or a region-1 offset for a 5-level setup.
    The other three functions p4d_offset, pud_offset and pmd_offset will
    only add the respective offset if they dereference the passed pointer.
    
    With the new way of walking the page tables a sequence like this from
    mm/gup.c now works:
    
         pgdp = pgd_offset(current->mm, addr);
         pgd = READ_ONCE(*pgdp);
         p4dp = p4d_offset(&pgd, addr);
         p4d = READ_ONCE(*p4dp);
         pudp = pud_offset(&p4d, addr);
         pud = READ_ONCE(*pudp);
         pmdp = pmd_offset(&pud, addr);
         pmd = READ_ONCE(*pmdp);
    Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
    d1874a0c
gup.c 6.99 KB