powerpc: Always use SPRN_SPRG_HSCRATCH0 when running in HV mode
[firefly-linux-kernel-4.4.55.git] / arch / powerpc / include / asm / exception-64s.h
index 7778d6f0c878a614a4bda84c52f2a77d02012a07..d6b4849df9b190d3fca9c1e38f26c4e3f67dfffb 100644 (file)
 #define LOAD_HANDLER(reg, label)                                       \
        addi    reg,reg,(label)-_stext; /* virt addr of handler ... */
 
-#define EXCEPTION_PROLOG_1(area)                               \
-       mfspr   r13,SPRN_SPRG_PACA;     /* get paca address into r13 */ \
+/* Exception register prefixes */
+#define EXC_HV H
+#define EXC_STD
+
+#define EXCEPTION_PROLOG_1(area)                                       \
+       GET_PACA(r13);                                                  \
        std     r9,area+EX_R9(r13);     /* save r9 - r12 */             \
        std     r10,area+EX_R10(r13);                                   \
        std     r11,area+EX_R11(r13);                                   \
        std     r12,area+EX_R12(r13);                                   \
-       mfspr   r9,SPRN_SPRG_SCRATCH0;                                  \
+       GET_SCRATCH0(r9);                                               \
        std     r9,area+EX_R13(r13);                                    \
        mfcr    r9
 
-#define EXCEPTION_PROLOG_PSERIES_1(label)                              \
+#define __EXCEPTION_PROLOG_PSERIES_1(label, h)                         \
        ld      r12,PACAKBASE(r13);     /* get high part of &label */   \
        ld      r10,PACAKMSR(r13);      /* get MSR value for kernel */  \
-       mfspr   r11,SPRN_SRR0;          /* save SRR0 */                 \
+       mfspr   r11,SPRN_##h##SRR0;     /* save SRR0 */                 \
        LOAD_HANDLER(r12,label)                                         \
-       mtspr   SPRN_SRR0,r12;                                          \
-       mfspr   r12,SPRN_SRR1;          /* and SRR1 */                  \
-       mtspr   SPRN_SRR1,r10;                                          \
-       rfid;                                                           \
+       mtspr   SPRN_##h##SRR0,r12;                                     \
+       mfspr   r12,SPRN_##h##SRR1;     /* and SRR1 */                  \
+       mtspr   SPRN_##h##SRR1,r10;                                     \
+       h##rfid;                                                        \
        b       .       /* prevent speculative execution */
+#define EXCEPTION_PROLOG_PSERIES_1(label, h) \
+       __EXCEPTION_PROLOG_PSERIES_1(label, h)
 
-#define EXCEPTION_PROLOG_PSERIES(area, label)                          \
+#define EXCEPTION_PROLOG_PSERIES(area, label, h)                       \
        EXCEPTION_PROLOG_1(area);                                       \
-       EXCEPTION_PROLOG_PSERIES_1(label);
+       EXCEPTION_PROLOG_PSERIES_1(label, h);
 
 /*
  * The common exception prolog is used for all except a few exceptions
 /*
  * Exception vectors.
  */
-#define STD_EXCEPTION_PSERIES(n, label)                        \
-       . = n;                                          \
+#define STD_EXCEPTION_PSERIES(loc, vec, label)         \
+       . = loc;                                        \
        .globl label##_pSeries;                         \
 label##_pSeries:                                       \
        HMT_MEDIUM;                                     \
-       DO_KVM  n;                                      \
-       mtspr   SPRN_SPRG_SCRATCH0,r13;         /* save r13 */  \
-       EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common)
+       DO_KVM  vec;                                    \
+       SET_SCRATCH0(r13);              /* save r13 */          \
+       EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common, EXC_STD)
 
-#define HSTD_EXCEPTION_PSERIES(n, label)               \
-       . = n;                                          \
-       .globl label##_pSeries;                         \
-label##_pSeries:                                       \
+#define STD_EXCEPTION_HV(loc, vec, label)              \
+       . = loc;                                        \
+       .globl label##_hv;                              \
+label##_hv:                                            \
        HMT_MEDIUM;                                     \
