MIPS: mm: Fix the cache error vector jump for XKPHYS kernels
Subsystems (2)
PATCH 1/1 MIPS: mm: Fix the cache error vector jump for XKPHYS kernels
except_vec2_generic jumps to cache_parity_error with a j, which cannot leave the vector's 256MB region. An XKPHYS kernel such as IP30's, linked at 512MB, is outside it, so the j targets an unbacked address and its speculative fetch raises bus errors on unrelated fetches. Jump to the handler's uncached XKPHYS address instead.
--- arch/mips/mm/cex-gen.S | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
arch/mips/mm/cex-gen.S +16 -0
@@ -8,6 +8,7 @@ * * Cache error handler */ +#include <asm/addrspace.h> #include <asm/asm.h> #include <asm/regdef.h> #include <asm/mipsregs.h>
@@ -37,6 +38,21 @@ nop nop +#if defined(CONFIG_64BIT) && VMLINUX_LOAD_ADDRESS >= XKPHYS && \ + VMLINUX_LOAD_ADDRESS < XKSEG + /* + * An XKPHYS kernel may lie outside the 256MB region a j from the + * vector reaches, so jump to the handler's uncached XKPHYS address. + */ + PTR_LA k0, cache_parity_error + PTR_LI k1, TO_PHYS_MASK + and k0, k0, k1 + PTR_LI k1, UNCAC_BASE + or k0, k0, k1 + jr k0 + nop +#else j cache_parity_error nop +#endif END(except_vec2_generic)
base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907
Quoted 6 lines · Imre Kaloz
except_vec2_genericjumps tocache_parity_errorwith a j, which cannot leave the vector's 256MB region. An XKPHYS kernel such as IP30's, linked at 512MB, is outside it, so the j targets an unbacked address and its speculative fetch raises bus errors on unrelated fetches. Jump to the handler's uncached XKPHYS address instead.
Quoted 6 lines
Fixes 7505576d1c1a ("MIPS: add support for SGI Octane (IP30)")Signed-off-by Imre Kaloz <[email protected]>--- arch/mips/mm/cex-gen.S | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
applied to mips-fixes
Thomas.
Signature · 2 lines
Crap can work. Given enough thrust pigs will fly, but it's not necessarily a good idea. [ RFC1925, 2.3 ]
arch/mips/mm/cex-gen.S line 42
Quoted 10 lines · Imre Kaloz
arch/mips/mm/cex-gen.S +2
-0@@ -37,6 +38,21 @@ nop nop +#if defined(CONFIG_64BIT) && VMLINUX_LOAD_ADDRESS >= XKPHYS && \ + VMLINUX_LOAD_ADDRESS < XKSEG
Not VMLINUX_LOAD_ADDRESS < CKSEG0 to take care of CONFIG_MAPPED_KERNEL?
Of course we'd have to switch caching in the wired TLB entry then too, but at least we won't crash outright...
arch/mips/mm/cex-gen.S line 53
Quoted 11 lines
arch/mips/mm/cex-gen.S +11
-0+ /* + * An XKPHYS kernel may lie outside the 256MB region a j from the + * vector reaches, so jump to the handler's uncached XKPHYS address. + */ + PTR_LA k0, cache_parity_error + PTR_LI k1, TO_PHYS_MASK + and k0, k0, k1 + PTR_LI k1, UNCAC_BASE + or k0, k0, k1 + jr k0 + nop
Given that this runs at ERL, a much shorter sequence could look like:
LEAF(except_vec2_generic)
0:
[...] PTR_L k0, %lo(0x100 + (1f - 0b))(zero) jr k0 nop 1: .quad cache_parity_error [...] END(except_vec2_generic)
but I guess it doesn't matter that much as long as we don't overrun the exception handler slot, since this is obviously not a hot path. Still it could be considered neater, couldn't it?
Maciej