diff options
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/Kconfig | 1 | ||||
-rw-r--r-- | arch/x86/include/asm/ftrace.h | 7 | ||||
-rw-r--r-- | arch/x86/kernel/entry_64.S | 32 | ||||
-rw-r--r-- | arch/x86/kernel/x8664_ksyms_64.c | 6 |
4 files changed, 39 insertions, 7 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index a2d19ee750ca..28dd891a0a16 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
@@ -36,6 +36,7 @@ config X86 | |||
36 | select HAVE_KRETPROBES | 36 | select HAVE_KRETPROBES |
37 | select HAVE_OPTPROBES | 37 | select HAVE_OPTPROBES |
38 | select HAVE_FTRACE_MCOUNT_RECORD | 38 | select HAVE_FTRACE_MCOUNT_RECORD |
39 | select HAVE_FENTRY if X86_64 | ||
39 | select HAVE_C_RECORDMCOUNT | 40 | select HAVE_C_RECORDMCOUNT |
40 | select HAVE_DYNAMIC_FTRACE | 41 | select HAVE_DYNAMIC_FTRACE |
41 | select HAVE_FUNCTION_TRACER | 42 | select HAVE_FUNCTION_TRACER |
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h index a6cae0c1720c..9a25b522d377 100644 --- a/arch/x86/include/asm/ftrace.h +++ b/arch/x86/include/asm/ftrace.h | |||
@@ -35,7 +35,11 @@ | |||
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #ifdef CONFIG_FUNCTION_TRACER | 37 | #ifdef CONFIG_FUNCTION_TRACER |
38 | #define MCOUNT_ADDR ((long)(mcount)) | 38 | #ifdef CC_USING_FENTRY |
39 | # define MCOUNT_ADDR ((long)(__fentry__)) | ||
40 | #else | ||
41 | # define MCOUNT_ADDR ((long)(mcount)) | ||
42 | #endif | ||
39 | #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ | 43 | #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ |
40 | 44 | ||
41 | #ifdef CONFIG_DYNAMIC_FTRACE | 45 | #ifdef CONFIG_DYNAMIC_FTRACE |
@@ -46,6 +50,7 @@ | |||
46 | #ifndef __ASSEMBLY__ | 50 | #ifndef __ASSEMBLY__ |
47 | extern void mcount(void); | 51 | extern void mcount(void); |
48 | extern atomic_t modifying_ftrace_code; | 52 | extern atomic_t modifying_ftrace_code; |
53 | extern void __fentry__(void); | ||
49 | 54 | ||
50 | static inline unsigned long ftrace_call_adjust(unsigned long addr) | 55 | static inline unsigned long ftrace_call_adjust(unsigned long addr) |
51 | { | 56 | { |
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index b7a81dcb7366..ed767b747fe5 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S | |||
@@ -68,10 +68,18 @@ | |||
68 | .section .entry.text, "ax" | 68 | .section .entry.text, "ax" |
69 | 69 | ||
70 | #ifdef CONFIG_FUNCTION_TRACER | 70 | #ifdef CONFIG_FUNCTION_TRACER |
71 | |||
72 | #ifdef CC_USING_FENTRY | ||
73 | # define function_hook __fentry__ | ||
74 | #else | ||
75 | # define function_hook mcount | ||
76 | #endif | ||
77 | |||
71 | #ifdef CONFIG_DYNAMIC_FTRACE | 78 | #ifdef CONFIG_DYNAMIC_FTRACE |
72 | ENTRY(mcount) | 79 | |
80 | ENTRY(function_hook) | ||
73 | retq | 81 | retq |
74 | END(mcount) | 82 | END(function_hook) |
75 | 83 | ||
76 | /* skip is set if stack has been adjusted */ | 84 | /* skip is set if stack has been adjusted */ |
77 | .macro ftrace_caller_setup skip=0 | 85 | .macro ftrace_caller_setup skip=0 |
@@ -84,7 +92,11 @@ END(mcount) | |||
84 | movq RIP(%rsp), %rdi | 92 | movq RIP(%rsp), %rdi |
85 | subq $MCOUNT_INSN_SIZE, %rdi | 93 | subq $MCOUNT_INSN_SIZE, %rdi |
86 | /* Load the parent_ip into the second parameter */ | 94 | /* Load the parent_ip into the second parameter */ |
95 | #ifdef CC_USING_FENTRY | ||
96 | movq SS+16(%rsp), %rsi | ||
97 | #else | ||
87 | movq 8(%rbp), %rsi | 98 | movq 8(%rbp), %rsi |
99 | #endif | ||
88 | .endm | 100 | .endm |
89 | 101 | ||
90 | ENTRY(ftrace_caller) | 102 | ENTRY(ftrace_caller) |
@@ -177,7 +189,8 @@ END(ftrace_regs_caller) | |||
177 | 189 | ||
178 | 190 | ||
179 | #else /* ! CONFIG_DYNAMIC_FTRACE */ | 191 | #else /* ! CONFIG_DYNAMIC_FTRACE */ |
180 | ENTRY(mcount) | 192 | |
193 | ENTRY(function_hook) | ||
181 | cmpl $0, function_trace_stop | 194 | cmpl $0, function_trace_stop |
182 | jne ftrace_stub | 195 | jne ftrace_stub |
183 | 196 | ||
@@ -199,7 +212,11 @@ trace: | |||
199 | MCOUNT_SAVE_FRAME | 212 | MCOUNT_SAVE_FRAME |
200 | 213 | ||
201 | movq RIP(%rsp), %rdi | 214 | movq RIP(%rsp), %rdi |
215 | #ifdef CC_USING_FENTRY | ||
216 | movq SS+16(%rsp), %rsi | ||
217 | #else | ||
202 | movq 8(%rbp), %rsi | 218 | movq 8(%rbp), %rsi |
219 | #endif | ||
203 | subq $MCOUNT_INSN_SIZE, %rdi | 220 | subq $MCOUNT_INSN_SIZE, %rdi |
204 | 221 | ||
205 | call *ftrace_trace_function | 222 | call *ftrace_trace_function |
@@ -207,7 +224,7 @@ trace: | |||
207 | MCOUNT_RESTORE_FRAME | 224 | MCOUNT_RESTORE_FRAME |
208 | 225 | ||
209 | jmp ftrace_stub | 226 | jmp ftrace_stub |
210 | END(mcount) | 227 | END(function_hook) |
211 | #endif /* CONFIG_DYNAMIC_FTRACE */ | 228 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
212 | #endif /* CONFIG_FUNCTION_TRACER */ | 229 | #endif /* CONFIG_FUNCTION_TRACER */ |
213 | 230 | ||
@@ -215,9 +232,14 @@ END(mcount) | |||
215 | ENTRY(ftrace_graph_caller) | 232 | ENTRY(ftrace_graph_caller) |
216 | MCOUNT_SAVE_FRAME | 233 | MCOUNT_SAVE_FRAME |
217 | 234 | ||
235 | #ifdef CC_USING_FENTRY | ||
236 | leaq SS+16(%rsp), %rdi | ||
237 | movq $0, %rdx /* No framepointers needed */ | ||
238 | #else | ||
218 | leaq 8(%rbp), %rdi | 239 | leaq 8(%rbp), %rdi |
219 | movq RIP(%rsp), %rsi | ||
220 | movq (%rbp), %rdx | 240 | movq (%rbp), %rdx |
241 | #endif | ||
242 | movq RIP(%rsp), %rsi | ||
221 | subq $MCOUNT_INSN_SIZE, %rsi | 243 | subq $MCOUNT_INSN_SIZE, %rsi |
222 | 244 | ||
223 | call prepare_ftrace_return | 245 | call prepare_ftrace_return |
diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c index 6020f6f5927c..1330dd102950 100644 --- a/arch/x86/kernel/x8664_ksyms_64.c +++ b/arch/x86/kernel/x8664_ksyms_64.c | |||
@@ -13,9 +13,13 @@ | |||
13 | #include <asm/ftrace.h> | 13 | #include <asm/ftrace.h> |
14 | 14 | ||
15 | #ifdef CONFIG_FUNCTION_TRACER | 15 | #ifdef CONFIG_FUNCTION_TRACER |
16 | /* mcount is defined in assembly */ | 16 | /* mcount and __fentry__ are defined in assembly */ |
17 | #ifdef CC_USING_FENTRY | ||
18 | EXPORT_SYMBOL(__fentry__); | ||
19 | #else | ||
17 | EXPORT_SYMBOL(mcount); | 20 | EXPORT_SYMBOL(mcount); |
18 | #endif | 21 | #endif |
22 | #endif | ||
19 | 23 | ||
20 | EXPORT_SYMBOL(__get_user_1); | 24 | EXPORT_SYMBOL(__get_user_1); |
21 | EXPORT_SYMBOL(__get_user_2); | 25 | EXPORT_SYMBOL(__get_user_2); |