diff options
author | Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com> | 2005-06-23 03:09:28 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-06-23 12:45:22 -0400 |
commit | b2761dc262b428475890fffd979687051beb12ba (patch) | |
tree | 088fcb3fb1a5e3fc73614dcbfcde9aa2ff7bc1ce | |
parent | fd7b231ff98578308d8f5fb76a25a369ce1074ae (diff) |
[PATCH] Kprobes/IA64: architecture specific JProbes support
This patch adds IA64 architecture specific JProbes support on top of Kprobes
Signed-off-by: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Signed-off-by: Rusty Lynch <Rusty.lynch@intel.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | arch/ia64/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/ia64/kernel/jprobes.S | 61 | ||||
-rw-r--r-- | arch/ia64/kernel/kprobes.c | 28 | ||||
-rw-r--r-- | include/asm-ia64/kprobes.h | 5 |
4 files changed, 89 insertions, 7 deletions
diff --git a/arch/ia64/kernel/Makefile b/arch/ia64/kernel/Makefile index 5290fa4c3371..b2e2f6509eb0 100644 --- a/arch/ia64/kernel/Makefile +++ b/arch/ia64/kernel/Makefile | |||
@@ -20,7 +20,7 @@ obj-$(CONFIG_SMP) += smp.o smpboot.o domain.o | |||
20 | obj-$(CONFIG_PERFMON) += perfmon_default_smpl.o | 20 | obj-$(CONFIG_PERFMON) += perfmon_default_smpl.o |
21 | obj-$(CONFIG_IA64_CYCLONE) += cyclone.o | 21 | obj-$(CONFIG_IA64_CYCLONE) += cyclone.o |
22 | obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o | 22 | obj-$(CONFIG_IA64_MCA_RECOVERY) += mca_recovery.o |
23 | obj-$(CONFIG_KPROBES) += kprobes.o | 23 | obj-$(CONFIG_KPROBES) += kprobes.o jprobes.o |
24 | obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o | 24 | obj-$(CONFIG_IA64_UNCACHED_ALLOCATOR) += uncached.o |
25 | mca_recovery-y += mca_drv.o mca_drv_asm.o | 25 | mca_recovery-y += mca_drv.o mca_drv_asm.o |
26 | 26 | ||
diff --git a/arch/ia64/kernel/jprobes.S b/arch/ia64/kernel/jprobes.S new file mode 100644 index 000000000000..b7fa3ccd2b0f --- /dev/null +++ b/arch/ia64/kernel/jprobes.S | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Jprobe specific operations | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the Free Software | ||
16 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
17 | * | ||
18 | * Copyright (C) Intel Corporation, 2005 | ||
19 | * | ||
20 | * 2005-May Rusty Lynch <rusty.lynch@intel.com> and Anil S Keshavamurthy | ||
21 | * <anil.s.keshavamurthy@intel.com> initial implementation | ||
22 | * | ||
23 | * Jprobes (a.k.a. "jump probes" which is built on-top of kprobes) allow a | ||
24 | * probe to be inserted into the beginning of a function call. The fundamental | ||
25 | * difference between a jprobe and a kprobe is the jprobe handler is executed | ||
26 | * in the same context as the target function, while the kprobe handlers | ||
27 | * are executed in interrupt context. | ||
28 | * | ||
29 | * For jprobes we initially gain control by placing a break point in the | ||
30 | * first instruction of the targeted function. When we catch that specific | ||
31 | * break, we: | ||
32 | * * set the return address to our jprobe_inst_return() function | ||
33 | * * jump to the jprobe handler function | ||
34 | * | ||
35 | * Since we fixed up the return address, the jprobe handler will return to our | ||
36 | * jprobe_inst_return() function, giving us control again. At this point we | ||
37 | * are back in the parents frame marker, so we do yet another call to our | ||
38 | * jprobe_break() function to fix up the frame marker as it would normally | ||
39 | * exist in the target function. | ||
40 | * | ||
41 | * Our jprobe_return function then transfers control back to kprobes.c by | ||
42 | * executing a break instruction using one of our reserved numbers. When we | ||
43 | * catch that break in kprobes.c, we continue like we do for a normal kprobe | ||
44 | * by single stepping the emulated instruction, and then returning execution | ||
45 | * to the correct location. | ||
46 | */ | ||
47 | #include <asm/asmmacro.h> | ||
48 | |||
49 | /* | ||
50 | * void jprobe_break(void) | ||
51 | */ | ||
52 | ENTRY(jprobe_break) | ||
53 | break.m 0x80300 | ||
54 | END(jprobe_break) | ||
55 | |||
56 | /* | ||
57 | * void jprobe_inst_return(void) | ||
58 | */ | ||
59 | GLOBAL_ENTRY(jprobe_inst_return) | ||
60 | br.call.sptk.many b0=jprobe_break | ||
61 | END(jprobe_inst_return) | ||
diff --git a/arch/ia64/kernel/kprobes.c b/arch/ia64/kernel/kprobes.c index 81a53f99a573..6683a44f419f 100644 --- a/arch/ia64/kernel/kprobes.c +++ b/arch/ia64/kernel/kprobes.c | |||
@@ -35,12 +35,15 @@ | |||
35 | #include <asm/pgtable.h> | 35 | #include <asm/pgtable.h> |
36 | #include <asm/kdebug.h> | 36 | #include <asm/kdebug.h> |
37 | 37 | ||
38 | extern void jprobe_inst_return(void); | ||
39 | |||
38 | /* kprobe_status settings */ | 40 | /* kprobe_status settings */ |
39 | #define KPROBE_HIT_ACTIVE 0x00000001 | 41 | #define KPROBE_HIT_ACTIVE 0x00000001 |
40 | #define KPROBE_HIT_SS 0x00000002 | 42 | #define KPROBE_HIT_SS 0x00000002 |
41 | 43 | ||
42 | static struct kprobe *current_kprobe; | 44 | static struct kprobe *current_kprobe; |
43 | static unsigned long kprobe_status; | 45 | static unsigned long kprobe_status; |
46 | static struct pt_regs jprobe_saved_regs; | ||
44 | 47 | ||
45 | enum instruction_type {A, I, M, F, B, L, X, u}; | 48 | enum instruction_type {A, I, M, F, B, L, X, u}; |
46 | static enum instruction_type bundle_encoding[32][3] = { | 49 | static enum instruction_type bundle_encoding[32][3] = { |
@@ -318,15 +321,28 @@ int kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, | |||
318 | 321 | ||
319 | int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) | 322 | int setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) |
320 | { | 323 | { |
321 | printk(KERN_WARNING "Jprobes is not supported\n"); | 324 | struct jprobe *jp = container_of(p, struct jprobe, kp); |
322 | return 0; | 325 | unsigned long addr = ((struct fnptr *)(jp->entry))->ip; |
323 | } | ||
324 | 326 | ||
325 | void jprobe_return(void) | 327 | /* save architectural state */ |
326 | { | 328 | jprobe_saved_regs = *regs; |
329 | |||
330 | /* after rfi, execute the jprobe instrumented function */ | ||
331 | regs->cr_iip = addr & ~0xFULL; | ||
332 | ia64_psr(regs)->ri = addr & 0xf; | ||
333 | regs->r1 = ((struct fnptr *)(jp->entry))->gp; | ||
334 | |||
335 | /* | ||
336 | * fix the return address to our jprobe_inst_return() function | ||
337 | * in the jprobes.S file | ||
338 | */ | ||
339 | regs->b0 = ((struct fnptr *)(jprobe_inst_return))->ip; | ||
340 | |||
341 | return 1; | ||
327 | } | 342 | } |
328 | 343 | ||
329 | int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs) | 344 | int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs) |
330 | { | 345 | { |
331 | return 0; | 346 | *regs = jprobe_saved_regs; |
347 | return 1; | ||
332 | } | 348 | } |
diff --git a/include/asm-ia64/kprobes.h b/include/asm-ia64/kprobes.h index 2a6f2a148890..fec3506e53f8 100644 --- a/include/asm-ia64/kprobes.h +++ b/include/asm-ia64/kprobes.h | |||
@@ -59,6 +59,11 @@ struct arch_specific_insn { | |||
59 | kprobe_opcode_t insn; | 59 | kprobe_opcode_t insn; |
60 | }; | 60 | }; |
61 | 61 | ||
62 | /* ia64 does not need this */ | ||
63 | static inline void jprobe_return(void) | ||
64 | { | ||
65 | } | ||
66 | |||
62 | #ifdef CONFIG_KPROBES | 67 | #ifdef CONFIG_KPROBES |
63 | extern int kprobe_exceptions_notify(struct notifier_block *self, | 68 | extern int kprobe_exceptions_notify(struct notifier_block *self, |
64 | unsigned long val, void *data); | 69 | unsigned long val, void *data); |