Skip to content

Commit c195e07

Browse files
James Hoganralfbaechle
authored andcommitted
MIPS: traps: Convert ebase to KSEG0
When allocating boot memory for the exception vector when vectored interrupts (vint) or vectored external interrupt controllers (veic) are enabled, try to ensure that the virtual address resides in KSeg0 (and WARN should that not be possible). This will be helpful on MIPS64 cores supporting the CP0_EBase Write Gate (WG) bit once we start using the WG bit to write the full ebase into CP0_EBase, as we ideally need to avoid hitting the architecturally poorly defined exception base for Cache Errors when CP0_EBase is in XKPhys. An exception is made for Enhanced Virtual Addressing (EVA) kernels which allow segments to be rearranged and to become uncached during cache error handling, making it valid for ebase to be elsewhere. Signed-off-by: James Hogan <[email protected]> Cc: Matt Redfearn <[email protected]> Cc: Leonid Yegoshin <[email protected]> Cc: [email protected] Patchwork: https://patchwork.linux-mips.org/patch/14149/ Signed-off-by: Ralf Baechle <[email protected]>
1 parent 1802289 commit c195e07

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

arch/mips/kernel/traps.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,8 +2210,25 @@ void __init trap_init(void)
22102210

22112211
if (cpu_has_veic || cpu_has_vint) {
22122212
unsigned long size = 0x200 + VECTORSPACING*64;
2213+
phys_addr_t ebase_pa;
2214+
22132215
ebase = (unsigned long)
22142216
__alloc_bootmem(size, 1 << fls(size), 0);
2217+
2218+
/*
2219+
* Try to ensure ebase resides in KSeg0 if possible.
2220+
*
2221+
* It shouldn't generally be in XKPhys on MIPS64 to avoid
2222+
* hitting a poorly defined exception base for Cache Errors.
2223+
* The allocation is likely to be in the low 512MB of physical,
2224+
* in which case we should be able to convert to KSeg0.
2225+
*
2226+
* EVA is special though as it allows segments to be rearranged
2227+
* and to become uncached during cache error handling.
2228+
*/
2229+
ebase_pa = __pa(ebase);
2230+
if (!IS_ENABLED(CONFIG_EVA) && !WARN_ON(ebase_pa >= 0x20000000))
2231+
ebase = CKSEG0ADDR(ebase_pa);
22152232
} else {
22162233
ebase = CAC_BASE;
22172234

0 commit comments

Comments
 (0)