powerpc/kprobes: Some minor fixes
[firefly-linux-kernel-4.4.55.git] / arch / powerpc / kernel / kprobes.c
index 23545a2f51f34d40c02f44840eb607985c5ddc4c..74693d91731ff441de8c4db172608c1de65b635e 100644 (file)
@@ -95,6 +95,11 @@ void __kprobes arch_remove_kprobe(struct kprobe *p)
 
 static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
 {
+       /* We turn off async exceptions to ensure that the single step will
+        * be for the instruction we have the kprobe on, if we dont its
+        * possible we'd get the single step reported for an exception handler
+        * like Decrementer or External Interrupt */
+       regs->msr &= ~MSR_EE;
        regs->msr |= MSR_SE;
 
        /*
@@ -376,6 +381,10 @@ static int __kprobes post_kprobe_handler(struct pt_regs *regs)
        if (!cur)
                return 0;
 
+       /* make sure we got here for instruction we have a kprobe on */
+       if (((unsigned long)cur->ainsn.insn + 4) != regs->nip)
+               return 0;
+
        if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
                kcb->kprobe_status = KPROBE_HIT_SSDONE;
                cur->post_handler(cur, regs, 0);