提交 aebd1fb4 编写于 作者: N Nicholas Piggin 提交者: Michael Ellerman

powerpc: flexible GPR range save/restore macros

Introduce macros that operate on a (start, end) range of GPRs, which
reduces lines of code and need to do mental arithmetic while reading the
code.
Signed-off-by: NNicholas Piggin <npiggin@gmail.com>
Reviewed-by: NSegher Boessenkool <segher@kernel.crashing.org>
Reviewed-by: NChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20211022061322.2671178-1-npiggin@gmail.com
上级 e012c499
...@@ -226,16 +226,19 @@ p_base: mflr r10 /* r10 now points to runtime addr of p_base */ ...@@ -226,16 +226,19 @@ p_base: mflr r10 /* r10 now points to runtime addr of p_base */
#ifdef __powerpc64__ #ifdef __powerpc64__
#define PROM_FRAME_SIZE 512 #define PROM_FRAME_SIZE 512
#define SAVE_GPR(n, base) std n,8*(n)(base)
#define REST_GPR(n, base) ld n,8*(n)(base) .macro OP_REGS op, width, start, end, base, offset
#define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base) .Lreg=\start
#define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base) .rept (\end - \start + 1)
#define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base) \op .Lreg,\offset+\width*.Lreg(\base)
#define SAVE_10GPRS(n, base) SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base) .Lreg=.Lreg+1
#define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base) .endr
#define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base) .endm
#define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base)
#define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base) #define SAVE_GPRS(start, end, base) OP_REGS std, 8, start, end, base, 0
#define REST_GPRS(start, end, base) OP_REGS ld, 8, start, end, base, 0
#define SAVE_GPR(n, base) SAVE_GPRS(n, n, base)
#define REST_GPR(n, base) REST_GPRS(n, n, base)
/* prom handles the jump into and return from firmware. The prom args pointer /* prom handles the jump into and return from firmware. The prom args pointer
is loaded in r3. */ is loaded in r3. */
...@@ -246,9 +249,7 @@ prom: ...@@ -246,9 +249,7 @@ prom:
stdu r1,-PROM_FRAME_SIZE(r1) /* Save SP and create stack space */ stdu r1,-PROM_FRAME_SIZE(r1) /* Save SP and create stack space */
SAVE_GPR(2, r1) SAVE_GPR(2, r1)
SAVE_GPR(13, r1) SAVE_GPRS(13, 31, r1)
SAVE_8GPRS(14, r1)
SAVE_10GPRS(22, r1)
mfcr r10 mfcr r10
std r10,8*32(r1) std r10,8*32(r1)
mfmsr r10 mfmsr r10
...@@ -283,9 +284,7 @@ prom: ...@@ -283,9 +284,7 @@ prom:
/* Restore other registers */ /* Restore other registers */
REST_GPR(2, r1) REST_GPR(2, r1)
REST_GPR(13, r1) REST_GPRS(13, 31, r1)
REST_8GPRS(14, r1)
REST_10GPRS(22, r1)
ld r10,8*32(r1) ld r10,8*32(r1)
mtcr r10 mtcr r10
......
...@@ -38,15 +38,11 @@ ...@@ -38,15 +38,11 @@
#define INITIALIZE \ #define INITIALIZE \
PPC_STLU r1,-INT_FRAME_SIZE(r1); \ PPC_STLU r1,-INT_FRAME_SIZE(r1); \
SAVE_8GPRS(14, r1); /* push registers onto stack */ \ SAVE_GPRS(14, 26, r1) /* push registers onto stack */
SAVE_4GPRS(22, r1); \
SAVE_GPR(26, r1)
#define FINALIZE \ #define FINALIZE \
REST_8GPRS(14, r1); /* pop registers from stack */ \ REST_GPRS(14, 26, r1); /* pop registers from stack */ \
REST_4GPRS(22, r1); \ addi r1,r1,INT_FRAME_SIZE
REST_GPR(26, r1); \
addi r1,r1,INT_FRAME_SIZE;
#ifdef __BIG_ENDIAN__ #ifdef __BIG_ENDIAN__
#define LOAD_DATA(reg, off) \ #define LOAD_DATA(reg, off) \
......
...@@ -125,8 +125,7 @@ ...@@ -125,8 +125,7 @@
_GLOBAL(powerpc_sha_transform) _GLOBAL(powerpc_sha_transform)
PPC_STLU r1,-INT_FRAME_SIZE(r1) PPC_STLU r1,-INT_FRAME_SIZE(r1)
SAVE_8GPRS(14, r1) SAVE_GPRS(14, 31, r1)
SAVE_10GPRS(22, r1)
/* Load up A - E */ /* Load up A - E */
lwz RA(0),0(r3) /* A */ lwz RA(0),0(r3) /* A */
...@@ -184,7 +183,6 @@ _GLOBAL(powerpc_sha_transform) ...@@ -184,7 +183,6 @@ _GLOBAL(powerpc_sha_transform)
stw RD(0),12(r3) stw RD(0),12(r3)
stw RE(0),16(r3) stw RE(0),16(r3)
REST_8GPRS(14, r1) REST_GPRS(14, 31, r1)
REST_10GPRS(22, r1)
addi r1,r1,INT_FRAME_SIZE addi r1,r1,INT_FRAME_SIZE
blr blr
...@@ -16,30 +16,41 @@ ...@@ -16,30 +16,41 @@
#define SZL (BITS_PER_LONG/8) #define SZL (BITS_PER_LONG/8)
/*
* This expands to a sequence of operations with reg incrementing from
* start to end inclusive, of this form:
*
* op reg, (offset + (width * reg))(base)
*
* Note that offset is not the offset of the first operation unless start
* is zero (or width is zero).
*/
.macro OP_REGS op, width, start, end, base, offset
.Lreg=\start
.rept (\end - \start + 1)
\op .Lreg, \offset + \width * .Lreg(\base)
.Lreg=.Lreg+1
.endr
.endm
/* /*
* Macros for storing registers into and loading registers from * Macros for storing registers into and loading registers from
* exception frames. * exception frames.
*/ */
#ifdef __powerpc64__ #ifdef __powerpc64__
#define SAVE_GPR(n, base) std n,GPR0+8*(n)(base) #define SAVE_GPRS(start, end, base) OP_REGS std, 8, start, end, base, GPR0
#define REST_GPR(n, base) ld n,GPR0+8*(n)(base) #define REST_GPRS(start, end, base) OP_REGS ld, 8, start, end, base, GPR0
#define SAVE_NVGPRS(base) SAVE_8GPRS(14, base); SAVE_10GPRS(22, base) #define SAVE_NVGPRS(base) SAVE_GPRS(14, 31, base)
#define REST_NVGPRS(base) REST_8GPRS(14, base); REST_10GPRS(22, base) #define REST_NVGPRS(base) REST_GPRS(14, 31, base)
#else #else
#define SAVE_GPR(n, base) stw n,GPR0+4*(n)(base) #define SAVE_GPRS(start, end, base) OP_REGS stw, 4, start, end, base, GPR0
#define REST_GPR(n, base) lwz n,GPR0+4*(n)(base) #define REST_GPRS(start, end, base) OP_REGS lwz, 4, start, end, base, GPR0
#define SAVE_NVGPRS(base) SAVE_GPR(13, base); SAVE_8GPRS(14, base); SAVE_10GPRS(22, base) #define SAVE_NVGPRS(base) SAVE_GPRS(13, 31, base)
#define REST_NVGPRS(base) REST_GPR(13, base); REST_8GPRS(14, base); REST_10GPRS(22, base) #define REST_NVGPRS(base) REST_GPRS(13, 31, base)
#endif #endif
#define SAVE_2GPRS(n, base) SAVE_GPR(n, base); SAVE_GPR(n+1, base) #define SAVE_GPR(n, base) SAVE_GPRS(n, n, base)
#define SAVE_4GPRS(n, base) SAVE_2GPRS(n, base); SAVE_2GPRS(n+2, base) #define REST_GPR(n, base) REST_GPRS(n, n, base)
#define SAVE_8GPRS(n, base) SAVE_4GPRS(n, base); SAVE_4GPRS(n+4, base)
#define SAVE_10GPRS(n, base) SAVE_8GPRS(n, base); SAVE_2GPRS(n+8, base)
#define REST_2GPRS(n, base) REST_GPR(n, base); REST_GPR(n+1, base)
#define REST_4GPRS(n, base) REST_2GPRS(n, base); REST_2GPRS(n+2, base)
#define REST_8GPRS(n, base) REST_4GPRS(n, base); REST_4GPRS(n+4, base)
#define REST_10GPRS(n, base) REST_8GPRS(n, base); REST_2GPRS(n+8, base)
#define SAVE_FPR(n, base) stfd n,8*TS_FPRWIDTH*(n)(base) #define SAVE_FPR(n, base) stfd n,8*TS_FPRWIDTH*(n)(base)
#define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base) #define SAVE_2FPRS(n, base) SAVE_FPR(n, base); SAVE_FPR(n+1, base)
......
...@@ -90,8 +90,7 @@ transfer_to_syscall: ...@@ -90,8 +90,7 @@ transfer_to_syscall:
stw r12,8(r1) stw r12,8(r1)
stw r2,_TRAP(r1) stw r2,_TRAP(r1)
SAVE_GPR(0, r1) SAVE_GPR(0, r1)
SAVE_4GPRS(3, r1) SAVE_GPRS(3, 8, r1)
SAVE_2GPRS(7, r1)
addi r2,r10,-THREAD addi r2,r10,-THREAD
SAVE_NVGPRS(r1) SAVE_NVGPRS(r1)
...@@ -139,7 +138,7 @@ syscall_exit_finish: ...@@ -139,7 +138,7 @@ syscall_exit_finish:
mtxer r5 mtxer r5
lwz r0,GPR0(r1) lwz r0,GPR0(r1)
lwz r3,GPR3(r1) lwz r3,GPR3(r1)
REST_8GPRS(4,r1) REST_GPRS(4, 11, r1)
lwz r12,GPR12(r1) lwz r12,GPR12(r1)
b 1b b 1b
...@@ -232,9 +231,9 @@ fast_exception_return: ...@@ -232,9 +231,9 @@ fast_exception_return:
beq 3f /* if not, we've got problems */ beq 3f /* if not, we've got problems */
#endif #endif
2: REST_4GPRS(3, r11) 2: REST_GPRS(3, 6, r11)
lwz r10,_CCR(r11) lwz r10,_CCR(r11)
REST_2GPRS(1, r11) REST_GPRS(1, 2, r11)
mtcr r10 mtcr r10
lwz r10,_LINK(r11) lwz r10,_LINK(r11)
mtlr r10 mtlr r10
...@@ -298,16 +297,14 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) ...@@ -298,16 +297,14 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
* the reliable stack unwinder later on. Clear it. * the reliable stack unwinder later on. Clear it.
*/ */
stw r0,8(r1) stw r0,8(r1)
REST_4GPRS(7, r1) REST_GPRS(7, 12, r1)
REST_2GPRS(11, r1)
mtcr r3 mtcr r3
mtlr r4 mtlr r4
mtctr r5 mtctr r5
mtspr SPRN_XER,r6 mtspr SPRN_XER,r6
REST_4GPRS(2, r1) REST_GPRS(2, 6, r1)
REST_GPR(6, r1)
REST_GPR(0, r1) REST_GPR(0, r1)
REST_GPR(1, r1) REST_GPR(1, r1)
rfi rfi
...@@ -341,8 +338,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) ...@@ -341,8 +338,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
lwz r6,_CCR(r1) lwz r6,_CCR(r1)
li r0,0 li r0,0
REST_4GPRS(7, r1) REST_GPRS(7, 12, r1)
REST_2GPRS(11, r1)
mtlr r3 mtlr r3
mtctr r4 mtctr r4
...@@ -354,7 +350,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) ...@@ -354,7 +350,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
*/ */
stw r0,8(r1) stw r0,8(r1)
REST_4GPRS(2, r1) REST_GPRS(2, 5, r1)
bne- cr1,1f /* emulate stack store */ bne- cr1,1f /* emulate stack store */
mtcr r6 mtcr r6
...@@ -430,8 +426,7 @@ _ASM_NOKPROBE_SYMBOL(interrupt_return) ...@@ -430,8 +426,7 @@ _ASM_NOKPROBE_SYMBOL(interrupt_return)
bne interrupt_return; \ bne interrupt_return; \
lwz r0,GPR0(r1); \ lwz r0,GPR0(r1); \
lwz r2,GPR2(r1); \ lwz r2,GPR2(r1); \
REST_4GPRS(3, r1); \ REST_GPRS(3, 8, r1); \
REST_2GPRS(7, r1); \
lwz r10,_XER(r1); \ lwz r10,_XER(r1); \
lwz r11,_CTR(r1); \ lwz r11,_CTR(r1); \
mtspr SPRN_XER,r10; \ mtspr SPRN_XER,r10; \
......
...@@ -198,8 +198,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV) ...@@ -198,8 +198,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_EMB_HV)
stdcx. r0,0,r1 /* to clear the reservation */ stdcx. r0,0,r1 /* to clear the reservation */
REST_4GPRS(2, r1) REST_GPRS(2, 9, r1)
REST_4GPRS(6, r1)
ld r10,_CTR(r1) ld r10,_CTR(r1)
ld r11,_XER(r1) ld r11,_XER(r1)
...@@ -375,9 +374,7 @@ ret_from_mc_except: ...@@ -375,9 +374,7 @@ ret_from_mc_except:
exc_##n##_common: \ exc_##n##_common: \
std r0,GPR0(r1); /* save r0 in stackframe */ \ std r0,GPR0(r1); /* save r0 in stackframe */ \
std r2,GPR2(r1); /* save r2 in stackframe */ \ std r2,GPR2(r1); /* save r2 in stackframe */ \
SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ SAVE_GPRS(3, 9, r1); /* save r3 - r9 in stackframe */ \
SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \
std r9,GPR9(r1); /* save r9 in stackframe */ \
std r10,_NIP(r1); /* save SRR0 to stackframe */ \ std r10,_NIP(r1); /* save SRR0 to stackframe */ \
std r11,_MSR(r1); /* save SRR1 to stackframe */ \ std r11,_MSR(r1); /* save SRR1 to stackframe */ \
beq 2f; /* if from kernel mode */ \ beq 2f; /* if from kernel mode */ \
...@@ -1061,9 +1058,7 @@ bad_stack_book3e: ...@@ -1061,9 +1058,7 @@ bad_stack_book3e:
std r11,_ESR(r1) std r11,_ESR(r1)
std r0,GPR0(r1); /* save r0 in stackframe */ \ std r0,GPR0(r1); /* save r0 in stackframe */ \
std r2,GPR2(r1); /* save r2 in stackframe */ \ std r2,GPR2(r1); /* save r2 in stackframe */ \
SAVE_4GPRS(3, r1); /* save r3 - r6 in stackframe */ \ SAVE_GPRS(3, 9, r1); /* save r3 - r9 in stackframe */ \
SAVE_2GPRS(7, r1); /* save r7, r8 in stackframe */ \
std r9,GPR9(r1); /* save r9 in stackframe */ \
ld r3,PACA_EXGEN+EX_R10(r13);/* get back r10 */ \ ld r3,PACA_EXGEN+EX_R10(r13);/* get back r10 */ \
ld r4,PACA_EXGEN+EX_R11(r13);/* get back r11 */ \ ld r4,PACA_EXGEN+EX_R11(r13);/* get back r11 */ \
mfspr r5,SPRN_SPRG_GEN_SCRATCH;/* get back r13 XXX can be wrong */ \ mfspr r5,SPRN_SPRG_GEN_SCRATCH;/* get back r13 XXX can be wrong */ \
...@@ -1077,8 +1072,7 @@ bad_stack_book3e: ...@@ -1077,8 +1072,7 @@ bad_stack_book3e:
std r10,_LINK(r1) std r10,_LINK(r1)
std r11,_CTR(r1) std r11,_CTR(r1)
std r12,_XER(r1) std r12,_XER(r1)
SAVE_10GPRS(14,r1) SAVE_GPRS(14, 31, r1)
SAVE_8GPRS(24,r1)
lhz r12,PACA_TRAP_SAVE(r13) lhz r12,PACA_TRAP_SAVE(r13)
std r12,_TRAP(r1) std r12,_TRAP(r1)
addi r11,r1,INT_FRAME_SIZE addi r11,r1,INT_FRAME_SIZE
......
...@@ -574,8 +574,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR) ...@@ -574,8 +574,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
ld r10,IAREA+EX_CTR(r13) ld r10,IAREA+EX_CTR(r13)
std r10,_CTR(r1) std r10,_CTR(r1)
std r2,GPR2(r1) /* save r2 in stackframe */ std r2,GPR2(r1) /* save r2 in stackframe */
SAVE_4GPRS(3, r1) /* save r3 - r6 in stackframe */ SAVE_GPRS(3, 8, r1) /* save r3 - r8 in stackframe */
SAVE_2GPRS(7, r1) /* save r7, r8 in stackframe */
mflr r9 /* Get LR, later save to stack */ mflr r9 /* Get LR, later save to stack */
ld r2,PACATOC(r13) /* get kernel TOC into r2 */ ld r2,PACATOC(r13) /* get kernel TOC into r2 */
std r9,_LINK(r1) std r9,_LINK(r1)
...@@ -693,8 +692,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR) ...@@ -693,8 +692,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_CFAR)
mtlr r9 mtlr r9
ld r9,_CCR(r1) ld r9,_CCR(r1)
mtcr r9 mtcr r9
REST_8GPRS(2, r1) REST_GPRS(2, 13, r1)
REST_4GPRS(10, r1)
REST_GPR(0, r1) REST_GPR(0, r1)
/* restore original r1. */ /* restore original r1. */
ld r1,GPR1(r1) ld r1,GPR1(r1)
......
...@@ -115,8 +115,7 @@ _ASM_NOKPROBE_SYMBOL(\name\()_virt) ...@@ -115,8 +115,7 @@ _ASM_NOKPROBE_SYMBOL(\name\()_virt)
stw r10,8(r1) stw r10,8(r1)
li r10, \trapno li r10, \trapno
stw r10,_TRAP(r1) stw r10,_TRAP(r1)
SAVE_4GPRS(3, r1) SAVE_GPRS(3, 8, r1)
SAVE_2GPRS(7, r1)
SAVE_NVGPRS(r1) SAVE_NVGPRS(r1)
stw r2,GPR2(r1) stw r2,GPR2(r1)
stw r12,_NIP(r1) stw r12,_NIP(r1)
......
...@@ -87,8 +87,7 @@ END_BTB_FLUSH_SECTION ...@@ -87,8 +87,7 @@ END_BTB_FLUSH_SECTION
stw r10, 8(r1) stw r10, 8(r1)
li r10, \trapno li r10, \trapno
stw r10,_TRAP(r1) stw r10,_TRAP(r1)
SAVE_4GPRS(3, r1) SAVE_GPRS(3, 8, r1)
SAVE_2GPRS(7, r1)
SAVE_NVGPRS(r1) SAVE_NVGPRS(r1)
stw r2,GPR2(r1) stw r2,GPR2(r1)
stw r12,_NIP(r1) stw r12,_NIP(r1)
......
...@@ -162,10 +162,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) ...@@ -162,10 +162,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
* The value of AMR only matters while we're in the kernel. * The value of AMR only matters while we're in the kernel.
*/ */
mtcr r2 mtcr r2
ld r2,GPR2(r1) REST_GPRS(2, 3, r1)
ld r3,GPR3(r1) REST_GPR(13, r1)
ld r13,GPR13(r1) REST_GPR(1, r1)
ld r1,GPR1(r1)
RFSCV_TO_USER RFSCV_TO_USER
b . /* prevent speculative execution */ b . /* prevent speculative execution */
...@@ -183,9 +182,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) ...@@ -183,9 +182,8 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
mtctr r3 mtctr r3
mtlr r4 mtlr r4
mtspr SPRN_XER,r5 mtspr SPRN_XER,r5
REST_10GPRS(2, r1) REST_GPRS(2, 13, r1)
REST_2GPRS(12, r1) REST_GPR(1, r1)
ld r1,GPR1(r1)
RFI_TO_USER RFI_TO_USER
.Lsyscall_vectored_\name\()_rst_end: .Lsyscall_vectored_\name\()_rst_end:
...@@ -374,10 +372,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) ...@@ -374,10 +372,9 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
* The value of AMR only matters while we're in the kernel. * The value of AMR only matters while we're in the kernel.
*/ */
mtcr r2 mtcr r2
ld r2,GPR2(r1) REST_GPRS(2, 3, r1)
ld r3,GPR3(r1) REST_GPR(13, r1)
ld r13,GPR13(r1) REST_GPR(1, r1)
ld r1,GPR1(r1)
RFI_TO_USER RFI_TO_USER
b . /* prevent speculative execution */ b . /* prevent speculative execution */
...@@ -388,8 +385,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) ...@@ -388,8 +385,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR)
mtctr r3 mtctr r3
mtspr SPRN_XER,r4 mtspr SPRN_XER,r4
ld r0,GPR0(r1) ld r0,GPR0(r1)
REST_8GPRS(4, r1) REST_GPRS(4, 12, r1)
ld r12,GPR12(r1)
b .Lsyscall_restore_regs_cont b .Lsyscall_restore_regs_cont
.Lsyscall_rst_end: .Lsyscall_rst_end:
...@@ -518,17 +514,14 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) ...@@ -518,17 +514,14 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
ld r6,_XER(r1) ld r6,_XER(r1)
li r0,0 li r0,0
REST_4GPRS(7, r1) REST_GPRS(7, 13, r1)
REST_2GPRS(11, r1)
REST_GPR(13, r1)
mtcr r3 mtcr r3
mtlr r4 mtlr r4
mtctr r5 mtctr r5
mtspr SPRN_XER,r6 mtspr SPRN_XER,r6
REST_4GPRS(2, r1) REST_GPRS(2, 6, r1)
REST_GPR(6, r1)
REST_GPR(0, r1) REST_GPR(0, r1)
REST_GPR(1, r1) REST_GPR(1, r1)
.ifc \srr,srr .ifc \srr,srr
...@@ -625,8 +618,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) ...@@ -625,8 +618,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
ld r6,_CCR(r1) ld r6,_CCR(r1)
li r0,0 li r0,0
REST_4GPRS(7, r1) REST_GPRS(7, 12, r1)
REST_2GPRS(11, r1)
mtlr r3 mtlr r3
mtctr r4 mtctr r4
...@@ -638,7 +630,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS) ...@@ -638,7 +630,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
*/ */
std r0,STACK_FRAME_OVERHEAD-16(r1) std r0,STACK_FRAME_OVERHEAD-16(r1)
REST_4GPRS(2, r1) REST_GPRS(2, 5, r1)
bne- cr1,1f /* emulate stack store */ bne- cr1,1f /* emulate stack store */
mtcr r6 mtcr r6
......
...@@ -10,8 +10,8 @@ ...@@ -10,8 +10,8 @@
#include <asm/asm-offsets.h> #include <asm/asm-offsets.h>
#ifdef CONFIG_PPC64 #ifdef CONFIG_PPC64
#define SAVE_30GPRS(base) SAVE_10GPRS(2,base); SAVE_10GPRS(12,base); SAVE_10GPRS(22,base) #define SAVE_30GPRS(base) SAVE_GPRS(2, 31, base)
#define REST_30GPRS(base) REST_10GPRS(2,base); REST_10GPRS(12,base); REST_10GPRS(22,base) #define REST_30GPRS(base) REST_GPRS(2, 31, base)
#define TEMPLATE_FOR_IMM_LOAD_INSNS nop; nop; nop; nop; nop #define TEMPLATE_FOR_IMM_LOAD_INSNS nop; nop; nop; nop; nop
#else #else
#define SAVE_30GPRS(base) stmw r2, GPR2(base) #define SAVE_30GPRS(base) stmw r2, GPR2(base)
......
...@@ -226,11 +226,8 @@ _GLOBAL(tm_reclaim) ...@@ -226,11 +226,8 @@ _GLOBAL(tm_reclaim)
/* Sync the userland GPRs 2-12, 14-31 to thread->regs: */ /* Sync the userland GPRs 2-12, 14-31 to thread->regs: */
SAVE_GPR(0, r7) /* user r0 */ SAVE_GPR(0, r7) /* user r0 */
SAVE_GPR(2, r7) /* user r2 */ SAVE_GPRS(2, 6, r7) /* user r2-r6 */
SAVE_4GPRS(3, r7) /* user r3-r6 */ SAVE_GPRS(8, 10, r7) /* user r8-r10 */
SAVE_GPR(8, r7) /* user r8 */
SAVE_GPR(9, r7) /* user r9 */
SAVE_GPR(10, r7) /* user r10 */
ld r3, GPR1(r1) /* user r1 */ ld r3, GPR1(r1) /* user r1 */
ld r4, GPR7(r1) /* user r7 */ ld r4, GPR7(r1) /* user r7 */
ld r5, GPR11(r1) /* user r11 */ ld r5, GPR11(r1) /* user r11 */
...@@ -445,12 +442,8 @@ restore_gprs: ...@@ -445,12 +442,8 @@ restore_gprs:
ld r6, THREAD_TM_PPR(r3) ld r6, THREAD_TM_PPR(r3)
REST_GPR(0, r7) /* GPR0 */ REST_GPR(0, r7) /* GPR0 */
REST_2GPRS(2, r7) /* GPR2-3 */ REST_GPRS(2, 4, r7) /* GPR2-4 */
REST_GPR(4, r7) /* GPR4 */ REST_GPRS(8, 31, r7) /* GPR8-31 */
REST_4GPRS(8, r7) /* GPR8-11 */
REST_2GPRS(12, r7) /* GPR12-13 */
REST_NVGPRS(r7) /* GPR14-31 */
/* Load up PPR and DSCR here so we don't run with user values for long */ /* Load up PPR and DSCR here so we don't run with user values for long */
mtspr SPRN_DSCR, r5 mtspr SPRN_DSCR, r5
......
...@@ -41,15 +41,14 @@ _GLOBAL(ftrace_regs_caller) ...@@ -41,15 +41,14 @@ _GLOBAL(ftrace_regs_caller)
/* Save all gprs to pt_regs */ /* Save all gprs to pt_regs */
SAVE_GPR(0, r1) SAVE_GPR(0, r1)
SAVE_10GPRS(2, r1) SAVE_GPRS(2, 11, r1)
/* Ok to continue? */ /* Ok to continue? */
lbz r3, PACA_FTRACE_ENABLED(r13) lbz r3, PACA_FTRACE_ENABLED(r13)
cmpdi r3, 0 cmpdi r3, 0
beq ftrace_no_trace beq ftrace_no_trace
SAVE_10GPRS(12, r1) SAVE_GPRS(12, 31, r1)
SAVE_10GPRS(22, r1)
/* Save previous stack pointer (r1) */ /* Save previous stack pointer (r1) */
addi r8, r1, SWITCH_FRAME_SIZE addi r8, r1, SWITCH_FRAME_SIZE
...@@ -108,10 +107,8 @@ ftrace_regs_call: ...@@ -108,10 +107,8 @@ ftrace_regs_call:
#endif #endif
/* Restore gprs */ /* Restore gprs */
REST_GPR(0,r1) REST_GPR(0, r1)
REST_10GPRS(2,r1) REST_GPRS(2, 31, r1)
REST_10GPRS(12,r1)
REST_10GPRS(22,r1)
/* Restore possibly modified LR */ /* Restore possibly modified LR */
ld r0, _LINK(r1) ld r0, _LINK(r1)
...@@ -157,7 +154,7 @@ _GLOBAL(ftrace_caller) ...@@ -157,7 +154,7 @@ _GLOBAL(ftrace_caller)
stdu r1, -SWITCH_FRAME_SIZE(r1) stdu r1, -SWITCH_FRAME_SIZE(r1)
/* Save all gprs to pt_regs */ /* Save all gprs to pt_regs */
SAVE_8GPRS(3, r1) SAVE_GPRS(3, 10, r1)
lbz r3, PACA_FTRACE_ENABLED(r13) lbz r3, PACA_FTRACE_ENABLED(r13)
cmpdi r3, 0 cmpdi r3, 0
...@@ -194,7 +191,7 @@ ftrace_call: ...@@ -194,7 +191,7 @@ ftrace_call:
mtctr r3 mtctr r3
/* Restore gprs */ /* Restore gprs */
REST_8GPRS(3,r1) REST_GPRS(3, 10, r1)
/* Restore callee's TOC */ /* Restore callee's TOC */
ld r2, 24(r1) ld r2, 24(r1)
......
...@@ -2693,8 +2693,7 @@ kvmppc_bad_host_intr: ...@@ -2693,8 +2693,7 @@ kvmppc_bad_host_intr:
std r0, GPR0(r1) std r0, GPR0(r1)
std r9, GPR1(r1) std r9, GPR1(r1)
std r2, GPR2(r1) std r2, GPR2(r1)
SAVE_4GPRS(3, r1) SAVE_GPRS(3, 8, r1)
SAVE_2GPRS(7, r1)
srdi r0, r12, 32 srdi r0, r12, 32
clrldi r12, r12, 32 clrldi r12, r12, 32
std r0, _CCR(r1) std r0, _CCR(r1)
...@@ -2717,7 +2716,7 @@ kvmppc_bad_host_intr: ...@@ -2717,7 +2716,7 @@ kvmppc_bad_host_intr:
ld r9, HSTATE_SCRATCH2(r13) ld r9, HSTATE_SCRATCH2(r13)
ld r12, HSTATE_SCRATCH0(r13) ld r12, HSTATE_SCRATCH0(r13)
GET_SCRATCH0(r0) GET_SCRATCH0(r0)
SAVE_4GPRS(9, r1) SAVE_GPRS(9, 12, r1)
std r0, GPR13(r1) std r0, GPR13(r1)
SAVE_NVGPRS(r1) SAVE_NVGPRS(r1)
ld r5, HSTATE_CFAR(r13) ld r5, HSTATE_CFAR(r13)
......
...@@ -37,7 +37,7 @@ _GLOBAL(exec_instr) ...@@ -37,7 +37,7 @@ _GLOBAL(exec_instr)
* The stack pointer (GPR1) and the thread pointer (GPR13) are not * The stack pointer (GPR1) and the thread pointer (GPR13) are not
* saved as these should not be modified anyway. * saved as these should not be modified anyway.
*/ */
SAVE_2GPRS(2, r1) SAVE_GPRS(2, 3, r1)
SAVE_NVGPRS(r1) SAVE_NVGPRS(r1)
/* /*
...@@ -75,8 +75,7 @@ _GLOBAL(exec_instr) ...@@ -75,8 +75,7 @@ _GLOBAL(exec_instr)
/* Load GPRs from pt_regs */ /* Load GPRs from pt_regs */
REST_GPR(0, r31) REST_GPR(0, r31)
REST_10GPRS(2, r31) REST_GPRS(2, 12, r31)
REST_GPR(12, r31)
REST_NVGPRS(r31) REST_NVGPRS(r31)
/* Placeholder for the test instruction */ /* Placeholder for the test instruction */
...@@ -99,8 +98,7 @@ _GLOBAL(exec_instr) ...@@ -99,8 +98,7 @@ _GLOBAL(exec_instr)
subi r3, r3, GPR0 subi r3, r3, GPR0
SAVE_GPR(0, r3) SAVE_GPR(0, r3)
SAVE_GPR(2, r3) SAVE_GPR(2, r3)
SAVE_8GPRS(4, r3) SAVE_GPRS(4, 12, r3)
SAVE_GPR(12, r3)
SAVE_NVGPRS(r3) SAVE_NVGPRS(r3)
/* Save resulting LR to pt_regs */ /* Save resulting LR to pt_regs */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册