Skip to content

Commit f5ee256

Browse files
rpptjcmvbkbc
authored andcommitted
xtensa: get rid of __ARCH_USE_5LEVEL_HACK
xtensa has 2-level page tables and already uses pgtable-nopmd for page table folding. Add walks of p4d level where appropriate and drop usage of __ARCH_USE_5LEVEL_HACK. Signed-off-by: Mike Rapoport <[email protected]> Message-Id: <[email protected]> Signed-off-by: Max Filippov <[email protected]> [fix up arch/xtensa/include/asm/fixmap.h and arch/xtensa/mm/tlb.c]
1 parent f0d1eab commit f5ee256

File tree

6 files changed

+24
-10
lines changed

6 files changed

+24
-10
lines changed

arch/xtensa/include/asm/fixmap.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ static inline unsigned long virt_to_fix(const unsigned long vaddr)
7878

7979
#define kmap_get_fixmap_pte(vaddr) \
8080
pte_offset_kernel( \
81-
pmd_offset(pud_offset(pgd_offset_k(vaddr), (vaddr)), (vaddr)), \
82-
(vaddr) \
83-
)
81+
pmd_offset(pud_offset(p4d_offset(pgd_offset_k(vaddr), \
82+
(vaddr)), \
83+
(vaddr)), \
84+
(vaddr)), \
85+
(vaddr))
8486

8587
#endif

arch/xtensa/include/asm/pgtable.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#ifndef _XTENSA_PGTABLE_H
99
#define _XTENSA_PGTABLE_H
1010

11-
#define __ARCH_USE_5LEVEL_HACK
1211
#include <asm/page.h>
1312
#include <asm/kmem_layout.h>
1413
#include <asm-generic/pgtable-nopmd.h>

arch/xtensa/mm/fault.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ void do_page_fault(struct pt_regs *regs)
197197
struct mm_struct *act_mm = current->active_mm;
198198
int index = pgd_index(address);
199199
pgd_t *pgd, *pgd_k;
200+
p4d_t *p4d, *p4d_k;
200201
pud_t *pud, *pud_k;
201202
pmd_t *pmd, *pmd_k;
202203
pte_t *pte_k;
@@ -212,8 +213,13 @@ void do_page_fault(struct pt_regs *regs)
212213

213214
pgd_val(*pgd) = pgd_val(*pgd_k);
214215

215-
pud = pud_offset(pgd, address);
216-
pud_k = pud_offset(pgd_k, address);
216+
p4d = p4d_offset(pgd, address);
217+
p4d_k = p4d_offset(pgd_k, address);
218+
if (!p4d_present(*p4d) || !p4d_present(*p4d_k))
219+
goto bad_page_fault;
220+
221+
pud = pud_offset(p4d, address);
222+
pud_k = pud_offset(p4d_k, address);
217223
if (!pud_present(*pud) || !pud_present(*pud_k))
218224
goto bad_page_fault;
219225

arch/xtensa/mm/kasan_init.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ void __init kasan_early_init(void)
2020
{
2121
unsigned long vaddr = KASAN_SHADOW_START;
2222
pgd_t *pgd = pgd_offset_k(vaddr);
23-
pud_t *pud = pud_offset(pgd, vaddr);
23+
p4d_t *p4d = p4d_offset(pgd, vaddr);
24+
pud_t *pud = pud_offset(p4d, vaddr);
2425
pmd_t *pmd = pmd_offset(pud, vaddr);
2526
int i;
2627

@@ -43,7 +44,8 @@ static void __init populate(void *start, void *end)
4344
unsigned long i, j;
4445
unsigned long vaddr = (unsigned long)start;
4546
pgd_t *pgd = pgd_offset_k(vaddr);
46-
pud_t *pud = pud_offset(pgd, vaddr);
47+
p4d_t *p4d = p4d_offset(pgd, vaddr);
48+
pud_t *pud = pud_offset(p4d, vaddr);
4749
pmd_t *pmd = pmd_offset(pud, vaddr);
4850
pte_t *pte = memblock_alloc(n_pages * sizeof(pte_t), PAGE_SIZE);
4951

arch/xtensa/mm/mmu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
static void * __init init_pmd(unsigned long vaddr, unsigned long n_pages)
2323
{
2424
pgd_t *pgd = pgd_offset_k(vaddr);
25-
pud_t *pud = pud_offset(pgd, vaddr);
25+
p4d_t *p4d = p4d_offset(pgd, vaddr);
26+
pud_t *pud = pud_offset(p4d, vaddr);
2627
pmd_t *pmd = pmd_offset(pud, vaddr);
2728
pte_t *pte;
2829
unsigned long i;

arch/xtensa/mm/tlb.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ static unsigned get_pte_for_vaddr(unsigned vaddr)
169169
struct task_struct *task = get_current();
170170
struct mm_struct *mm = task->mm;
171171
pgd_t *pgd;
172+
p4d_t *p4d;
172173
pud_t *pud;
173174
pmd_t *pmd;
174175
pte_t *pte;
@@ -178,7 +179,10 @@ static unsigned get_pte_for_vaddr(unsigned vaddr)
178179
pgd = pgd_offset(mm, vaddr);
179180
if (pgd_none_or_clear_bad(pgd))
180181
return 0;
181-
pud = pud_offset(pgd, vaddr);
182+
p4d = p4d_offset(pgd, vaddr);
183+
if (p4d_none_or_clear_bad(p4d))
184+
return 0;
185+
pud = pud_offset(p4d, vaddr);
182186
if (pud_none_or_clear_bad(pud))
183187
return 0;
184188
pmd = pmd_offset(pud, vaddr);

0 commit comments

Comments
 (0)