diff options
author | Ben Dooks <ben.dooks@codethink.co.uk> | 2013-11-08 18:29:25 +0000 |
---|---|---|
committer | Taras Kondratiuk <taras@ti.com> | 2014-04-01 16:45:19 +0300 |
commit | 888be25402021a425da3e85e2d5a954d7509286e (patch) | |
tree | 5f6a556112fe3098370272c57e482501956d8f6c /arch/arm/kernel/kprobes.c | |
parent | c7edc9e326d53ca5ef9bed82de0740c6b107d55b (diff) | |
download | linux-888be25402021a425da3e85e2d5a954d7509286e.tar.gz linux-888be25402021a425da3e85e2d5a954d7509286e.tar.bz2 linux-888be25402021a425da3e85e2d5a954d7509286e.zip |
ARM: probes: fix instruction fetch order with <asm/opcodes.h>
If we are running BE8, the data and instruction endianness do not
match, so use <asm/opcodes.h> to correctly translate memory accesses
into ARM instructions.
Acked-by: Jon Medhurst <tixy@linaro.org>
Signed-off-by: Ben Dooks <ben.dooks@codethink.co.uk>
[taras.kondratiuk@linaro.org: fixed Thumb instruction fetch order]
Signed-off-by: Taras Kondratiuk <taras.kondratiuk@linaro.org>
Diffstat (limited to 'arch/arm/kernel/kprobes.c')
-rw-r--r-- | arch/arm/kernel/kprobes.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/arch/arm/kernel/kprobes.c b/arch/arm/kernel/kprobes.c index 8795f9f819d5..6d644202c8dc 100644 --- a/arch/arm/kernel/kprobes.c +++ b/arch/arm/kernel/kprobes.c @@ -26,6 +26,7 @@ #include <linux/stop_machine.h> #include <linux/stringify.h> #include <asm/traps.h> +#include <asm/opcodes.h> #include <asm/cacheflush.h> #include <linux/percpu.h> #include <linux/bug.h> @@ -67,10 +68,10 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) #ifdef CONFIG_THUMB2_KERNEL thumb = true; addr &= ~1; /* Bit 0 would normally be set to indicate Thumb code */ - insn = ((u16 *)addr)[0]; + insn = __mem_to_opcode_thumb16(((u16 *)addr)[0]); if (is_wide_instruction(insn)) { - insn <<= 16; - insn |= ((u16 *)addr)[1]; + u16 inst2 = __mem_to_opcode_thumb16(((u16 *)addr)[1]); + insn = __opcode_thumb32_compose(insn, inst2); decode_insn = thumb32_probes_decode_insn; actions = kprobes_t32_actions; } else { @@ -81,7 +82,7 @@ int __kprobes arch_prepare_kprobe(struct kprobe *p) thumb = false; if (addr & 0x3) return -EINVAL; - insn = *p->addr; + insn = __mem_to_opcode_arm(*p->addr); decode_insn = arm_probes_decode_insn; actions = kprobes_arm_actions; #endif |