]> git.baikalelectronics.ru Git - kernel.git/commit
MIPS: kernel: Reserve exception base early to prevent corruption
authorThomas Bogendoerfer <tsbogend@alpha.franken.de>
Mon, 8 Mar 2021 09:24:47 +0000 (10:24 +0100)
committerThomas Bogendoerfer <tsbogend@alpha.franken.de>
Tue, 9 Mar 2021 10:22:59 +0000 (11:22 +0100)
commit0a6b7df93db3a05126bc08a063c2746b45305dda
treedc2d59c8cd38b94ff3a546b6f8eed444c04907a5
parentb41d6d2988dc8df283a3692bfc8ab2d1e489df69
MIPS: kernel: Reserve exception base early to prevent corruption

BMIPS is one of the few platforms that do change the exception base.
After commit 69de43c0f8f6 ("memblock: do not start bottom-up allocations
with kernel_end") we started seeing BMIPS boards fail to boot with the
built-in FDT being corrupted.

Before the cited commit, early allocations would be in the [kernel_end,
RAM_END] range, but after commit they would be within [RAM_START +
PAGE_SIZE, RAM_END].

The custom exception base handler that is installed by
bmips_ebase_setup() done for BMIPS5000 CPUs ends-up trampling on the
memory region allocated by unflatten_and_copy_device_tree() thus
corrupting the FDT used by the kernel.

To fix this, we need to perform an early reservation of the custom
exception space. Additional we reserve the first 4k (1k for R3k) for
either normal exception vector space (legacy CPUs) or special vectors
like cache exceptions.

Huge thanks to Serge for analysing and proposing a solution to this
issue.

Fixes: 69de43c0f8f6 ("memblock: do not start bottom-up allocations with kernel_end")
Reported-by: Kamal Dasu <kdasu.kdev@gmail.com>
Debugged-by: Serge Semin <Sergey.Semin@baikalelectronics.ru>
Acked-by: Mike Rapoport <rppt@linux.ibm.com>
Tested-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Serge Semin <fancer.lancer@gmail.com>
Signed-off-by: Thomas Bogendoerfer <tsbogend@alpha.franken.de>
arch/mips/include/asm/traps.h
arch/mips/kernel/cpu-probe.c
arch/mips/kernel/cpu-r3k-probe.c
arch/mips/kernel/traps.c