MIPS: Always allocate exception vector for MIPSr2+
authorPaul Burton <paul.burton@mips.com>
Tue, 30 Apr 2019 22:53:30 +0000 (22:53 +0000)
committerPaul Burton <paul.burton@mips.com>
Thu, 2 May 2019 18:20:47 +0000 (11:20 -0700)
commit172dcd935c34b022729f45a7bbaae5cc05231533
tree2561c53caebe4df0c5369662cc05c98fa914773a
parentf995adb0ac5bcfa0d396ba7706aab420c7a6fec2
MIPS: Always allocate exception vector for MIPSr2+

Currently we allocate the exception vector on systems which use a
vectored interrupt mode, but otherwise attempt to reuse whatever
exception vector the bootloader uses.

This can be problematic for a number of reasons:

  1) The memory isn't properly marked reserved in the memblock
     allocator. We've relied on the fact that EBase is generally in the
     memory below the kernel image which we don't free, but this is
     about to change.

  2) Recent versions of U-Boot place their exception vector high in
     kseg0, in memory which isn't protected by being lower than the
     kernel anyway & can end up being clobbered.

  3) We are unnecessarily reliant upon there being memory at the address
     EBase points to upon entry to the kernel. This is often the case,
     but if the bootloader doesn't configure EBase & leaves it with its
     default value then we rely upon there being memory at physical
     address 0 for no good reason.

Improve this situation by allocating the exception vector in all cases
when running on MIPSr2 or higher, and reserving the memory for MIPSr1 or
lower. This ensures we don't clobber the exception vector in any
configuration, and for MIPSr2 & higher removes the need for memory at
physical address 0.

Signed-off-by: Paul Burton <paul.burton@mips.com>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Tested-by: Serge Semin <fancer.lancer@gmail.com>
Cc: linux-mips@vger.kernel.org
arch/mips/kernel/traps.c