nios2: add support for folded p4d page tables
authorMike Rapoport <rppt@linux.ibm.com>
Thu, 4 Jun 2020 23:46:35 +0000 (16:46 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 5 Jun 2020 02:06:21 +0000 (19:06 -0700)
Implement primitives necessary for the 4th level folding, add walks of p4d
level where appropriate and remove usage of __ARCH_USE_5LEVEL_HACK.

Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Brian Cain <bcain@codeaurora.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Christophe Leroy <christophe.leroy@c-s.fr>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>
Cc: Guan Xuetao <gxt@pku.edu.cn>
Cc: James Morse <james.morse@arm.com>
Cc: Jonas Bonn <jonas@southpole.se>
Cc: Julien Thierry <julien.thierry.kdev@gmail.com>
Cc: Ley Foon Tan <ley.foon.tan@intel.com>
Cc: Marc Zyngier <maz@kernel.org>
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Rich Felker <dalias@libc.org>
Cc: Russell King <linux@armlinux.org.uk>
Cc: Stafford Horne <shorne@gmail.com>
Cc: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Will Deacon <will@kernel.org>
Cc: Yoshinori Sato <ysato@users.sourceforge.jp>
Link: http://lkml.kernel.org/r/20200414153455.21744-7-rppt@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
arch/nios2/include/asm/pgtable.h
arch/nios2/mm/fault.c
arch/nios2/mm/ioremap.c

index f98b7f4519ba36b328c84fb6f9fa1729a859e75b..47a1a3ea5734a8d8159157d9456e7093019beb72 100644 (file)
@@ -22,7 +22,6 @@
 #include <asm/tlbflush.h>
 
 #include <asm/pgtable-bits.h>
-#define __ARCH_USE_5LEVEL_HACK
 #include <asm-generic/pgtable-nopmd.h>
 
 #define FIRST_USER_ADDRESS     0UL
@@ -100,7 +99,7 @@ extern pte_t invalid_pte_table[PAGE_SIZE/sizeof(pte_t)];
  */
 static inline void set_pmd(pmd_t *pmdptr, pmd_t pmdval)
 {
-       pmdptr->pud.pgd.pgd = pmdval.pud.pgd.pgd;
+       *pmdptr = pmdval;
 }
 
 /* to find an entry in a page-table-directory */
index ec9d8a9c426fcde8f64f5c09635392117ffc7a9f..964eac1a21d0e15b6f935edfb16be6fcd10a1d13 100644 (file)
@@ -242,6 +242,7 @@ vmalloc_fault:
                 */
                int offset = pgd_index(address);
                pgd_t *pgd, *pgd_k;
+               p4d_t *p4d, *p4d_k;
                pud_t *pud, *pud_k;
                pmd_t *pmd, *pmd_k;
                pte_t *pte_k;
@@ -253,8 +254,12 @@ vmalloc_fault:
                        goto no_context;
                set_pgd(pgd, *pgd_k);
 
-               pud = pud_offset(pgd, address);
-               pud_k = pud_offset(pgd_k, address);
+               p4d = p4d_offset(pgd, address);
+               p4d_k = p4d_offset(pgd_k, address);
+               if (!p4d_present(*p4d_k))
+                       goto no_context;
+               pud = pud_offset(p4d, address);
+               pud_k = pud_offset(p4d_k, address);
                if (!pud_present(*pud_k))
                        goto no_context;
                pmd = pmd_offset(pud, address);
index 819bdfcc2e714d64ba1657de319dcc1ba6b6a5da..fe821efb9a998694b1048e11b63ef1719c942d80 100644 (file)
@@ -86,11 +86,15 @@ static int remap_area_pages(unsigned long address, unsigned long phys_addr,
        if (address >= end)
                BUG();
        do {
+               p4d_t *p4d;
                pud_t *pud;
                pmd_t *pmd;
 
                error = -ENOMEM;
-               pud = pud_alloc(&init_mm, dir, address);
+               p4d = p4d_alloc(&init_mm, dir, address);
+               if (!p4d)
+                       break;
+               pud = pud_alloc(&init_mm, p4d, address);
                if (!pud)
                        break;
                pmd = pmd_alloc(&init_mm, pud, address);