aboutsummaryrefslogtreecommitdiffstats
path: root/arch/sparc64
diff options
context:
space:
mode:
authorRusty Lynch <rusty.lynch@intel.com>2005-06-23 03:09:25 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-06-23 12:45:21 -0400
commit7e1048b11c5afe79aac46a42e3ccec86b8365c6d (patch)
tree4f9caee0153e688f22d7e7b6fdc62e35be4fc3fe /arch/sparc64
parent73649dab0fd524cb8545a8cb83c6eaf77b107105 (diff)
[PATCH] Move kprobe [dis]arming into arch specific code
The architecture independent code of the current kprobes implementation is arming and disarming kprobes at registration time. The problem is that the code is assuming that arming and disarming is a just done by a simple write of some magic value to an address. This is problematic for ia64 where our instructions look more like structures, and we can not insert break points by just doing something like: *p->addr = BREAKPOINT_INSTRUCTION; The following patch to 2.6.12-rc4-mm2 adds two new architecture dependent functions: * void arch_arm_kprobe(struct kprobe *p) * void arch_disarm_kprobe(struct kprobe *p) and then adds the new functions for each of the architectures that already implement kprobes (spar64/ppc64/i386/x86_64). I thought arch_[dis]arm_kprobe was the most descriptive of what was really happening, but each of the architectures already had a disarm_kprobe() function that was really a "disarm and do some other clean-up items as needed when you stumble across a recursive kprobe." So... I took the liberty of changing the code that was calling disarm_kprobe() to call arch_disarm_kprobe(), and then do the cleanup in the block of code dealing with the recursive kprobe case. So far this patch as been tested on i386, x86_64, and ppc64, but still needs to be tested in sparc64. Signed-off-by: Rusty Lynch <rusty.lynch@intel.com> Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/sparc64')
-rw-r--r--arch/sparc64/kernel/kprobes.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/arch/sparc64/kernel/kprobes.c b/arch/sparc64/kernel/kprobes.c
index 7066d7ba667a..d67195ba3fa2 100644
--- a/arch/sparc64/kernel/kprobes.c
+++ b/arch/sparc64/kernel/kprobes.c
@@ -6,7 +6,6 @@
6#include <linux/config.h> 6#include <linux/config.h>
7#include <linux/kernel.h> 7#include <linux/kernel.h>
8#include <linux/kprobes.h> 8#include <linux/kprobes.h>
9
10#include <asm/kdebug.h> 9#include <asm/kdebug.h>
11#include <asm/signal.h> 10#include <asm/signal.h>
12 11
@@ -47,6 +46,19 @@ void arch_copy_kprobe(struct kprobe *p)
47{ 46{
48 p->ainsn.insn[0] = *p->addr; 47 p->ainsn.insn[0] = *p->addr;
49 p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2; 48 p->ainsn.insn[1] = BREAKPOINT_INSTRUCTION_2;
49 p->opcode = *p->addr;
50}
51
52void arch_arm_kprobe(struct kprobe *p)
53{
54 *p->addr = BREAKPOINT_INSTRUCTION;
55 flushi(p->addr);
56}
57
58void arch_disarm_kprobe(struct kprobe *p)
59{
60 *p->addr = p->opcode;
61 flushi(p->addr);
50} 62}
51 63
52void arch_remove_kprobe(struct kprobe *p) 64void arch_remove_kprobe(struct kprobe *p)
@@ -78,17 +90,6 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
78 } 90 }
79} 91}
80 92
81static inline void disarm_kprobe(struct kprobe *p, struct pt_regs *regs)
82{
83 *p->addr = p->opcode;
84 flushi(p->addr);
85
86 regs->tpc = (unsigned long) p->addr;
87 regs->tnpc = current_kprobe_orig_tnpc;
88 regs->tstate = ((regs->tstate & ~TSTATE_PIL) |
89 current_kprobe_orig_tstate_pil);
90}
91
92static int kprobe_handler(struct pt_regs *regs) 93static int kprobe_handler(struct pt_regs *regs)
93{ 94{
94 struct kprobe *p; 95 struct kprobe *p;
@@ -109,7 +110,11 @@ static int kprobe_handler(struct pt_regs *regs)
109 unlock_kprobes(); 110 unlock_kprobes();
110 goto no_kprobe; 111 goto no_kprobe;
111 } 112 }
112 disarm_kprobe(p, regs); 113 arch_disarm_kprobe(p);
114 regs->tpc = (unsigned long) p->addr;
115 regs->tnpc = current_kprobe_orig_tnpc;
116 regs->tstate = ((regs->tstate & ~TSTATE_PIL) |
117 current_kprobe_orig_tstate_pil);
113 ret = 1; 118 ret = 1;
114 } else { 119 } else {
115 p = current_kprobe; 120 p = current_kprobe;