Skip to content

Commit a616c44

Browse files
chleroympe
authored andcommitted
powerpc/entry32: Blacklist exception entry points for kprobe.
kprobe does not handle events happening in real mode. As exception entry points are running with MMU disabled, blacklist them. The handling of TLF_NAPPING and TLF_SLEEPING is moved before the CONFIG_TRACE_IRQFLAGS which contains 'reenable_mmu' because from there kprobe will be possible as the kernel will run with MMU enabled. Signed-off-by: Christophe Leroy <[email protected]> Acked-by: Naveen N. Rao <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/f61ac599855e674ebb592464d0ea32a3ba9c6644.1585670437.git.christophe.leroy@c-s.fr
1 parent 5f32e83 commit a616c44

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

arch/powerpc/kernel/entry_32.S

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ mcheck_transfer_to_handler:
5050
mfspr r0,SPRN_DSRR1
5151
stw r0,_DSRR1(r11)
5252
/* fall through */
53+
_ASM_NOKPROBE_SYMBOL(mcheck_transfer_to_handler)
5354

5455
.globl debug_transfer_to_handler
5556
debug_transfer_to_handler:
@@ -58,6 +59,7 @@ debug_transfer_to_handler:
5859
mfspr r0,SPRN_CSRR1
5960
stw r0,_CSRR1(r11)
6061
/* fall through */
62+
_ASM_NOKPROBE_SYMBOL(debug_transfer_to_handler)
6163

6264
.globl crit_transfer_to_handler
6365
crit_transfer_to_handler:
@@ -93,6 +95,7 @@ crit_transfer_to_handler:
9395
rlwinm r0,r1,0,0,(31 - THREAD_SHIFT)
9496
stw r0,KSP_LIMIT(r8)
9597
/* fall through */
98+
_ASM_NOKPROBE_SYMBOL(crit_transfer_to_handler)
9699
#endif
97100

98101
#ifdef CONFIG_40x
@@ -114,6 +117,7 @@ crit_transfer_to_handler:
114117
rlwinm r0,r1,0,0,(31 - THREAD_SHIFT)
115118
stw r0,KSP_LIMIT(r8)
116119
/* fall through */
120+
_ASM_NOKPROBE_SYMBOL(crit_transfer_to_handler)
117121
#endif
118122

119123
/*
@@ -126,6 +130,7 @@ crit_transfer_to_handler:
126130
.globl transfer_to_handler_full
127131
transfer_to_handler_full:
128132
SAVE_NVGPRS(r11)
133+
_ASM_NOKPROBE_SYMBOL(transfer_to_handler_full)
129134
/* fall through */
130135

131136
.globl transfer_to_handler
@@ -226,6 +231,23 @@ transfer_to_handler_cont:
226231
SYNC
227232
RFI /* jump to handler, enable MMU */
228233

234+
#if defined (CONFIG_PPC_BOOK3S_32) || defined(CONFIG_E500)
235+
4: rlwinm r12,r12,0,~_TLF_NAPPING
236+
stw r12,TI_LOCAL_FLAGS(r2)
237+
b power_save_ppc32_restore
238+
239+
7: rlwinm r12,r12,0,~_TLF_SLEEPING
240+
stw r12,TI_LOCAL_FLAGS(r2)
241+
lwz r9,_MSR(r11) /* if sleeping, clear MSR.EE */
242+
rlwinm r9,r9,0,~MSR_EE
243+
lwz r12,_LINK(r11) /* and return to address in LR */
244+
kuap_restore r11, r2, r3, r4, r5
245+
lwz r2, GPR2(r11)
246+
b fast_exception_return
247+
#endif
248+
_ASM_NOKPROBE_SYMBOL(transfer_to_handler)
249+
_ASM_NOKPROBE_SYMBOL(transfer_to_handler_cont)
250+
229251
#ifdef CONFIG_TRACE_IRQFLAGS
230252
1: /* MSR is changing, re-enable MMU so we can notify lockdep. We need to
231253
* keep interrupts disabled at this point otherwise we might risk
@@ -271,21 +293,6 @@ reenable_mmu:
271293
bctr /* jump to handler */
272294
#endif /* CONFIG_TRACE_IRQFLAGS */
273295

274-
#if defined (CONFIG_PPC_BOOK3S_32) || defined(CONFIG_E500)
275-
4: rlwinm r12,r12,0,~_TLF_NAPPING
276-
stw r12,TI_LOCAL_FLAGS(r2)
277-
b power_save_ppc32_restore
278-
279-
7: rlwinm r12,r12,0,~_TLF_SLEEPING
280-
stw r12,TI_LOCAL_FLAGS(r2)
281-
lwz r9,_MSR(r11) /* if sleeping, clear MSR.EE */
282-
rlwinm r9,r9,0,~MSR_EE
283-
lwz r12,_LINK(r11) /* and return to address in LR */
284-
kuap_restore r11, r2, r3, r4, r5
285-
lwz r2, GPR2(r11)
286-
b fast_exception_return
287-
#endif
288-
289296
#ifndef CONFIG_VMAP_STACK
290297
/*
291298
* On kernel stack overflow, load up an initial stack pointer

0 commit comments

Comments
 (0)