From: Ananth N Mavinakayanahalli Date: Fri, 28 Apr 2006 12:08:42 +0000 (+0530) Subject: [PATCH] powerpc/kprobes: fix singlestep out-of-line X-Git-Tag: Ubuntu-5.2.0-15.16~51125^2~4 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=0ccde0a290b44b8296b82a7683b4c299eb51ba6b;p=mirror_ubuntu-eoan-kernel.git [PATCH] powerpc/kprobes: fix singlestep out-of-line We currently single-step inline if the instruction on which a kprobe is inserted is a trap variant. - variants (such as tdnei, used by BUG()) typically evaluate a condition and cause a trap only if the condition is satisfied. - kprobes uses the unconditional "trap" (0x7fe00008) and single-stepping again on this instruction, resulting in another trap without evaluating the condition is obviously incorrect. Signed-off-by: Ananth N Mavinakayanahalli Signed-off-by: Paul Mackerras --- diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c index 856ef1a832b9..f78866367b70 100644 --- a/arch/powerpc/kernel/kprobes.c +++ b/arch/powerpc/kernel/kprobes.c @@ -90,15 +90,15 @@ void __kprobes arch_remove_kprobe(struct kprobe *p) static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs) { - kprobe_opcode_t insn = *p->ainsn.insn; - regs->msr |= MSR_SE; - /* single step inline if it is a trap variant */ - if (is_trap(insn)) - regs->nip = (unsigned long)p->addr; - else - regs->nip = (unsigned long)p->ainsn.insn; + /* + * On powerpc we should single step on the original + * instruction even if the probed insn is a trap + * variant as values in regs could play a part in + * if the trap is taken or not + */ + regs->nip = (unsigned long)p->ainsn.insn; } static void __kprobes save_previous_kprobe(struct kprobe_ctlblk *kcb)