Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nios2: add support for folded p4d page tables

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>

authored by

Mike Rapoport and committed by
Linus Torvalds
9f4e7037 c03ab9e3

+13 -5
+1 -2
arch/nios2/include/asm/pgtable.h
··· 22 22 #include <asm/tlbflush.h> 23 23 24 24 #include <asm/pgtable-bits.h> 25 - #define __ARCH_USE_5LEVEL_HACK 26 25 #include <asm-generic/pgtable-nopmd.h> 27 26 28 27 #define FIRST_USER_ADDRESS 0UL ··· 99 100 */ 100 101 static inline void set_pmd(pmd_t *pmdptr, pmd_t pmdval) 101 102 { 102 - pmdptr->pud.pgd.pgd = pmdval.pud.pgd.pgd; 103 + *pmdptr = pmdval; 103 104 } 104 105 105 106 /* to find an entry in a page-table-directory */
+7 -2
arch/nios2/mm/fault.c
··· 242 242 */ 243 243 int offset = pgd_index(address); 244 244 pgd_t *pgd, *pgd_k; 245 + p4d_t *p4d, *p4d_k; 245 246 pud_t *pud, *pud_k; 246 247 pmd_t *pmd, *pmd_k; 247 248 pte_t *pte_k; ··· 254 253 goto no_context; 255 254 set_pgd(pgd, *pgd_k); 256 255 257 - pud = pud_offset(pgd, address); 258 - pud_k = pud_offset(pgd_k, address); 256 + p4d = p4d_offset(pgd, address); 257 + p4d_k = p4d_offset(pgd_k, address); 258 + if (!p4d_present(*p4d_k)) 259 + goto no_context; 260 + pud = pud_offset(p4d, address); 261 + pud_k = pud_offset(p4d_k, address); 259 262 if (!pud_present(*pud_k)) 260 263 goto no_context; 261 264 pmd = pmd_offset(pud, address);
+5 -1
arch/nios2/mm/ioremap.c
··· 86 86 if (address >= end) 87 87 BUG(); 88 88 do { 89 + p4d_t *p4d; 89 90 pud_t *pud; 90 91 pmd_t *pmd; 91 92 92 93 error = -ENOMEM; 93 - pud = pud_alloc(&init_mm, dir, address); 94 + p4d = p4d_alloc(&init_mm, dir, address); 95 + if (!p4d) 96 + break; 97 + pud = pud_alloc(&init_mm, p4d, address); 94 98 if (!pud) 95 99 break; 96 100 pmd = pmd_alloc(&init_mm, pud, address);