]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
powerpc/kexec: Fix radix to hash kexec due to IAMR/AMOR
authorBalbir Singh <bsingharora@gmail.com>
Thu, 29 Jun 2017 11:57:26 +0000 (21:57 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Mon, 10 Jul 2017 11:07:38 +0000 (21:07 +1000)
This patch fixes a crash seen while doing a kexec from radix mode to
hash mode. Key 0 is special in hash and used in the RPN by default, we
set the key values to 0 today. In radix mode key 0 is used to control
supervisor<->user access. In hash key 0 is used by default, so the
first instruction after the switch causes a crash on kexec.

Commit 3b10d0095a1e ("powerpc/mm/radix: Prevent kernel execution of
user space") introduced the setting of IAMR and AMOR values to prevent
execution of user mode instructions from supervisor mode. We need to
clean up these SPR's on kexec.

Fixes: 3b10d0095a1e ("powerpc/mm/radix: Prevent kernel execution of user space")
Cc: stable@vger.kernel.org # v4.10+
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Balbir Singh <bsingharora@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/misc_64.S

index c119044cad0d58e94bb0d4a7557ed27da8f7a390..8ac0bd2bddb0c93b95dccfd61807807219913b5e 100644 (file)
@@ -614,6 +614,18 @@ _GLOBAL(kexec_sequence)
        li      r0,0
        std     r0,16(r1)
 
+BEGIN_FTR_SECTION
+       /*
+        * This is the best time to turn AMR/IAMR off.
+        * key 0 is used in radix for supervisor<->user
+        * protection, but on hash key 0 is reserved
+        * ideally we want to enter with a clean state.
+        * NOTE, we rely on r0 being 0 from above.
+        */
+       mtspr   SPRN_IAMR,r0
+       mtspr   SPRN_AMOR,r0
+END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
+
        /* save regs for local vars on new stack.
         * yes, we won't go back, but ...
         */