]> git.baikalelectronics.ru Git - kernel.git/commit
powerpc: Fix kexec failure on book3s/32
authorChristophe Leroy <christophe.leroy@c-s.fr>
Mon, 3 Jun 2019 08:20:28 +0000 (08:20 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Fri, 7 Jun 2019 06:24:47 +0000 (16:24 +1000)
commitf5679f73ac69f63d6b92d0e596f2c56997a4677b
tree2de38388fe334022cb17bc6158a3b2088c487ccf
parentd4af5abda2664f52c5d43457c52ea397f34be5cb
powerpc: Fix kexec failure on book3s/32

In the old days, _PAGE_EXEC didn't exist on 6xx aka book3s/32.
Therefore, allthough __mapin_ram_chunk() was already mapping kernel
text with PAGE_KERNEL_TEXT and the rest with PAGE_KERNEL, the entire
memory was executable. Part of the memory (first 512kbytes) was
mapped with BATs instead of page table, but it was also entirely
mapped as executable.

In commit 18f18a49802a ("powerpc/mm: add exec protection on
powerpc 603"), we started adding exec protection to some 6xx, namely
the 603, for pages mapped via pagetables.

Then, in commit e9a9bd9f1407 ("powerpc/mm/32s: Use BATs for
STRICT_KERNEL_RWX"), the exec protection was extended to BAT mapped
memory, so that really only the kernel text could be executed.

The problem here is that kexec is based on copying some code into
upper part of memory then executing it from there in order to install
a fresh new kernel at its definitive location.

However, the code is position independant and first part of it is
just there to deactivate the MMU and jump to the second part. So it
is possible to run this first part inplace instead of running the
copy. Once the MMU is off, there is no protection anymore and the
second part of the code will just run as before.

Reported-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Fixes: e9a9bd9f1407 ("powerpc/mm/32s: Use BATs for STRICT_KERNEL_RWX")
Cc: stable@vger.kernel.org # v5.1+
Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Tested-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/kexec.h
arch/powerpc/kernel/machine_kexec_32.c