diff options
author | Wang Nan <wangnan0@huawei.com> | 2015-01-09 01:37:36 -0500 |
---|---|---|
committer | Jon Medhurst <tixy@linaro.org> | 2015-01-13 11:10:17 -0500 |
commit | 0dc016dbd820260b8ea74337980735b8c88d4ef2 (patch) | |
tree | 0a6408b4181016d41858afec026cc4e93455f852 /arch/arm/kernel | |
parent | cbf6ab52add20b845f903decc973afbd5463c527 (diff) |
ARM: kprobes: enable OPTPROBES for ARM 32
This patch introduce kprobeopt for ARM 32.
Limitations:
- Currently only kernel compiled with ARM ISA is supported.
- Offset between probe point and optinsn slot must not larger than
32MiB. Masami Hiramatsu suggests replacing 2 words, it will make
things complex. Futher patch can make such optimization.
Kprobe opt on ARM is relatively simpler than kprobe opt on x86 because
ARM instruction is always 4 bytes aligned and 4 bytes long. This patch
replace probed instruction by a 'b', branch to trampoline code and then
calls optimized_callback(). optimized_callback() calls opt_pre_handler()
to execute kprobe handler. It also emulate/simulate replaced instruction.
When unregistering kprobe, the deferred manner of unoptimizer may leave
branch instruction before optimizer is called. Different from x86_64,
which only copy the probed insn after optprobe_template_end and
reexecute them, this patch call singlestep to emulate/simulate the insn
directly. Futher patch can optimize this behavior.
Signed-off-by: Wang Nan <wangnan0@huawei.com>
Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Will Deacon <will.deacon@arm.com>
Reviewed-by: Jon Medhurst (Tixy) <tixy@linaro.org>
Signed-off-by: Jon Medhurst <tixy@linaro.org>
Diffstat (limited to 'arch/arm/kernel')
-rw-r--r-- | arch/arm/kernel/Makefile | 2 | ||||
-rw-r--r-- | arch/arm/kernel/ftrace.c | 3 | ||||
-rw-r--r-- | arch/arm/kernel/insn.h | 29 | ||||
-rw-r--r-- | arch/arm/kernel/jump_label.c | 3 |
4 files changed, 3 insertions, 34 deletions
diff --git a/arch/arm/kernel/Makefile b/arch/arm/kernel/Makefile index 9c51a433e025..902397dd1000 100644 --- a/arch/arm/kernel/Makefile +++ b/arch/arm/kernel/Makefile | |||
@@ -52,7 +52,7 @@ obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o insn.o | |||
52 | obj-$(CONFIG_JUMP_LABEL) += jump_label.o insn.o patch.o | 52 | obj-$(CONFIG_JUMP_LABEL) += jump_label.o insn.o patch.o |
53 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o | 53 | obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o |
54 | # Main staffs in KPROBES are in arch/arm/probes/ . | 54 | # Main staffs in KPROBES are in arch/arm/probes/ . |
55 | obj-$(CONFIG_KPROBES) += patch.o | 55 | obj-$(CONFIG_KPROBES) += patch.o insn.o |
56 | obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o | 56 | obj-$(CONFIG_OABI_COMPAT) += sys_oabi-compat.o |
57 | obj-$(CONFIG_ARM_THUMBEE) += thumbee.o | 57 | obj-$(CONFIG_ARM_THUMBEE) += thumbee.o |
58 | obj-$(CONFIG_KGDB) += kgdb.o patch.o | 58 | obj-$(CONFIG_KGDB) += kgdb.o patch.o |
diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index b8c75e45a950..709ee1d6d4df 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c | |||
@@ -20,8 +20,7 @@ | |||
20 | #include <asm/cacheflush.h> | 20 | #include <asm/cacheflush.h> |
21 | #include <asm/opcodes.h> | 21 | #include <asm/opcodes.h> |
22 | #include <asm/ftrace.h> | 22 | #include <asm/ftrace.h> |
23 | 23 | #include <asm/insn.h> | |
24 | #include "insn.h" | ||
25 | 24 | ||
26 | #ifdef CONFIG_THUMB2_KERNEL | 25 | #ifdef CONFIG_THUMB2_KERNEL |
27 | #define NOP 0xf85deb04 /* pop.w {lr} */ | 26 | #define NOP 0xf85deb04 /* pop.w {lr} */ |
diff --git a/arch/arm/kernel/insn.h b/arch/arm/kernel/insn.h deleted file mode 100644 index e96065da4dae..000000000000 --- a/arch/arm/kernel/insn.h +++ /dev/null | |||
@@ -1,29 +0,0 @@ | |||
1 | #ifndef __ASM_ARM_INSN_H | ||
2 | #define __ASM_ARM_INSN_H | ||
3 | |||
4 | static inline unsigned long | ||
5 | arm_gen_nop(void) | ||
6 | { | ||
7 | #ifdef CONFIG_THUMB2_KERNEL | ||
8 | return 0xf3af8000; /* nop.w */ | ||
9 | #else | ||
10 | return 0xe1a00000; /* mov r0, r0 */ | ||
11 | #endif | ||
12 | } | ||
13 | |||
14 | unsigned long | ||
15 | __arm_gen_branch(unsigned long pc, unsigned long addr, bool link); | ||
16 | |||
17 | static inline unsigned long | ||
18 | arm_gen_branch(unsigned long pc, unsigned long addr) | ||
19 | { | ||
20 | return __arm_gen_branch(pc, addr, false); | ||
21 | } | ||
22 | |||
23 | static inline unsigned long | ||
24 | arm_gen_branch_link(unsigned long pc, unsigned long addr) | ||
25 | { | ||
26 | return __arm_gen_branch(pc, addr, true); | ||
27 | } | ||
28 | |||
29 | #endif | ||
diff --git a/arch/arm/kernel/jump_label.c b/arch/arm/kernel/jump_label.c index d8da075959bf..e39cbf488cfe 100644 --- a/arch/arm/kernel/jump_label.c +++ b/arch/arm/kernel/jump_label.c | |||
@@ -1,8 +1,7 @@ | |||
1 | #include <linux/kernel.h> | 1 | #include <linux/kernel.h> |
2 | #include <linux/jump_label.h> | 2 | #include <linux/jump_label.h> |
3 | #include <asm/patch.h> | 3 | #include <asm/patch.h> |
4 | 4 | #include <asm/insn.h> | |
5 | #include "insn.h" | ||
6 | 5 | ||
7 | #ifdef HAVE_JUMP_LABEL | 6 | #ifdef HAVE_JUMP_LABEL |
8 | 7 | ||