Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <galak@kernel.crashing.org>

+10 -1
+9
arch/powerpc/kernel/kprobes.c
··· 95 95 96 96 static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 97 97 { 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; 98 103 regs->msr |= MSR_SE; 99 104 100 105 /* ··· 379 374 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk(); 380 375 381 376 if (!cur) 377 + return 0; 378 + 379 + /* make sure we got here for instruction we have a kprobe on */ 380 + if (((unsigned long)cur->ainsn.insn + 4) != regs->nip) 382 381 return 0; 383 382 384 383 if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
+1 -1
arch/powerpc/kernel/misc_32.S
··· 489 489 * 490 490 * flush_icache_range(unsigned long start, unsigned long stop) 491 491 */ 492 - _GLOBAL(__flush_icache_range) 492 + _KPROBE(__flush_icache_range) 493 493 BEGIN_FTR_SECTION 494 494 blr /* for 601, do nothing */ 495 495 END_FTR_SECTION_IFSET(CPU_FTR_COHERENT_ICACHE)