File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11#ifndef _ASM_X86_FTRACE_H
22#define _ASM_X86_FTRACE_H
33
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+
431#ifdef CONFIG_FUNCTION_TRACER
532#define MCOUNT_ADDR ( (long )(mcount ))
633#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
@@ -46,7 +73,7 @@ struct ftrace_ret_stack {
4673/*
4774 * Primary handler of a function return.
4875 * It relays on ftrace_return_to_handler.
49- * Defined in entry32 .S
76+ * Defined in entry_32/64 .S
5077 */
5178extern void return_to_handler (void );
5279
Original file line number Diff line number Diff line change @@ -71,15 +71,7 @@ ENTRY(ftrace_caller)
7171 cmpl $0 , function_trace_stop
7272 jne ftrace_stub
7373
74- /* taken from glibc */
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 )
74+ MCOUNT_SAVE_FRAME
8375
8476 movq 0x38 (%rsp ), %rdi
8577 movq 8 (%rbp ), %rsi
@@ -89,14 +81,7 @@ ENTRY(ftrace_caller)
8981ftrace_call:
9082 call ftrace_stub
9183
92- movq 48 (%rsp ), %r9
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
84+ MCOUNT_RESTORE_FRAME
10085
10186#ifdef CONFIG_FUNCTION_GRAPH_TRACER
10287.globl ftrace_graph_call
@@ -130,30 +115,15 @@ ftrace_stub:
130115 retq
131116
132117trace:
133- /* taken from glibc */
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 )
118+ MCOUNT_SAVE_FRAME
142119
143120 movq 0x38 (%rsp ), %rdi
144121 movq 8 (%rbp ), %rsi
145122 subq $MCOUNT_INSN_SIZE, %rdi
146123
147124 call *ftrace_trace_function
148125
149- movq 48 (%rsp ), %r9
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
126+ MCOUNT_RESTORE_FRAME
157127
158128 jmp ftrace_stub
159129END(mcount)
@@ -165,29 +135,16 @@ ENTRY(ftrace_graph_caller)
165135 cmpl $0 , function_trace_stop
166136 jne ftrace_stub
167137
168- subq $0x38 , %rsp
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 )
138+ MCOUNT_SAVE_FRAME
176139
177140 leaq 8 (%rbp ), %rdi
178141 movq 0x38 (%rsp ), %rsi
179142 subq $MCOUNT_INSN_SIZE, %rsi
180143
181144 call prepare_ftrace_return
182145
183- movq 48 (%rsp ), %r9
184- movq 40 (%rsp ), %r8
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
146+ MCOUNT_RESTORE_FRAME
147+
191148 retq
192149END(ftrace_graph_caller)
193150
You can’t perform that action at this time.
0 commit comments