powerpc/64s: Fix FIXUP_ENDIAN non-maskable interrupt reentrancy
authorNicholas Piggin <npiggin@gmail.com>
Mon, 1 May 2017 12:01:09 +0000 (22:01 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 30 May 2017 04:59:51 +0000 (14:59 +1000)
FIXUP_ENDIAN uses SRR[01] with MSR_RI=1, which gets corrupted if there
is an interleaving system reset or machine check interrupt.

Set MSR_RI=0 before setting SRRs. The rfid will restore MSR.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/boot/ppc_asm.h
arch/powerpc/include/asm/ppc_asm.h

index b03373d8b386defe78477aec523e8540d0df3d68..68e388ee94fe51ac89f47669f3eb41a65384d13a 100644 (file)
 #define MSR_LE         0x0000000000000001
 
 #define FIXUP_ENDIAN                                              \
-       tdi   0, 0, 0x48; /* Reverse endian of b . + 8          */ \
-       b     $+36;       /* Skip trampoline if endian is good  */ \
-       .long 0x05009f42; /* bcl 20,31,$+4                      */ \
-       .long 0xa602487d; /* mflr r10                           */ \
-       .long 0x1c004a39; /* addi r10,r10,28                    */ \
+       tdi   0,0,0x48;   /* Reverse endian of b . + 8          */ \
+       b     $+44;       /* Skip trampoline if endian is good  */ \
        .long 0xa600607d; /* mfmsr r11                          */ \
        .long 0x01006b69; /* xori r11,r11,1                     */ \
+       .long 0x00004039; /* li r10,0                           */ \
+       .long 0x6401417d; /* mtmsrd r10,1                       */ \
+       .long 0x05009f42; /* bcl 20,31,$+4                      */ \
+       .long 0xa602487d; /* mflr r10                           */ \
+       .long 0x14004a39; /* addi r10,r10,20                    */ \
        .long 0xa6035a7d; /* mtsrr0 r10                         */ \
        .long 0xa6037b7d; /* mtsrr1 r11                         */ \
        .long 0x2400004c  /* rfid                               */
index 359c443417616c0137b08e7361bb6ea151263b30..6baeeb9acd0d6efdcf19f07075668a42f30c8c40 100644 (file)
@@ -770,15 +770,18 @@ END_FTR_SECTION_IFCLR(CPU_FTR_601)
 #else
 #define FIXUP_ENDIAN                                              \
        tdi   0,0,0x48;   /* Reverse endian of b . + 8          */ \
-       b     $+36;       /* Skip trampoline if endian is good  */ \
-       .long 0x05009f42; /* bcl 20,31,$+4                      */ \
-       .long 0xa602487d; /* mflr r10                           */ \
-       .long 0x1c004a39; /* addi r10,r10,28                    */ \
+       b     $+44;       /* Skip trampoline if endian is good  */ \
        .long 0xa600607d; /* mfmsr r11                          */ \
        .long 0x01006b69; /* xori r11,r11,1                     */ \
+       .long 0x00004039; /* li r10,0                           */ \
+       .long 0x6401417d; /* mtmsrd r10,1                       */ \
+       .long 0x05009f42; /* bcl 20,31,$+4                      */ \
+       .long 0xa602487d; /* mflr r10                           */ \
+       .long 0x14004a39; /* addi r10,r10,20                    */ \
        .long 0xa6035a7d; /* mtsrr0 r10                         */ \
        .long 0xa6037b7d; /* mtsrr1 r11                         */ \
        .long 0x2400004c  /* rfid                               */
+
 #endif /* !CONFIG_PPC_BOOK3E */
 
 #endif /*  __ASSEMBLY__ */