aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuzuki K. Poulose <suzuki@in.ibm.com>2012-12-03 10:08:37 -0500
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2013-06-20 02:55:09 -0400
commit35fd219a268cc82cef842518cd64ea6949629ba2 (patch)
tree2226a6d0fe4a0d36d679905c5680f5ca27db0bab
parent85f395c5b0a26b3a80f9e2d35333981a2a75c0ae (diff)
powerpc: Move the single step enable code to a generic path
This patch moves the single step enable code used by kprobe to a generic routine header so that, it can be re-used by other code, in this case, uprobes. No functional changes. Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com> Cc: Ananth N Mavinakaynahalli <ananth@in.ibm.com> Cc: Kumar Gala <galak@kernel.crashing.org> Cc: linuxppc-dev@ozlabs.org Acked-by: Ananth N Mavinakayanahalli <ananth@in.ibm.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--arch/powerpc/include/asm/probes.h25
-rw-r--r--arch/powerpc/kernel/kprobes.c20
2 files changed, 26 insertions, 19 deletions
diff --git a/arch/powerpc/include/asm/probes.h b/arch/powerpc/include/asm/probes.h
index 5f1e15b68704..3421637cfd7b 100644
--- a/arch/powerpc/include/asm/probes.h
+++ b/arch/powerpc/include/asm/probes.h
@@ -38,5 +38,30 @@ typedef u32 ppc_opcode_t;
38#define is_trap(instr) (IS_TW(instr) || IS_TWI(instr)) 38#define is_trap(instr) (IS_TW(instr) || IS_TWI(instr))
39#endif /* CONFIG_PPC64 */ 39#endif /* CONFIG_PPC64 */
40 40
41#ifdef CONFIG_PPC_ADV_DEBUG_REGS
42#define MSR_SINGLESTEP (MSR_DE)
43#else
44#define MSR_SINGLESTEP (MSR_SE)
45#endif
46
47/* Enable single stepping for the current task */
48static inline void enable_single_step(struct pt_regs *regs)
49{
50 regs->msr |= MSR_SINGLESTEP;
51#ifdef CONFIG_PPC_ADV_DEBUG_REGS
52 /*
53 * We turn off Critical Input Exception(CE) to ensure that the single
54 * step will be for the instruction we have the probe on; if we don't,
55 * it is possible we'd get the single step reported for CE.
56 */
57 regs->msr &= ~MSR_CE;
58 mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
59#ifdef CONFIG_PPC_47x
60 isync();
61#endif
62#endif
63}
64
65
41#endif /* __KERNEL__ */ 66#endif /* __KERNEL__ */
42#endif /* _ASM_POWERPC_PROBES_H */ 67#endif /* _ASM_POWERPC_PROBES_H */
diff --git a/arch/powerpc/kernel/kprobes.c b/arch/powerpc/kernel/kprobes.c
index 560f430da478..2156ea90eb54 100644
--- a/arch/powerpc/kernel/kprobes.c
+++ b/arch/powerpc/kernel/kprobes.c
@@ -36,12 +36,6 @@
36#include <asm/sstep.h> 36#include <asm/sstep.h>
37#include <asm/uaccess.h> 37#include <asm/uaccess.h>
38 38
39#ifdef CONFIG_PPC_ADV_DEBUG_REGS
40#define MSR_SINGLESTEP (MSR_DE)
41#else
42#define MSR_SINGLESTEP (MSR_SE)
43#endif
44
45DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL; 39DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
46DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk); 40DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
47 41
@@ -104,19 +98,7 @@ void __kprobes arch_remove_kprobe(struct kprobe *p)
104 98
105static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 99static void __kprobes prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
106{ 100{
107 regs->msr |= MSR_SINGLESTEP; 101 enable_single_step(regs);
108#ifdef CONFIG_PPC_ADV_DEBUG_REGS
109 /*
110 * We turn off Critical Input Exception(CE) to ensure that the single
111 * step will be for the instruction we have the probe on; if we don't,
112 * it is possible we'd get the single step reported for CE.
113 */
114 regs->msr &= ~MSR_CE;
115 mtspr(SPRN_DBCR0, mfspr(SPRN_DBCR0) | DBCR0_IC | DBCR0_IDM);
116#ifdef CONFIG_PPC_47x
117 isync();
118#endif
119#endif
120 102
121 /* 103 /*
122 * On powerpc we should single step on the original 104 * On powerpc we should single step on the original