powerpc/book3s: Fix CFAR clobbering issue in machine check handler.
authorMahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Tue, 11 Mar 2014 05:26:18 +0000 (10:56 +0530)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Sun, 23 Mar 2014 23:16:09 +0000 (10:16 +1100)
While checking powersaving mode in machine check handler at 0x200, we
clobber CFAR register. Fix it by saving and restoring it during beq/bgt.

Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/exception-64s.h
arch/powerpc/kernel/exceptions-64s.S

index 66830618cc19b2f4b12a5b6cefa8d1663425187e..aeaa56cd9b5465100b00025c7a1da36b3d58e1c5 100644 (file)
@@ -146,6 +146,14 @@ BEGIN_FTR_SECTION_NESTED(943)                                              \
        mfspr   ra,spr;                                                 \
 END_FTR_SECTION_NESTED(ftr,ftr,943)
 
+/*
+ * Set an SPR from a register if the CPU has the given feature
+ */
+#define OPT_SET_SPR(ra, spr, ftr)                                      \
+BEGIN_FTR_SECTION_NESTED(943)                                          \
+       mtspr   spr,ra;                                                 \
+END_FTR_SECTION_NESTED(ftr,ftr,943)
+
 /*
  * Save a register to the PACA if the CPU has the given feature
  */
index 38d507306a111dc40f06028c90d5014e2fedd817..4c34c3c827ad5be65a4f59381c9f485086662fe9 100644 (file)
@@ -164,13 +164,18 @@ BEGIN_FTR_SECTION
         */
        mfspr   r13,SPRN_SRR1
        rlwinm. r13,r13,47-31,30,31
+       OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR)
        beq     9f
 
+       mfspr   r13,SPRN_SRR1
+       rlwinm. r13,r13,47-31,30,31
        /* waking up from powersave (nap) state */
        cmpwi   cr1,r13,2
        /* Total loss of HV state is fatal. let's just stay stuck here */
+       OPT_GET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR)
        bgt     cr1,.
 9:
+       OPT_SET_SPR(r13, SPRN_CFAR, CPU_FTR_CFAR)
 END_FTR_SECTION_IFSET(CPU_FTR_HVMODE | CPU_FTR_ARCH_206)
 #endif /* CONFIG_PPC_P7_NAP */
        EXCEPTION_PROLOG_0(PACA_EXMC)