Skip to content

Commit 9f4e703

Browse files
rppttorvalds
authored andcommitted
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>
1 parent c03ab9e commit 9f4e703

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎arch/nios2/include/asm/pgtable.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
#include <asm/tlbflush.h>
2323

2424
#include <asm/pgtable-bits.h>
25-
#define __ARCH_USE_5LEVEL_HACK
2625
#include <asm-generic/pgtable-nopmd.h>
2726

2827
#define FIRST_USER_ADDRESS 0UL
@@ -100,7 +99,7 @@ extern pte_t invalid_pte_table[PAGE_SIZE/sizeof(pte_t)];
10099
*/
101100
static inline void set_pmd(pmd_t *pmdptr, pmd_t pmdval)
102101
{
103-
pmdptr->pud.pgd.pgd = pmdval.pud.pgd.pgd;
102+
*pmdptr = pmdval;
104103
}
105104

106105
/* to find an entry in a page-table-directory */

‎arch/nios2/mm/fault.c‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,
242242
*/
243243
int offset = pgd_index(address);
244244
pgd_t *pgd, *pgd_k;
245+
p4d_t *p4d, *p4d_k;
245246
pud_t *pud, *pud_k;
246247
pmd_t *pmd, *pmd_k;
247248
pte_t *pte_k;
@@ -253,8 +254,12 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long cause,
253254
goto no_context;
254255
set_pgd(pgd, *pgd_k);
255256

256-
pud = pud_offset(pgd, address);
257-
pud_k = pud_offset(pgd_k, address);
257+
p4d = p4d_offset(pgd, address);
258+
p4d_k = p4d_offset(pgd_k, address);
259+
if (!p4d_present(*p4d_k))
260+
goto no_context;
261+
pud = pud_offset(p4d, address);
262+
pud_k = pud_offset(p4d_k, address);
258263
if (!pud_present(*pud_k))
259264
goto no_context;
260265
pmd = pmd_offset(pud, address);

‎arch/nios2/mm/ioremap.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,15 @@ static int remap_area_pages(unsigned long address, unsigned long phys_addr,
8686
if (address >= end)
8787
BUG();
8888
do {
89+
p4d_t *p4d;
8990
pud_t *pud;
9091
pmd_t *pmd;
9192

9293
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);
9498
if (!pud)
9599
break;
96100
pmd = pmd_alloc(&init_mm, pud, address);

0 commit comments

Comments
 (0)