diff options
author | Rusty Lynch <rusty.lynch@intel.com> | 2005-06-23 03:09:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-23 12:45:21 -0400 |
commit | 7e1048b11c5afe79aac46a42e3ccec86b8365c6d (patch) | |
tree | 4f9caee0153e688f22d7e7b6fdc62e35be4fc3fe /kernel/kprobes.c | |
parent | 73649dab0fd524cb8545a8cb83c6eaf77b107105 (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 'kernel/kprobes.c')
-rw-r--r-- | kernel/kprobes.c | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 692fbf75ab49..e8e0ae8a6e14 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
@@ -261,7 +261,7 @@ static inline void free_rp_inst(struct kretprobe *rp) | |||
261 | static inline void add_aggr_kprobe(struct kprobe *ap, struct kprobe *p) | 261 | static inline void add_aggr_kprobe(struct kprobe *ap, struct kprobe *p) |
262 | { | 262 | { |
263 | ap->addr = p->addr; | 263 | ap->addr = p->addr; |
264 | ap->opcode = p->opcode; | 264 | memcpy(&ap->opcode, &p->opcode, sizeof(kprobe_opcode_t)); |
265 | memcpy(&ap->ainsn, &p->ainsn, sizeof(struct arch_specific_insn)); | 265 | memcpy(&ap->ainsn, &p->ainsn, sizeof(struct arch_specific_insn)); |
266 | 266 | ||
267 | ap->pre_handler = aggr_pre_handler; | 267 | ap->pre_handler = aggr_pre_handler; |
@@ -304,10 +304,8 @@ static int register_aggr_kprobe(struct kprobe *old_p, struct kprobe *p) | |||
304 | /* kprobe removal house-keeping routines */ | 304 | /* kprobe removal house-keeping routines */ |
305 | static inline void cleanup_kprobe(struct kprobe *p, unsigned long flags) | 305 | static inline void cleanup_kprobe(struct kprobe *p, unsigned long flags) |
306 | { | 306 | { |
307 | *p->addr = p->opcode; | 307 | arch_disarm_kprobe(p); |
308 | hlist_del(&p->hlist); | 308 | hlist_del(&p->hlist); |
309 | flush_icache_range((unsigned long) p->addr, | ||
310 | (unsigned long) p->addr + sizeof(kprobe_opcode_t)); | ||
311 | spin_unlock_irqrestore(&kprobe_lock, flags); | 309 | spin_unlock_irqrestore(&kprobe_lock, flags); |
312 | arch_remove_kprobe(p); | 310 | arch_remove_kprobe(p); |
313 | } | 311 | } |
@@ -344,10 +342,8 @@ int register_kprobe(struct kprobe *p) | |||
344 | hlist_add_head(&p->hlist, | 342 | hlist_add_head(&p->hlist, |
345 | &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); | 343 | &kprobe_table[hash_ptr(p->addr, KPROBE_HASH_BITS)]); |
346 | 344 | ||
347 | p->opcode = *p->addr; | 345 | arch_arm_kprobe(p); |
348 | *p->addr = BREAKPOINT_INSTRUCTION; | 346 | |
349 | flush_icache_range((unsigned long) p->addr, | ||
350 | (unsigned long) p->addr + sizeof(kprobe_opcode_t)); | ||
351 | out: | 347 | out: |
352 | spin_unlock_irqrestore(&kprobe_lock, flags); | 348 | spin_unlock_irqrestore(&kprobe_lock, flags); |
353 | rm_kprobe: | 349 | rm_kprobe: |