aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/kernel
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2016-09-01 12:30:08 -0400
committerRalf Baechle <ralf@linux-mips.org>2016-10-04 10:13:57 -0400
commitc195e079e9dd00ffeb274965737280ca6d10ff70 (patch)
tree42b894b7b27a838b0a09aee1851ccfdee0c49871 /arch/mips/kernel
parent18022894eca1315851bfd0614f011fbc01e44d16 (diff)
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 <james.hogan@imgtec.com> Cc: Matt Redfearn <matt.redfearn@imgtec.com> Cc: Leonid Yegoshin <leonid.yegoshin@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/14149/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/kernel')
-rw-r--r--arch/mips/kernel/traps.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 4b60fb53b604..edc0c3d8e386 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -2210,8 +2210,25 @@ void __init trap_init(void)
2210 2210
2211 if (cpu_has_veic || cpu_has_vint) { 2211 if (cpu_has_veic || cpu_has_vint) {
2212 unsigned long size = 0x200 + VECTORSPACING*64; 2212 unsigned long size = 0x200 + VECTORSPACING*64;
2213 phys_addr_t ebase_pa;
2214
2213 ebase = (unsigned long) 2215 ebase = (unsigned long)
2214 __alloc_bootmem(size, 1 << fls(size), 0); 2216 __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);
2215 } else { 2232 } else {
2216 ebase = CAC_BASE; 2233 ebase = CAC_BASE;
2217 2234