aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/kernel/entry-common.S
diff options
context:
space:
mode:
authorRabin Vincent <rabin@rab.in>2010-10-07 08:09:47 -0400
committerRabin Vincent <rabin@rab.in>2010-11-19 11:13:26 -0500
commitd3b9dc9dd2b994f396741f7086ffe7a48bacb165 (patch)
tree84491baf18d9c950277419df04e1e75a5b33ed51 /arch/arm/kernel/entry-common.S
parent61b5cb1c3bff8875d2fd289c7b6ac344f95261fa (diff)
ARM: ftrace: use gas macros to avoid code duplication
Use assembler macros to avoid copy/pasting code between the implementations of the two variants of the mcount call. Signed-off-by: Rabin Vincent <rabin@rab.in>
Diffstat (limited to 'arch/arm/kernel/entry-common.S')
-rw-r--r--arch/arm/kernel/entry-common.S146
1 files changed, 80 insertions, 66 deletions
diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
index 8bfa98757cd2..fe1d5862b19f 100644
--- a/arch/arm/kernel/entry-common.S
+++ b/arch/arm/kernel/entry-common.S
@@ -141,98 +141,112 @@ ENDPROC(ret_from_fork)
141#endif 141#endif
142#endif 142#endif
143 143
144#ifdef CONFIG_DYNAMIC_FTRACE 144.macro __mcount suffix
145ENTRY(__gnu_mcount_nc) 145 mcount_enter
146 mov ip, lr 146 ldr r0, =ftrace_trace_function
147 ldmia sp!, {lr} 147 ldr r2, [r0]
148 mov pc, ip 148 adr r0, .Lftrace_stub
149ENDPROC(__gnu_mcount_nc) 149 cmp r0, r2
150 bne 1f
151 mcount_exit
150 152
151ENTRY(ftrace_caller) 1531: mcount_get_lr r1 @ lr of instrumented func
152 stmdb sp!, {r0-r3, lr} 154 mov r0, lr @ instrumented function
153 mov r0, lr 155 sub r0, r0, #MCOUNT_INSN_SIZE
156 adr lr, BSYM(2f)
157 mov pc, r2
1582: mcount_exit
159.endm
160
161.macro __ftrace_caller suffix
162 mcount_enter
163
164 mcount_get_lr r1 @ lr of instrumented func
165 mov r0, lr @ instrumented function
154 sub r0, r0, #MCOUNT_INSN_SIZE 166 sub r0, r0, #MCOUNT_INSN_SIZE
155 ldr r1, [sp, #20]
156 167
157 .global ftrace_call 168 .globl ftrace_call\suffix
158ftrace_call: 169ftrace_call\suffix:
159 bl ftrace_stub 170 bl ftrace_stub
160 ldmia sp!, {r0-r3, ip, lr} 171
161 mov pc, ip 172 mcount_exit
162ENDPROC(ftrace_caller) 173.endm
163 174
164#ifdef CONFIG_OLD_MCOUNT 175#ifdef CONFIG_OLD_MCOUNT
176/*
177 * mcount
178 */
179
180.macro mcount_enter
181 stmdb sp!, {r0-r3, lr}
182.endm
183
184.macro mcount_get_lr reg
185 ldr \reg, [fp, #-4]
186.endm
187
188.macro mcount_exit
189 ldr lr, [fp, #-4]
190 ldmia sp!, {r0-r3, pc}
191.endm
192
165ENTRY(mcount) 193ENTRY(mcount)
194#ifdef CONFIG_DYNAMIC_FTRACE
166 stmdb sp!, {lr} 195 stmdb sp!, {lr}
167 ldr lr, [fp, #-4] 196 ldr lr, [fp, #-4]
168 ldmia sp!, {pc} 197 ldmia sp!, {pc}
198#else
199 __mcount _old
200#endif
169ENDPROC(mcount) 201ENDPROC(mcount)
170 202
203#ifdef CONFIG_DYNAMIC_FTRACE
171ENTRY(ftrace_caller_old) 204ENTRY(ftrace_caller_old)
172 stmdb sp!, {r0-r3, lr} 205 __ftrace_caller _old
173 ldr r1, [fp, #-4]
174 mov r0, lr
175 sub r0, r0, #MCOUNT_INSN_SIZE
176
177 .globl ftrace_call_old
178ftrace_call_old:
179 bl ftrace_stub
180 ldr lr, [fp, #-4] @ restore lr
181 ldmia sp!, {r0-r3, pc}
182ENDPROC(ftrace_caller_old) 206ENDPROC(ftrace_caller_old)
183#endif 207#endif
184 208
185#else 209.purgem mcount_enter
210.purgem mcount_get_lr
211.purgem mcount_exit
212#endif
186 213
187ENTRY(__gnu_mcount_nc) 214/*
215 * __gnu_mcount_nc
216 */
217
218.macro mcount_enter
188 stmdb sp!, {r0-r3, lr} 219 stmdb sp!, {r0-r3, lr}
189 ldr r0, =ftrace_trace_function 220.endm
190 ldr r2, [r0] 221
191 adr r0, .Lftrace_stub 222.macro mcount_get_lr reg
192 cmp r0, r2 223 ldr \reg, [sp, #20]
193 bne gnu_trace 224.endm
225
226.macro mcount_exit
194 ldmia sp!, {r0-r3, ip, lr} 227 ldmia sp!, {r0-r3, ip, lr}
195 mov pc, ip 228 mov pc, ip
229.endm
196 230
197gnu_trace: 231ENTRY(__gnu_mcount_nc)
198 ldr r1, [sp, #20] @ lr of instrumented routine 232#ifdef CONFIG_DYNAMIC_FTRACE
199 mov r0, lr 233 mov ip, lr
200 sub r0, r0, #MCOUNT_INSN_SIZE 234 ldmia sp!, {lr}
201 adr lr, BSYM(1f)
202 mov pc, r2
2031:
204 ldmia sp!, {r0-r3, ip, lr}
205 mov pc, ip 235 mov pc, ip
236#else
237 __mcount
238#endif
206ENDPROC(__gnu_mcount_nc) 239ENDPROC(__gnu_mcount_nc)
207 240
208#ifdef CONFIG_OLD_MCOUNT 241#ifdef CONFIG_DYNAMIC_FTRACE
209/* 242ENTRY(ftrace_caller)
210 * This is under an ifdef in order to force link-time errors for people trying 243 __ftrace_caller
211 * to build with !FRAME_POINTER with a GCC which doesn't use the new-style 244ENDPROC(ftrace_caller)
212 * mcount.
213 */
214ENTRY(mcount)
215 stmdb sp!, {r0-r3, lr}
216 ldr r0, =ftrace_trace_function
217 ldr r2, [r0]
218 adr r0, ftrace_stub
219 cmp r0, r2
220 bne trace
221 ldr lr, [fp, #-4] @ restore lr
222 ldmia sp!, {r0-r3, pc}
223
224trace:
225 ldr r1, [fp, #-4] @ lr of instrumented routine
226 mov r0, lr
227 sub r0, r0, #MCOUNT_INSN_SIZE
228 mov lr, pc
229 mov pc, r2
230 ldr lr, [fp, #-4] @ restore lr
231 ldmia sp!, {r0-r3, pc}
232ENDPROC(mcount)
233#endif 245#endif
234 246
235#endif /* CONFIG_DYNAMIC_FTRACE */ 247.purgem mcount_enter
248.purgem mcount_get_lr
249.purgem mcount_exit
236 250
237ENTRY(ftrace_stub) 251ENTRY(ftrace_stub)
238.Lftrace_stub: 252.Lftrace_stub: