diff options
author | Jon Medhurst <tixy@yxit.co.uk> | 2011-04-19 12:56:58 -0400 |
---|---|---|
committer | Tixy <tixy@medhuaa1.miniserver.com> | 2011-07-13 13:32:41 -0400 |
commit | 2437170710c4a3dee137a65623960aa7ac82a32e (patch) | |
tree | c886353a398a3e60c148bfd3e3eb7c3a42486d88 /arch/arm/kernel/kprobes.c | |
parent | de41984003ed2315dbb7d58168cc3e72e15b075c (diff) |
ARM: kprobes: Add Thumb instruction decoding stubs
Extend arch_prepare_kprobe to support probing of Thumb code. For
the actual decoding of Thumb instructions, stub functions are
added which currently just reject the probe.
Signed-off-by: Jon Medhurst <tixy@yxit.co.uk>
Acked-by: Nicolas Pitre <nicolas.pitre@linaro.org>
Diffstat (limited to 'arch/arm/kernel/kprobes.c')
-rw-r--r-- | arch/arm/kernel/kprobes.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/arch/arm/kernel/kprobes.c b/arch/arm/kernel/kprobes.c index 0e47d3d67427..0df2d6d57c04 100644 --- a/arch/arm/kernel/kprobes.c +++ b/arch/arm/kernel/kprobes.c | |||
@@ -51,16 +51,32 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) | |||
51 | kprobe_opcode_t insn; | 51 | kprobe_opcode_t insn; |
52 | kprobe_opcode_t tmp_insn[MAX_INSN_SIZE]; | 52 | kprobe_opcode_t tmp_insn[MAX_INSN_SIZE]; |
53 | unsigned long addr = (unsigned long)p->addr; | 53 | unsigned long addr = (unsigned long)p->addr; |
54 | kprobe_decode_insn_t *decode_insn; | ||
54 | int is; | 55 | int is; |
55 | 56 | ||
56 | if (addr & 0x3 || in_exception_text(addr)) | 57 | if (in_exception_text(addr)) |
57 | return -EINVAL; | 58 | return -EINVAL; |
58 | 59 | ||
60 | #ifdef CONFIG_THUMB2_KERNEL | ||
61 | addr &= ~1; /* Bit 0 would normally be set to indicate Thumb code */ | ||
62 | insn = ((u16 *)addr)[0]; | ||
63 | if (is_wide_instruction(insn)) { | ||
64 | insn <<= 16; | ||
65 | insn |= ((u16 *)addr)[1]; | ||
66 | decode_insn = thumb32_kprobe_decode_insn; | ||
67 | } else | ||
68 | decode_insn = thumb16_kprobe_decode_insn; | ||
69 | #else /* !CONFIG_THUMB2_KERNEL */ | ||
70 | if (addr & 0x3) | ||
71 | return -EINVAL; | ||
59 | insn = *p->addr; | 72 | insn = *p->addr; |
73 | decode_insn = arm_kprobe_decode_insn; | ||
74 | #endif | ||
75 | |||
60 | p->opcode = insn; | 76 | p->opcode = insn; |
61 | p->ainsn.insn = tmp_insn; | 77 | p->ainsn.insn = tmp_insn; |
62 | 78 | ||
63 | switch (arm_kprobe_decode_insn(insn, &p->ainsn)) { | 79 | switch ((*decode_insn)(insn, &p->ainsn)) { |
64 | case INSN_REJECTED: /* not supported */ | 80 | case INSN_REJECTED: /* not supported */ |
65 | return -EINVAL; | 81 | return -EINVAL; |
66 | 82 | ||