]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
s390/mm: make the pxd_offset functions more robust
authorMartin Schwidefsky <schwidefsky@de.ibm.com>
Tue, 23 Apr 2019 08:51:12 +0000 (10:51 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 May 2019 05:39:58 +0000 (07:39 +0200)
commit8b066d0047fdce29ccd6b943573773b3ce2a4ca6
tree9c2dcfea7de996c8917a557569b649262e46f3bf
parent550f5ba19cbd9217cb4d9dfc0e3ff37aeb1d4274
s390/mm: make the pxd_offset functions more robust

commit d1874a0c2805fcfa9162c972d6b7541e57adb542 upstream.

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: Martin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/s390/include/asm/pgtable.h
arch/s390/mm/gup.c