Skip to content

Commit c2edb35

Browse files
committed
xtensa: extract init_kio
KIO region placement may be specified in the device tree, that's why it's initialized with the rest of MMU after the early_init_devtree. In order to support KASAN the MMU must be initialized earlier. Separate KIO initialization from the rest of MMU initialization. Reinitialize KIO if its location is specified in the device tree. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
1 parent 501c26e commit c2edb35

4 files changed

Lines changed: 28 additions & 17 deletions

File tree

‎arch/xtensa/include/asm/mmu_context.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ DECLARE_PER_CPU(unsigned long, asid_cache);
5252
#define ASID_INSERT(x) (0x03020001 | (((x) & ASID_MASK) << 8))
5353

5454
void init_mmu(void);
55+
void init_kio(void);
5556

5657
static inline void set_rasid_register (unsigned long val)
5758
{

‎arch/xtensa/include/asm/nommu_context.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ static inline void init_mmu(void)
33
{
44
}
55

6+
static inline void init_kio(void)
7+
{
8+
}
9+
610
static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
711
{
812
}

‎arch/xtensa/kernel/setup.c‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,8 @@ static int __init xtensa_dt_io_area(unsigned long node, const char *uname,
207207
/* round down to nearest 256MB boundary */
208208
xtensa_kio_paddr &= 0xf0000000;
209209

210+
init_kio();
211+
210212
return 1;
211213
}
212214
#else
@@ -245,6 +247,10 @@ void __init early_init_devtree(void *params)
245247

246248
void __init init_arch(bp_tag_t *bp_start)
247249
{
250+
/* Initialize MMU. */
251+
252+
init_mmu();
253+
248254
/* Parse boot parameters */
249255

250256
if (bp_start)
@@ -262,10 +268,6 @@ void __init init_arch(bp_tag_t *bp_start)
262268
/* Early hook for platforms */
263269

264270
platform_init(bp_start);
265-
266-
/* Initialize MMU. */
267-
268-
init_mmu();
269271
}
270272

271273
/*

‎arch/xtensa/mm/mmu.c‎

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,23 @@ void init_mmu(void)
8282
set_itlbcfg_register(0);
8383
set_dtlbcfg_register(0);
8484
#endif
85+
init_kio();
86+
local_flush_tlb_all();
87+
88+
/* Set rasid register to a known value. */
89+
90+
set_rasid_register(ASID_INSERT(ASID_USER_FIRST));
91+
92+
/* Set PTEVADDR special register to the start of the page
93+
* table, which is in kernel mappable space (ie. not
94+
* statically mapped). This register's value is undefined on
95+
* reset.
96+
*/
97+
set_ptevaddr_register(XCHAL_PAGE_TABLE_VADDR);
98+
}
99+
100+
void init_kio(void)
101+
{
85102
#if XCHAL_HAVE_PTP_MMU && XCHAL_HAVE_SPANNING_WAY && defined(CONFIG_OF)
86103
/*
87104
* Update the IO area mapping in case xtensa_kio_paddr has changed
@@ -95,17 +112,4 @@ void init_mmu(void)
95112
write_itlb_entry(__pte(xtensa_kio_paddr + CA_BYPASS),
96113
XCHAL_KIO_BYPASS_VADDR + 6);
97114
#endif
98-
99-
local_flush_tlb_all();
100-
101-
/* Set rasid register to a known value. */
102-
103-
set_rasid_register(ASID_INSERT(ASID_USER_FIRST));
104-
105-
/* Set PTEVADDR special register to the start of the page
106-
* table, which is in kernel mappable space (ie. not
107-
* statically mapped). This register's value is undefined on
108-
* reset.
109-
*/
110-
set_ptevaddr_register(PGTABLE_START);
111115
}

0 commit comments

Comments
 (0)