aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2008-12-12 16:09:08 -0500
committerIngo Molnar <mingo@elte.hu>2008-12-16 18:26:38 -0500
commitd680fe44775ed17a80035462d9898f5e77bfd7dd (patch)
treedddee638e2a44d5008684c6a59b44edcae98ba8f /arch/x86
parent66896a85cf2890b6bbbc4c9ccdcd296600ffbf89 (diff)
x86: entry_64 - introduce FTRACE_ frame macro v2
Impact: clean up Itroduce MCOUNT_SAVE/RESTORE_FRAME which allow us to save a number of lines on source level. Also fix a comment in ftrace.h. Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/include/asm/ftrace.h29
-rw-r--r--arch/x86/kernel/entry_64.S57
2 files changed, 35 insertions, 51 deletions
diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h
index 7e61b4ceb9a4..b55b4a7fbefd 100644
--- a/arch/x86/include/asm/ftrace.h
+++ b/arch/x86/include/asm/ftrace.h
@@ -1,6 +1,33 @@
1#ifndef _ASM_X86_FTRACE_H 1#ifndef _ASM_X86_FTRACE_H
2#define _ASM_X86_FTRACE_H 2#define _ASM_X86_FTRACE_H
3 3
4#ifdef __ASSEMBLY__
5
6 .macro MCOUNT_SAVE_FRAME
7 /* taken from glibc */
8 subq $0x38, %rsp
9 movq %rax, (%rsp)
10 movq %rcx, 8(%rsp)
11 movq %rdx, 16(%rsp)
12 movq %rsi, 24(%rsp)
13 movq %rdi, 32(%rsp)
14 movq %r8, 40(%rsp)
15 movq %r9, 48(%rsp)
16 .endm
17
18 .macro MCOUNT_RESTORE_FRAME
19 movq 48(%rsp), %r9
20 movq 40(%rsp), %r8
21 movq 32(%rsp), %rdi
22 movq 24(%rsp), %rsi
23 movq 16(%rsp), %rdx
24 movq 8(%rsp), %rcx
25 movq (%rsp), %rax
26 addq $0x38, %rsp
27 .endm
28
29#endif
30
4#ifdef CONFIG_FUNCTION_TRACER 31#ifdef CONFIG_FUNCTION_TRACER
5#define MCOUNT_ADDR ((long)(mcount)) 32#define MCOUNT_ADDR ((long)(mcount))
6#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ 33#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
@@ -46,7 +73,7 @@ struct ftrace_ret_stack {
46/* 73/*
47 * Primary handler of a function return. 74 * Primary handler of a function return.
48 * It relays on ftrace_return_to_handler. 75 * It relays on ftrace_return_to_handler.
49 * Defined in entry32.S 76 * Defined in entry_32/64.S
50 */ 77 */
51extern void return_to_handler(void); 78extern void return_to_handler(void);
52 79
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
index 54e0bbdccb99..303dd84d2a98 100644
--- a/arch/x86/kernel/entry_64.S
+++ b/arch/x86/kernel/entry_64.S
@@ -71,15 +71,7 @@ ENTRY(ftrace_caller)
71 cmpl $0, function_trace_stop 71 cmpl $0, function_trace_stop
72 jne ftrace_stub 72 jne ftrace_stub
73 73
74 /* taken from glibc */ 74 MCOUNT_SAVE_FRAME
75 subq $0x38, %rsp
76 movq %rax, (%rsp)
77 movq %rcx, 8(%rsp)
78 movq %rdx, 16(%rsp)
79 movq %rsi, 24(%rsp)
80 movq %rdi, 32(%rsp)
81 movq %r8, 40(%rsp)
82 movq %r9, 48(%rsp)
83 75
84 movq 0x38(%rsp), %rdi 76 movq 0x38(%rsp), %rdi
85 movq 8(%rbp), %rsi 77 movq 8(%rbp), %rsi
@@ -89,14 +81,7 @@ ENTRY(ftrace_caller)
89ftrace_call: 81ftrace_call:
90 call ftrace_stub 82 call ftrace_stub
91 83
92 movq 48(%rsp), %r9 84 MCOUNT_RESTORE_FRAME
93 movq 40(%rsp), %r8
94 movq 32(%rsp), %rdi
95 movq 24(%rsp), %rsi
96 movq 16(%rsp), %rdx
97 movq 8(%rsp), %rcx
98 movq (%rsp), %rax
99 addq $0x38, %rsp
100 85
101#ifdef CONFIG_FUNCTION_GRAPH_TRACER 86#ifdef CONFIG_FUNCTION_GRAPH_TRACER
102.globl ftrace_graph_call 87.globl ftrace_graph_call
@@ -130,15 +115,7 @@ ftrace_stub:
130 retq 115 retq
131 116
132trace: 117trace:
133 /* taken from glibc */ 118 MCOUNT_SAVE_FRAME
134 subq $0x38, %rsp
135 movq %rax, (%rsp)
136 movq %rcx, 8(%rsp)
137 movq %rdx, 16(%rsp)
138 movq %rsi, 24(%rsp)
139 movq %rdi, 32(%rsp)
140 movq %r8, 40(%rsp)
141 movq %r9, 48(%rsp)
142 119
143 movq 0x38(%rsp), %rdi 120 movq 0x38(%rsp), %rdi
144 movq 8(%rbp), %rsi 121 movq 8(%rbp), %rsi
@@ -146,14 +123,7 @@ trace:
146 123
147 call *ftrace_trace_function 124 call *ftrace_trace_function
148 125
149 movq 48(%rsp), %r9 126 MCOUNT_RESTORE_FRAME
150 movq 40(%rsp), %r8
151 movq 32(%rsp), %rdi
152 movq 24(%rsp), %rsi
153 movq 16(%rsp), %rdx
154 movq 8(%rsp), %rcx
155 movq (%rsp), %rax
156 addq $0x38, %rsp
157 127
158 jmp ftrace_stub 128 jmp ftrace_stub
159END(mcount) 129END(mcount)
@@ -165,14 +135,7 @@ ENTRY(ftrace_graph_caller)
165 cmpl $0, function_trace_stop 135 cmpl $0, function_trace_stop
166 jne ftrace_stub 136 jne ftrace_stub
167 137
168 subq $0x38, %rsp 138 MCOUNT_SAVE_FRAME
169 movq %rax, (%rsp)
170 movq %rcx, 8(%rsp)
171 movq %rdx, 16(%rsp)
172 movq %rsi, 24(%rsp)
173 movq %rdi, 32(%rsp)
174 movq %r8, 40(%rsp)
175 movq %r9, 48(%rsp)
176 139
177 leaq 8(%rbp), %rdi 140 leaq 8(%rbp), %rdi
178 movq 0x38(%rsp), %rsi 141 movq 0x38(%rsp), %rsi
@@ -180,14 +143,8 @@ ENTRY(ftrace_graph_caller)
180 143
181 call prepare_ftrace_return 144 call prepare_ftrace_return
182 145
183 movq 48(%rsp), %r9 146 MCOUNT_RESTORE_FRAME
184 movq 40(%rsp), %r8 147
185 movq 32(%rsp), %rdi
186 movq 24(%rsp), %rsi
187 movq 16(%rsp), %rdx
188 movq 8(%rsp), %rcx
189 movq (%rsp), %rax
190 addq $0x38, %rsp
191 retq 148 retq
192END(ftrace_graph_caller) 149END(ftrace_graph_caller)
193 150