diff options
author | Andi Kleen <ak@linux.intel.com> | 2013-08-05 18:02:41 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2013-08-06 17:19:48 -0400 |
commit | 04bb591ca74fb8ea06d5ab7fadfb7bf5b11fb28e (patch) | |
tree | d39a3a2bfa54a5f5d272952ba5c586601c5295ec /arch/x86 | |
parent | ff49103fdba59aa3f845ad2dcac0c26a9e4c5404 (diff) |
x86, asmlinkage: Make kprobes code visible and fix assembler code
- Make all the external assembler template symbols __visible
- Move the templates inline assembler code into a top level
assembler statement, not inside a function. This avoids it being
optimized away or cloned.
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Anil S Keshavamurthy <anil.s.keshavamurthy@intel.com>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
Link: http://lkml.kernel.org/r/1375740170-7446-8-git-send-email-andi@firstfloor.org
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/include/asm/kprobes.h | 10 | ||||
-rw-r--r-- | arch/x86/kernel/kprobes/core.c | 2 | ||||
-rw-r--r-- | arch/x86/kernel/kprobes/opt.c | 5 |
3 files changed, 7 insertions, 10 deletions
diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h index 5a6d2873f80e..9454c167629f 100644 --- a/arch/x86/include/asm/kprobes.h +++ b/arch/x86/include/asm/kprobes.h | |||
@@ -49,10 +49,10 @@ typedef u8 kprobe_opcode_t; | |||
49 | #define flush_insn_slot(p) do { } while (0) | 49 | #define flush_insn_slot(p) do { } while (0) |
50 | 50 | ||
51 | /* optinsn template addresses */ | 51 | /* optinsn template addresses */ |
52 | extern kprobe_opcode_t optprobe_template_entry; | 52 | extern __visible kprobe_opcode_t optprobe_template_entry; |
53 | extern kprobe_opcode_t optprobe_template_val; | 53 | extern __visible kprobe_opcode_t optprobe_template_val; |
54 | extern kprobe_opcode_t optprobe_template_call; | 54 | extern __visible kprobe_opcode_t optprobe_template_call; |
55 | extern kprobe_opcode_t optprobe_template_end; | 55 | extern __visible kprobe_opcode_t optprobe_template_end; |
56 | #define MAX_OPTIMIZED_LENGTH (MAX_INSN_SIZE + RELATIVE_ADDR_SIZE) | 56 | #define MAX_OPTIMIZED_LENGTH (MAX_INSN_SIZE + RELATIVE_ADDR_SIZE) |
57 | #define MAX_OPTINSN_SIZE \ | 57 | #define MAX_OPTINSN_SIZE \ |
58 | (((unsigned long)&optprobe_template_end - \ | 58 | (((unsigned long)&optprobe_template_end - \ |
@@ -62,7 +62,7 @@ extern kprobe_opcode_t optprobe_template_end; | |||
62 | extern const int kretprobe_blacklist_size; | 62 | extern const int kretprobe_blacklist_size; |
63 | 63 | ||
64 | void arch_remove_kprobe(struct kprobe *p); | 64 | void arch_remove_kprobe(struct kprobe *p); |
65 | void kretprobe_trampoline(void); | 65 | asmlinkage void kretprobe_trampoline(void); |
66 | 66 | ||
67 | /* Architecture specific copy of original instruction*/ | 67 | /* Architecture specific copy of original instruction*/ |
68 | struct arch_specific_insn { | 68 | struct arch_specific_insn { |
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 211bce445522..048852d06447 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c | |||
@@ -661,7 +661,7 @@ static void __used __kprobes kretprobe_trampoline_holder(void) | |||
661 | /* | 661 | /* |
662 | * Called from kretprobe_trampoline | 662 | * Called from kretprobe_trampoline |
663 | */ | 663 | */ |
664 | static __used __kprobes void *trampoline_handler(struct pt_regs *regs) | 664 | __visible __used __kprobes void *trampoline_handler(struct pt_regs *regs) |
665 | { | 665 | { |
666 | struct kretprobe_instance *ri = NULL; | 666 | struct kretprobe_instance *ri = NULL; |
667 | struct hlist_head *head, empty_rp; | 667 | struct hlist_head *head, empty_rp; |
diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c index 76dc6f095724..2c1ac2893365 100644 --- a/arch/x86/kernel/kprobes/opt.c +++ b/arch/x86/kernel/kprobes/opt.c | |||
@@ -88,9 +88,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v | |||
88 | *(unsigned long *)addr = val; | 88 | *(unsigned long *)addr = val; |
89 | } | 89 | } |
90 | 90 | ||
91 | static void __used __kprobes kprobes_optinsn_template_holder(void) | 91 | asm ( |
92 | { | ||
93 | asm volatile ( | ||
94 | ".global optprobe_template_entry\n" | 92 | ".global optprobe_template_entry\n" |
95 | "optprobe_template_entry:\n" | 93 | "optprobe_template_entry:\n" |
96 | #ifdef CONFIG_X86_64 | 94 | #ifdef CONFIG_X86_64 |
@@ -129,7 +127,6 @@ static void __used __kprobes kprobes_optinsn_template_holder(void) | |||
129 | #endif | 127 | #endif |
130 | ".global optprobe_template_end\n" | 128 | ".global optprobe_template_end\n" |
131 | "optprobe_template_end:\n"); | 129 | "optprobe_template_end:\n"); |
132 | } | ||
133 | 130 | ||
134 | #define TMPL_MOVE_IDX \ | 131 | #define TMPL_MOVE_IDX \ |
135 | ((long)&optprobe_template_val - (long)&optprobe_template_entry) | 132 | ((long)&optprobe_template_val - (long)&optprobe_template_entry) |