Skip to content

Commit b76e59d

Browse files
committed
powerpc/kprobes: Some minor fixes
* Mark __flush_icache_range as a function that can't be probed since its used by the kprobe code. * Fix an issue with single stepping and async exceptions. We need to ensure that we dont get an async exception (external, decrementer, etc) while we are attempting to single step the probe point. Added a check to ensure we only handle a single step if its really intended for the instruction in question. Signed-off-by: Kumar Gala <[email protected]>
1 parent d14b3dd commit b76e59d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

arch/powerpc/kernel/kprobes.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ void __kprobes arch_remove_kprobe(struct kprobe *p)
9595

9696
static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
9797
{
98+
/* We turn off async exceptions to ensure that the single step will
99+
* be for the instruction we have the kprobe on, if we dont its
100+
* possible we'd get the single step reported for an exception handler
101+
* like Decrementer or External Interrupt */
102+
regs->msr &= ~MSR_EE;
98103
regs->msr |= MSR_SE;
99104

100105
/*
@@ -376,6 +381,10 @@ static int __kprobes post_kprobe_handler(struct pt_regs *regs)
376381
if (!cur)
377382
return 0;
378383

384+
/* make sure we got here for instruction we have a kprobe on */
385+
if (((unsigned long)cur->ainsn.insn + 4) != regs->nip)
386+
return 0;
387+
379388
if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
380389
kcb->kprobe_status = KPROBE_HIT_SSDONE;
381390
cur->post_handler(cur, regs, 0);

arch/powerpc/kernel/misc_32.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_UNIFIED_ID_CACHE)
489489
*
490490
* flush_icache_range(unsigned long start, unsigned long stop)
491491
*/
492-
_GLOBAL(__flush_icache_range)
492+
_KPROBE(__flush_icache_range)
493493
BEGIN_FTR_SECTION
494494
blr /* for 601, do nothing */
495495
END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)

0 commit comments

Comments
 (0)