-       mtspr   SPRN_SPRG_SCRATCH0,r20; /* save r20 */  \
-       mfspr   r20,SPRN_HSRR0;         /* copy HSRR0 to SRR0 */ \
-       mtspr   SPRN_SRR0,r20;                          \
-       mfspr   r20,SPRN_HSRR1;         /* copy HSRR0 to SRR0 */ \
-       mtspr   SPRN_SRR1,r20;                          \
-       mfspr   r20,SPRN_SPRG_SCRATCH0; /* restore r20 */ \
-       mtspr   SPRN_SPRG_SCRATCH0,r13;         /* save r13 */  \
-       EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common)
+       DO_KVM  vec;                                    \
+       SET_SCRATCH0(r13);      /* save r13 */          \
+       EXCEPTION_PROLOG_PSERIES(PACA_EXGEN, label##_common, EXC_HV)
 
-
-#define MASKABLE_EXCEPTION_PSERIES(n, label)                           \
-       . = n;                                                          \
-       .globl label##_pSeries;                                         \
-label##_pSeries:                                                       \
+#define __MASKABLE_EXCEPTION_PSERIES(vec, label, h)                    \
        HMT_MEDIUM;                                                     \
-       DO_KVM  n;                                                      \
-       mtspr   SPRN_SPRG_SCRATCH0,r13; /* save r13 */                  \
-       mfspr   r13,SPRN_SPRG_PACA;     /* get paca address into r13 */ \
+       DO_KVM  vec;                                                    \
+       SET_SCRATCH0(r13);    /* save r13 */                            \
+       GET_PACA(r13);                                                  \
        std     r9,PACA_EXGEN+EX_R9(r13);       /* save r9, r10 */      \
        std     r10,PACA_EXGEN+EX_R10(r13);                             \
        lbz     r10,PACASOFTIRQEN(r13);                                 \
        mfcr    r9;                                                     \
        cmpwi   r10,0;                                                  \
-       beq     masked_interrupt;                                       \
-       mfspr   r10,SPRN_SPRG_SCRATCH0;                                 \
+       beq     masked_##h##interrupt;                                  \
+       GET_SCRATCH0(r10);                                              \
        std     r10,PACA_EXGEN+EX_R13(r13);                             \
        std     r11,PACA_EXGEN+EX_R11(r13);                             \
        std     r12,PACA_EXGEN+EX_R12(r13);                             \
        ld      r12,PACAKBASE(r13);     /* get high part of &label */   \
        ld      r10,PACAKMSR(r13);      /* get MSR value for kernel */  \
-       mfspr   r11,SPRN_SRR0;          /* save SRR0 */                 \
+       mfspr   r11,SPRN_##h##SRR0;     /* save SRR0 */                 \
        LOAD_HANDLER(r12,label##_common)                                \
-       mtspr   SPRN_SRR0,r12;                                          \
-       mfspr   r12,SPRN_SRR1;          /* and SRR1 */                  \
-       mtspr   SPRN_SRR1,r10;                                          \
-       rfid;                                                           \
+       mtspr   SPRN_##h##SRR0,r12;                                     \
+       mfspr   r12,SPRN_##h##SRR1;     /* and SRR1 */                  \
+       mtspr   SPRN_##h##SRR1,r10;                                     \
+       h##rfid;                                                        \
        b       .       /* prevent speculative execution */
+#define _MASKABLE_EXCEPTION_PSERIES(vec, label, h)                     \
+       __MASKABLE_EXCEPTION_PSERIES(vec, label, h)
+
+#define MASKABLE_EXCEPTION_PSERIES(loc, vec, label)                    \
+       . = loc;                                                        \
+       .globl label##_pSeries;                                         \
+label##_pSeries:                                                       \
+       _MASKABLE_EXCEPTION_PSERIES(vec, label, EXC_STD)
+
+#define MASKABLE_EXCEPTION_HV(loc, vec, label)                         \
+       . = loc;                                                        \
+       .globl label##_hv;                                              \
+label##_hv:                                                            \
+       _MASKABLE_EXCEPTION_PSERIES(vec, label, EXC_HV)
 
 #ifdef CONFIG_PPC_ISERIES
 #define DISABLE_INTS                           \