The patch titled Subject: arm-arm64-add-support-for-folded-p4d-page-tables-fix-fix has been added to the -mm tree. Its filename is arm-arm64-add-support-for-folded-p4d-page-tables-fix-fix.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/arm-arm64-add-support-for-folded-p4d-page-tables-fix-fix.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/arm-arm64-add-support-for-folded-p4d-page-tables-fix-fix.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Catalin Marinas <catalin.marinas@xxxxxxx> Subject: arm-arm64-add-support-for-folded-p4d-page-tables-fix-fix Link: http://lkml.kernel.org/r/20200302174553.GC4166275@xxxxxxxxxxxxxxxxxxxx Cc: Anders Roxell <anders.roxell@xxxxxxxxxx> Cc: Anshuman Khandual <anshuman.khandual@xxxxxxx> Cc: Arnd Bergmann <arnd@xxxxxxxx> Cc: Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx> Cc: Brian Cain <bcain@xxxxxxxxxxxxxx> Cc: Christophe Leroy <christophe.leroy@xxxxxx> Cc: Fenghua Yu <fenghua.yu@xxxxxxxxx> Cc: Geert Uytterhoeven <geert+renesas@xxxxxxxxx> Cc: Guan Xuetao <gxt@xxxxxxxxxx> Cc: James Morse <james.morse@xxxxxxx> Cc: Jonas Bonn <jonas@xxxxxxxxxxxx> Cc: Julien Thierry <julien.thierry.kdev@xxxxxxxxx> Cc: Ley Foon Tan <ley.foon.tan@xxxxxxxxx> Cc: Marc Zyngier <maz@xxxxxxxxxx> Cc: Michael Ellerman <mpe@xxxxxxxxxxxxxx> Cc: Mike Rapoport <rppt@xxxxxxxxxxxxx> Cc: Naresh Kamboju <naresh.kamboju@xxxxxxxxxx> Cc: Paul Mackerras <paulus@xxxxxxxxx> Cc: Rich Felker <dalias@xxxxxxxx> Cc: Russell King <linux@xxxxxxxxxxxxxxx> Cc: Stafford Horne <shorne@xxxxxxxxx> Cc: Stefan Kristiansson <stefan.kristiansson@xxxxxxxxxxxxx> Cc: Stephen Rothwell<sfr@xxxxxxxxxxxxxxxx> Cc: Suzuki K Poulose <suzuki.poulose@xxxxxxx> Cc: Tony Luck <tony.luck@xxxxxxxxx> Cc: Will Deacon <will@xxxxxxxxxx> Cc: Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- arch/arm64/mm/mmu.c | 41 ++++++++++++++++++++++++++++++----------- 1 file changed, 30 insertions(+), 11 deletions(-) --- a/arch/arm64/mm/mmu.c~arm-arm64-add-support-for-folded-p4d-page-tables-fix-fix +++ a/arch/arm64/mm/mmu.c @@ -816,7 +816,7 @@ static void unmap_hotplug_pmd_range(pud_ } while (addr = next, addr < end); } -static void unmap_hotplug_pud_range(pgd_t *pgdp, unsigned long addr, +static void unmap_hotplug_pud_range(p4d_t *p4dp, unsigned long addr, unsigned long end, bool free_mapped) { unsigned long next; @@ -824,7 +824,7 @@ static void unmap_hotplug_pud_range(pgd_ do { next = pud_addr_end(addr, end); - pudp = pud_offset(pgdp, addr); + pudp = pud_offset(p4dp, addr); pud = READ_ONCE(*pudp); if (pud_none(pud)) continue; @@ -848,15 +848,15 @@ static void unmap_hotplug_pud_range(pgd_ } while (addr = next, addr < end); } -static void unmap_hotplug_p4d_range(pgd_t *pgd, unsigned long addr, - unsigned long end, bool free_mapped) +static void unmap_hotplug_p4d_range(pgd_t *pgdp, unsigned long addr, + unsigned long end, bool free_mapped) { unsigned long next; - pgd_t *p4dp, p4d; + p4d_t *p4dp, p4d; do { next = p4d_addr_end(addr, end); - p4dp = p4d_offset(pgd, addr); + p4dp = p4d_offset(pgdp, addr); p4d = READ_ONCE(*p4dp); if (p4d_none(p4d)) continue; @@ -961,7 +961,7 @@ static void free_empty_pmd_table(pud_t * free_hotplug_pgtable_page(virt_to_page(pmdp)); } -static void free_empty_pud_table(pgd_t *pgdp, unsigned long addr, +static void free_empty_pud_table(p4d_t *p4dp, unsigned long addr, unsigned long end, unsigned long floor, unsigned long ceiling) { @@ -970,7 +970,7 @@ static void free_empty_pud_table(pgd_t * do { next = pud_addr_end(addr, end); - pudp = pud_offset(pgdp, addr); + pudp = pud_offset(p4dp, addr); pud = READ_ONCE(*pudp); if (pud_none(pud)) continue; @@ -990,17 +990,36 @@ static void free_empty_pud_table(pgd_t * * entries are empty. Overlap with other regions have been * handled by the floor/ceiling check. */ - pudp = pud_offset(pgdp, 0UL); + pudp = pud_offset(p4dp, 0UL); for (i = 0; i < PTRS_PER_PUD; i++) { if (!pud_none(READ_ONCE(pudp[i]))) return; } - pgd_clear(pgdp); + p4d_clear(p4dp); __flush_tlb_kernel_pgtable(start); free_hotplug_pgtable_page(virt_to_page(pudp)); } +static void free_empty_p4d_table(pgd_t *pgdp, unsigned long addr, + unsigned long end, unsigned long floor, + unsigned long ceiling) +{ + p4d_t *p4dp, p4d; + unsigned long next; + + do { + next = p4d_addr_end(addr, end); + p4dp = p4d_offset(pgdp, addr); + p4d = READ_ONCE(*p4dp); + if (p4d_none(p4d)) + continue; + + WARN_ON(!p4d_present(p4d)); + free_empty_pud_table(p4dp, addr, next, floor, ceiling); + } while (addr = next, addr < end); +} + static void free_empty_tables(unsigned long addr, unsigned long end, unsigned long floor, unsigned long ceiling) { @@ -1015,7 +1034,7 @@ static void free_empty_tables(unsigned l continue; WARN_ON(!pgd_present(pgd)); - free_empty_pud_table(pgdp, addr, next, floor, ceiling); + free_empty_p4d_table(pgdp, addr, next, floor, ceiling); } while (addr = next, addr < end); } #endif _ Patches currently in -mm which might be from catalin.marinas@xxxxxxx are arm-arm64-add-support-for-folded-p4d-page-tables-fix-fix.patch