diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2014-11-24 21:38:40 -0500 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2014-12-01 14:08:43 -0500 |
commit | f1ab00af816ec8e1ad53229963c863fdd6bcf222 (patch) | |
tree | 91ef3763b2403fd33f88b0e5306dbda4458f1970 | |
parent | 0687c36e456ca81feff5f3415e53c1cb8d8efd56 (diff) |
ftrace/x86: Get rid of ftrace_caller_setup
Move all the work from ftrace_caller_setup into save_mcount_regs. This
simplifies the code and makes it easier to understand.
Link: http://lkml.kernel.org/r/CA+55aFxUTUbdxpjVMW8X9c=o8sui7OB_MYPfcbJuDyfUWtNrNg@mail.gmail.com
Link: http://lkml.kernel.org/r/alpine.DEB.2.11.1411262304010.3961@nanos
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | arch/x86/kernel/mcount_64.S | 71 |
1 files changed, 42 insertions, 29 deletions
diff --git a/arch/x86/kernel/mcount_64.S b/arch/x86/kernel/mcount_64.S index 003b22df1d87..ddc766efa1f1 100644 --- a/arch/x86/kernel/mcount_64.S +++ b/arch/x86/kernel/mcount_64.S | |||
@@ -54,7 +54,15 @@ | |||
54 | * be saved in the locations that pt_regs has them in. | 54 | * be saved in the locations that pt_regs has them in. |
55 | */ | 55 | */ |
56 | 56 | ||
57 | /* @added: the amount of stack added before calling this */ | 57 | /* |
58 | * @added: the amount of stack added before calling this | ||
59 | * | ||
60 | * After this is called, the following registers contain: | ||
61 | * | ||
62 | * %rdi - holds the address that called the trampoline | ||
63 | * %rsi - holds the parent function (traced function's return address) | ||
64 | * %rdx - holds the original %rbp | ||
65 | */ | ||
58 | .macro save_mcount_regs added=0 | 66 | .macro save_mcount_regs added=0 |
59 | 67 | ||
60 | /* Always save the original rbp */ | 68 | /* Always save the original rbp */ |
@@ -101,9 +109,24 @@ | |||
101 | movq MCOUNT_REG_SIZE-8(%rsp), %rdx | 109 | movq MCOUNT_REG_SIZE-8(%rsp), %rdx |
102 | movq %rdx, RBP(%rsp) | 110 | movq %rdx, RBP(%rsp) |
103 | 111 | ||
112 | /* Copy the parent address into %rsi (second parameter) */ | ||
113 | #ifdef CC_USING_FENTRY | ||
114 | movq MCOUNT_REG_SIZE+8+\added(%rsp), %rsi | ||
115 | #else | ||
116 | /* %rdx contains original %rbp */ | ||
117 | movq 8(%rdx), %rsi | ||
118 | #endif | ||
119 | |||
104 | /* Move RIP to its proper location */ | 120 | /* Move RIP to its proper location */ |
105 | movq MCOUNT_REG_SIZE+\added(%rsp), %rdi | 121 | movq MCOUNT_REG_SIZE+\added(%rsp), %rdi |
106 | movq %rdi, RIP(%rsp) | 122 | movq %rdi, RIP(%rsp) |
123 | |||
124 | /* | ||
125 | * Now %rdi (the first parameter) has the return address of | ||
126 | * where ftrace_call returns. But the callbacks expect the | ||
127 | * the address of the call itself. | ||
128 | */ | ||
129 | subq $MCOUNT_INSN_SIZE, %rdi | ||
107 | .endm | 130 | .endm |
108 | 131 | ||
109 | .macro restore_mcount_regs | 132 | .macro restore_mcount_regs |
@@ -122,28 +145,6 @@ | |||
122 | 145 | ||
123 | .endm | 146 | .endm |
124 | 147 | ||
125 | /* skip is set if stack has been adjusted */ | ||
126 | .macro ftrace_caller_setup trace_label added=0 | ||
127 | save_mcount_regs \added | ||
128 | |||
129 | /* Save this location */ | ||
130 | GLOBAL(\trace_label) | ||
131 | /* Load the ftrace_ops into the 3rd parameter */ | ||
132 | movq function_trace_op(%rip), %rdx | ||
133 | |||
134 | /* %rdi already has %rip from the save_mcount_regs macro */ | ||
135 | subq $MCOUNT_INSN_SIZE, %rdi | ||
136 | /* Load the parent_ip into the second parameter */ | ||
137 | #ifdef CC_USING_FENTRY | ||
138 | movq MCOUNT_REG_SIZE+8+\added(%rsp), %rsi | ||
139 | #else | ||
140 | /* Need to grab the original %rbp */ | ||
141 | movq RBP(%rsp), %rsi | ||
142 | /* Now parent address is 8 above original %rbp */ | ||
143 | movq 8(%rsi), %rsi | ||
144 | #endif | ||
145 | .endm | ||
146 | |||
147 | #ifdef CONFIG_DYNAMIC_FTRACE | 148 | #ifdef CONFIG_DYNAMIC_FTRACE |
148 | 149 | ||
149 | ENTRY(function_hook) | 150 | ENTRY(function_hook) |
@@ -151,7 +152,13 @@ ENTRY(function_hook) | |||
151 | END(function_hook) | 152 | END(function_hook) |
152 | 153 | ||
153 | ENTRY(ftrace_caller) | 154 | ENTRY(ftrace_caller) |
154 | ftrace_caller_setup ftrace_caller_op_ptr | 155 | /* save_mcount_regs fills in first two parameters */ |
156 | save_mcount_regs | ||
157 | |||
158 | GLOBAL(ftrace_caller_op_ptr) | ||
159 | /* Load the ftrace_ops into the 3rd parameter */ | ||
160 | movq function_trace_op(%rip), %rdx | ||
161 | |||
155 | /* regs go into 4th parameter (but make it NULL) */ | 162 | /* regs go into 4th parameter (but make it NULL) */ |
156 | movq $0, %rcx | 163 | movq $0, %rcx |
157 | 164 | ||
@@ -182,7 +189,12 @@ ENTRY(ftrace_regs_caller) | |||
182 | pushfq | 189 | pushfq |
183 | 190 | ||
184 | /* added 8 bytes to save flags */ | 191 | /* added 8 bytes to save flags */ |
185 | ftrace_caller_setup ftrace_regs_caller_op_ptr 8 | 192 | save_mcount_regs 8 |
193 | /* save_mcount_regs fills in first two parameters */ | ||
194 | |||
195 | GLOBAL(ftrace_regs_caller_op_ptr) | ||
196 | /* Load the ftrace_ops into the 3rd parameter */ | ||
197 | movq function_trace_op(%rip), %rdx | ||
186 | 198 | ||
187 | /* Save the rest of pt_regs */ | 199 | /* Save the rest of pt_regs */ |
188 | movq %r15, R15(%rsp) | 200 | movq %r15, R15(%rsp) |
@@ -263,7 +275,8 @@ GLOBAL(ftrace_stub) | |||
263 | retq | 275 | retq |
264 | 276 | ||
265 | trace: | 277 | trace: |
266 | ftrace_caller_setup ftrace_caller_op_ptr | 278 | /* save_mcount_regs fills in first two parameters */ |
279 | save_mcount_regs | ||
267 | 280 | ||
268 | call *ftrace_trace_function | 281 | call *ftrace_trace_function |
269 | 282 | ||
@@ -276,16 +289,16 @@ END(function_hook) | |||
276 | 289 | ||
277 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER | 290 | #ifdef CONFIG_FUNCTION_GRAPH_TRACER |
278 | ENTRY(ftrace_graph_caller) | 291 | ENTRY(ftrace_graph_caller) |
292 | /* Saves rbp into %rdx */ | ||
279 | save_mcount_regs | 293 | save_mcount_regs |
280 | 294 | ||
281 | #ifdef CC_USING_FENTRY | 295 | #ifdef CC_USING_FENTRY |
282 | leaq MCOUNT_REG_SIZE+8(%rsp), %rdi | 296 | leaq MCOUNT_REG_SIZE+8(%rsp), %rdi |
283 | movq $0, %rdx /* No framepointers needed */ | 297 | movq $0, %rdx /* No framepointers needed */ |
284 | #else | 298 | #else |
285 | /* Need to grab the original %rbp */ | 299 | /* Save address of the return address of traced function */ |
286 | movq RBP(%rsp), %rdx | ||
287 | /* Now parent address is 8 above original %rbp */ | ||
288 | leaq 8(%rdx), %rdi | 300 | leaq 8(%rdx), %rdi |
301 | /* ftrace does sanity checks against frame pointers */ | ||
289 | movq (%rdx), %rdx | 302 | movq (%rdx), %rdx |
290 | #endif | 303 | #endif |
291 | movq RIP(%rsp), %rsi | 304 | movq RIP(%rsp), %rsi |