Skip to content

Commit 2997876

Browse files
chleroymaddy-kerneldev
authored andcommitted
powerpc/32: Restore clearing of MSR[RI] at interrupt/syscall exit
Commit 1379974 ("powerpc/64: use interrupt restart table to speed up return from interrupt") removed the inconditional clearing of MSR[RI] when returning from interrupt into kernel. But powerpc/32 doesn't implement interrupt restart table hence still need MSR[RI] to be cleared. It could be added back in interrupt_exit_kernel_prepare() but it is easier and better to add it back in entry_32.S for following reasons: - Writing to MSR must be followed by a synchronising instruction - The smaller the non recoverable section is the better it is So add a macro called clr_ri and use it in the three places that play up with SRR0/SRR1. Use it just before another mtspr for synchronisation to avoid having to add an isync. Now that's done in entry_32.S, exit_must_hard_disable() can return false for non book3s/64, taking into account that BOOKE doesn't have MSR_RI. Also add back blacklisting syscall_exit_finish for kprobe. This was initially added by commit 7cdf440 ("powerpc/entry32: Blacklist syscall exit points for kprobe.") then lost with commit 6f76a01 ("powerpc/syscall: implement system call entry/exit logic in C for PPC32"). Fixes: 6f76a01 ("powerpc/syscall: implement system call entry/exit logic in C for PPC32") Fixes: 1379974 ("powerpc/64: use interrupt restart table to speed up return from interrupt") Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/66d0ab070563ad460ed481328ab0887c27f21a2c.1757593807.git.christophe.leroy@csgroup.eu
1 parent 98fa236 commit 2997876

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

arch/powerpc/kernel/entry_32.S

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ SYM_FUNC_END(__kuep_unlock)
101101
.endm
102102
#endif
103103

104+
.macro clr_ri trash
105+
#ifndef CONFIG_BOOKE
106+
#ifdef CONFIG_PPC_8xx
107+
mtspr SPRN_NRI, \trash
108+
#else
109+
li \trash, MSR_KERNEL & ~MSR_RI
110+
mtmsr \trash
111+
#endif
112+
#endif
113+
.endm
114+
104115
.globl transfer_to_syscall
105116
transfer_to_syscall:
106117
stw r3, ORIG_GPR3(r1)
@@ -149,6 +160,7 @@ ret_from_syscall:
149160
cmpwi r3,0
150161
REST_GPR(3, r1)
151162
syscall_exit_finish:
163+
clr_ri r4
152164
mtspr SPRN_SRR0,r7
153165
mtspr SPRN_SRR1,r8
154166

@@ -168,6 +180,7 @@ syscall_exit_finish:
168180
REST_GPR(0, r1)
169181
REST_GPRS(3, 12, r1)
170182
b 1b
183+
_ASM_NOKPROBE_SYMBOL(syscall_exit_finish)
171184

172185
#ifdef CONFIG_44x
173186
.L44x_icache_flush:
@@ -224,10 +237,11 @@ fast_exception_return:
224237
/* Clear the exception marker on the stack to avoid confusing stacktrace */
225238
li r10, 0
226239
stw r10, 8(r11)
227-
REST_GPR(10, r11)
240+
clr_ri r10
228241
mtspr SPRN_SRR1,r9
229242
mtspr SPRN_SRR0,r12
230243
REST_GPR(9, r11)
244+
REST_GPR(10, r11)
231245
REST_GPR(12, r11)
232246
REST_GPR(11, r11)
233247
rfi
@@ -256,6 +270,7 @@ interrupt_return:
256270
.Lfast_user_interrupt_return:
257271
lwz r11,_NIP(r1)
258272
lwz r12,_MSR(r1)
273+
clr_ri r4
259274
mtspr SPRN_SRR0,r11
260275
mtspr SPRN_SRR1,r12
261276

@@ -299,6 +314,7 @@ ALT_FTR_SECTION_END_IFCLR(CPU_FTR_STCX_CHECKS_ADDRESS)
299314
cmpwi cr1,r3,0
300315
lwz r11,_NIP(r1)
301316
lwz r12,_MSR(r1)
317+
clr_ri r4
302318
mtspr SPRN_SRR0,r11
303319
mtspr SPRN_SRR1,r12
304320

arch/powerpc/kernel/interrupt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ static inline bool exit_must_hard_disable(void)
3838
#else
3939
static inline bool exit_must_hard_disable(void)
4040
{
41-
return true;
41+
return false;
4242
}
4343
#endif
4444

0 commit comments

Comments
 (0)