]> git.baikalelectronics.ru Git - kernel.git/commitdiff
powerpc/kprobes: Fix handling of instruction emulation on probe re-entry
authorNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Mon, 15 May 2017 18:10:05 +0000 (23:40 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 16 May 2017 03:11:07 +0000 (13:11 +1000)
Commit 1a29be1be159d ("powerpc/kprobes: Emulate instructions on kprobe
handler re-entry") enabled emulating instructions on kprobe re-entry,
rather than single-stepping always. However, we didn't update the single
stepping code to only be run if the emulation fails. Also, we missed
re-enabling preemption if the instruction emulation was successful. Fix
those issues.

Fixes: 1a29be1be159d ("powerpc/kprobes: Emulate instructions on kprobe handler re-entry")
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/kprobes.c

index 160ae0fa7d0d15152011b111134784107287e7bb..fc4343514bed8b0f05a88e64caf0285c44ee8ea0 100644 (file)
@@ -305,16 +305,17 @@ int kprobe_handler(struct pt_regs *regs)
                        save_previous_kprobe(kcb);
                        set_current_kprobe(p, regs, kcb);
                        kprobes_inc_nmissed_count(p);
-                       prepare_singlestep(p, regs);
                        kcb->kprobe_status = KPROBE_REENTER;
                        if (p->ainsn.boostable >= 0) {
                                ret = try_to_emulate(p, regs);
 
                                if (ret > 0) {
                                        restore_previous_kprobe(kcb);
+                                       preempt_enable_no_resched();
                                        return 1;
                                }
                        }
+                       prepare_singlestep(p, regs);
                        return 1;
                } else {
                        if (*addr != BREAKPOINT_INSTRUCTION) {