Commit 4228b2c3 authored by Nicholas Piggin's avatar Nicholas Piggin Committed by Michael Ellerman

powerpc/64e/interrupt: always save nvgprs on interrupt

In order to use the C interrupt return, nvgprs must always be saved.
Signed-off-by: default avatarNicholas Piggin <npiggin@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20210316104206.407354-3-npiggin@gmail.com
parent 5a5a893c
...@@ -186,18 +186,11 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) ...@@ -186,18 +186,11 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)
((struct pt_regs *)((unsigned long)task_stack_page(current) + THREAD_SIZE) - 1) ((struct pt_regs *)((unsigned long)task_stack_page(current) + THREAD_SIZE) - 1)
#ifdef __powerpc64__ #ifdef __powerpc64__
#ifdef CONFIG_PPC_BOOK3S
#define TRAP_FLAGS_MASK 0x10 #define TRAP_FLAGS_MASK 0x10
#define TRAP(regs) ((regs)->trap & ~TRAP_FLAGS_MASK) #define TRAP(regs) ((regs)->trap & ~TRAP_FLAGS_MASK)
#define FULL_REGS(regs) true #define FULL_REGS(regs) true
#define SET_FULL_REGS(regs) do { } while (0) #define SET_FULL_REGS(regs) do { } while (0)
#else #define CHECK_FULL_REGS(regs) do { } while (0)
#define TRAP_FLAGS_MASK 0x11
#define TRAP(regs) ((regs)->trap & ~TRAP_FLAGS_MASK)
#define FULL_REGS(regs) (((regs)->trap & 1) == 0)
#define SET_FULL_REGS(regs) ((regs)->trap &= ~1)
#endif
#define CHECK_FULL_REGS(regs) BUG_ON(!FULL_REGS(regs))
#define NV_REG_POISON 0xdeadbeefdeadbeefUL #define NV_REG_POISON 0xdeadbeefdeadbeefUL
#else #else
/* /*
......
...@@ -417,19 +417,6 @@ _GLOBAL(ret_from_kernel_thread) ...@@ -417,19 +417,6 @@ _GLOBAL(ret_from_kernel_thread)
li r3,0 li r3,0
b .Lsyscall_exit b .Lsyscall_exit
#ifdef CONFIG_PPC_BOOK3E
/* Save non-volatile GPRs, if not already saved. */
_GLOBAL(save_nvgprs)
ld r11,_TRAP(r1)
andi. r0,r11,1
beqlr-
SAVE_NVGPRS(r1)
clrrdi r0,r11,1
std r0,_TRAP(r1)
blr
_ASM_NOKPROBE_SYMBOL(save_nvgprs);
#endif
#ifdef CONFIG_PPC_BOOK3S_64 #ifdef CONFIG_PPC_BOOK3S_64
#define FLUSH_COUNT_CACHE \ #define FLUSH_COUNT_CACHE \
......
...@@ -417,14 +417,15 @@ exc_##n##_common: \ ...@@ -417,14 +417,15 @@ exc_##n##_common: \
std r6,_LINK(r1); \ std r6,_LINK(r1); \
std r7,_CTR(r1); \ std r7,_CTR(r1); \
std r8,_XER(r1); \ std r8,_XER(r1); \
li r3,(n)+1; /* indicate partial regs in trap */ \ li r3,(n); /* regs.trap vector */ \
std r9,0(r1); /* store stack frame back link */ \ std r9,0(r1); /* store stack frame back link */ \
std r10,_CCR(r1); /* store orig CR in stackframe */ \ std r10,_CCR(r1); /* store orig CR in stackframe */ \
std r9,GPR1(r1); /* store stack frame back link */ \ std r9,GPR1(r1); /* store stack frame back link */ \
std r11,SOFTE(r1); /* and save it to stackframe */ \ std r11,SOFTE(r1); /* and save it to stackframe */ \
std r12,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ \ std r12,STACK_FRAME_OVERHEAD-16(r1); /* mark the frame */ \
std r3,_TRAP(r1); /* set trap number */ \ std r3,_TRAP(r1); /* set trap number */ \
std r0,RESULT(r1); /* clear regs->result */ std r0,RESULT(r1); /* clear regs->result */ \
SAVE_NVGPRS(r1);
#define EXCEPTION_COMMON(n) \ #define EXCEPTION_COMMON(n) \
EXCEPTION_COMMON_LVL(n, SPRN_SPRG_GEN_SCRATCH, PACA_EXGEN) EXCEPTION_COMMON_LVL(n, SPRN_SPRG_GEN_SCRATCH, PACA_EXGEN)
...@@ -561,7 +562,6 @@ __end_interrupts: ...@@ -561,7 +562,6 @@ __end_interrupts:
CRIT_EXCEPTION_PROLOG(0x100, BOOKE_INTERRUPT_CRITICAL, CRIT_EXCEPTION_PROLOG(0x100, BOOKE_INTERRUPT_CRITICAL,
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON_CRIT(0x100) EXCEPTION_COMMON_CRIT(0x100)
bl save_nvgprs
bl special_reg_save bl special_reg_save
CHECK_NAPPING(); CHECK_NAPPING();
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
...@@ -573,7 +573,6 @@ __end_interrupts: ...@@ -573,7 +573,6 @@ __end_interrupts:
MC_EXCEPTION_PROLOG(0x000, BOOKE_INTERRUPT_MACHINE_CHECK, MC_EXCEPTION_PROLOG(0x000, BOOKE_INTERRUPT_MACHINE_CHECK,
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON_MC(0x000) EXCEPTION_COMMON_MC(0x000)
bl save_nvgprs
bl special_reg_save bl special_reg_save
CHECK_NAPPING(); CHECK_NAPPING();
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
...@@ -623,7 +622,6 @@ __end_interrupts: ...@@ -623,7 +622,6 @@ __end_interrupts:
std r14,_DSISR(r1) std r14,_DSISR(r1)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
ld r14,PACA_EXGEN+EX_R14(r13) ld r14,PACA_EXGEN+EX_R14(r13)
bl save_nvgprs
bl program_check_exception bl program_check_exception
b ret_from_except b ret_from_except
...@@ -639,7 +637,6 @@ __end_interrupts: ...@@ -639,7 +637,6 @@ __end_interrupts:
bl load_up_fpu bl load_up_fpu
b fast_exception_return b fast_exception_return
1: INTS_DISABLE 1: INTS_DISABLE
bl save_nvgprs
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
bl kernel_fp_unavailable_exception bl kernel_fp_unavailable_exception
b ret_from_except b ret_from_except
...@@ -661,7 +658,6 @@ BEGIN_FTR_SECTION ...@@ -661,7 +658,6 @@ BEGIN_FTR_SECTION
END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
#endif #endif
INTS_DISABLE INTS_DISABLE
bl save_nvgprs
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
bl altivec_unavailable_exception bl altivec_unavailable_exception
b ret_from_except b ret_from_except
...@@ -673,7 +669,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) ...@@ -673,7 +669,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON(0x220) EXCEPTION_COMMON(0x220)
INTS_DISABLE INTS_DISABLE
bl save_nvgprs
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
#ifdef CONFIG_ALTIVEC #ifdef CONFIG_ALTIVEC
BEGIN_FTR_SECTION BEGIN_FTR_SECTION
...@@ -698,7 +693,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) ...@@ -698,7 +693,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
CRIT_EXCEPTION_PROLOG(0x9f0, BOOKE_INTERRUPT_WATCHDOG, CRIT_EXCEPTION_PROLOG(0x9f0, BOOKE_INTERRUPT_WATCHDOG,
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON_CRIT(0x9f0) EXCEPTION_COMMON_CRIT(0x9f0)
bl save_nvgprs
bl special_reg_save bl special_reg_save
CHECK_NAPPING(); CHECK_NAPPING();
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
...@@ -723,7 +717,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) ...@@ -723,7 +717,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON(0xf20) EXCEPTION_COMMON(0xf20)
INTS_DISABLE INTS_DISABLE
bl save_nvgprs
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
bl unknown_exception bl unknown_exception
b ret_from_except b ret_from_except
...@@ -792,7 +785,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC) ...@@ -792,7 +785,6 @@ END_FTR_SECTION_IFSET(CPU_FTR_ALTIVEC)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
ld r14,PACA_EXCRIT+EX_R14(r13) ld r14,PACA_EXCRIT+EX_R14(r13)
ld r15,PACA_EXCRIT+EX_R15(r13) ld r15,PACA_EXCRIT+EX_R15(r13)
bl save_nvgprs
bl DebugException bl DebugException
b ret_from_except b ret_from_except
...@@ -864,7 +856,6 @@ kernel_dbg_exc: ...@@ -864,7 +856,6 @@ kernel_dbg_exc:
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
ld r14,PACA_EXDBG+EX_R14(r13) ld r14,PACA_EXDBG+EX_R14(r13)
ld r15,PACA_EXDBG+EX_R15(r13) ld r15,PACA_EXDBG+EX_R15(r13)
bl save_nvgprs
bl DebugException bl DebugException
b ret_from_except b ret_from_except
...@@ -887,7 +878,6 @@ kernel_dbg_exc: ...@@ -887,7 +878,6 @@ kernel_dbg_exc:
CRIT_EXCEPTION_PROLOG(0x2a0, BOOKE_INTERRUPT_DOORBELL_CRITICAL, CRIT_EXCEPTION_PROLOG(0x2a0, BOOKE_INTERRUPT_DOORBELL_CRITICAL,
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON_CRIT(0x2a0) EXCEPTION_COMMON_CRIT(0x2a0)
bl save_nvgprs
bl special_reg_save bl special_reg_save
CHECK_NAPPING(); CHECK_NAPPING();
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
...@@ -903,7 +893,6 @@ kernel_dbg_exc: ...@@ -903,7 +893,6 @@ kernel_dbg_exc:
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON(0x2c0) EXCEPTION_COMMON(0x2c0)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
bl save_nvgprs
INTS_RESTORE_HARD INTS_RESTORE_HARD
bl unknown_exception bl unknown_exception
b ret_from_except b ret_from_except
...@@ -913,7 +902,6 @@ kernel_dbg_exc: ...@@ -913,7 +902,6 @@ kernel_dbg_exc:
CRIT_EXCEPTION_PROLOG(0x2e0, BOOKE_INTERRUPT_GUEST_DBELL_CRIT, CRIT_EXCEPTION_PROLOG(0x2e0, BOOKE_INTERRUPT_GUEST_DBELL_CRIT,
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON_CRIT(0x2e0) EXCEPTION_COMMON_CRIT(0x2e0)
bl save_nvgprs
bl special_reg_save bl special_reg_save
CHECK_NAPPING(); CHECK_NAPPING();
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
...@@ -926,7 +914,6 @@ kernel_dbg_exc: ...@@ -926,7 +914,6 @@ kernel_dbg_exc:
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON(0x310) EXCEPTION_COMMON(0x310)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
bl save_nvgprs
INTS_RESTORE_HARD INTS_RESTORE_HARD
bl unknown_exception bl unknown_exception
b ret_from_except b ret_from_except
...@@ -937,7 +924,6 @@ kernel_dbg_exc: ...@@ -937,7 +924,6 @@ kernel_dbg_exc:
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON(0x320) EXCEPTION_COMMON(0x320)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
bl save_nvgprs
INTS_RESTORE_HARD INTS_RESTORE_HARD
bl unknown_exception bl unknown_exception
b ret_from_except b ret_from_except
...@@ -948,7 +934,6 @@ kernel_dbg_exc: ...@@ -948,7 +934,6 @@ kernel_dbg_exc:
PROLOG_ADDITION_NONE) PROLOG_ADDITION_NONE)
EXCEPTION_COMMON(0x340) EXCEPTION_COMMON(0x340)
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
bl save_nvgprs
INTS_RESTORE_HARD INTS_RESTORE_HARD
bl unknown_exception bl unknown_exception
b ret_from_except b ret_from_except
...@@ -1014,7 +999,6 @@ storage_fault_common: ...@@ -1014,7 +999,6 @@ storage_fault_common:
cmpdi r3,0 cmpdi r3,0
bne- 1f bne- 1f
b ret_from_except_lite b ret_from_except_lite
1: bl save_nvgprs
mr r4,r3 mr r4,r3
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
bl __bad_page_fault bl __bad_page_fault
...@@ -1030,16 +1014,12 @@ alignment_more: ...@@ -1030,16 +1014,12 @@ alignment_more:
addi r3,r1,STACK_FRAME_OVERHEAD addi r3,r1,STACK_FRAME_OVERHEAD
ld r14,PACA_EXGEN+EX_R14(r13) ld r14,PACA_EXGEN+EX_R14(r13)
ld r15,PACA_EXGEN+EX_R15(r13) ld r15,PACA_EXGEN+EX_R15(r13)
bl save_nvgprs
INTS_RESTORE_HARD INTS_RESTORE_HARD
bl alignment_exception bl alignment_exception
b ret_from_except b ret_from_except
.align 7 .align 7
_GLOBAL(ret_from_except) _GLOBAL(ret_from_except)
ld r11,_TRAP(r1)
andi. r0,r11,1
bne ret_from_except_lite
REST_NVGPRS(r1) REST_NVGPRS(r1)
_GLOBAL(ret_from_except_lite) _GLOBAL(ret_from_except_lite)
...@@ -1080,7 +1060,6 @@ _GLOBAL(ret_from_except_lite) ...@@ -1080,7 +1060,6 @@ _GLOBAL(ret_from_except_lite)
SCHEDULE_USER SCHEDULE_USER
b ret_from_except_lite b ret_from_except_lite
2: 2:
bl save_nvgprs
/* /*
* Use a non volatile GPR to save and restore our thread_info flags * Use a non volatile GPR to save and restore our thread_info flags
* across the call to restore_interrupts. * across the call to restore_interrupts.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment