Skip to content

Commit 9aa791c

Browse files
richardweinbergerRussell King (Oracle)
authored andcommitted
ARM: 9457/1: ftrace: Implement HAVE_FUNCTION_GRAPH_FREGS
Enable support for ftrace's funcgraph-retval feature by capturing r0-r3 and fp. Since ARM does not provide its own __arch_ftrace_regs structure, we instead populate pt_regs with the registers required by ftrace. Cc: Donglin Peng <pengdonglin@sangfor.com.cn> Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
1 parent fb0e5f2 commit 9aa791c

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ config ARM
108108
select HAVE_GUP_FAST if ARM_LPAE
109109
select HAVE_FUNCTION_ERROR_INJECTION
110110
select HAVE_FUNCTION_GRAPH_TRACER
111+
select HAVE_FUNCTION_GRAPH_FREGS
111112
select HAVE_FUNCTION_TRACER if !XIP_KERNEL
112113
select HAVE_GCC_PLUGINS
113114
select HAVE_HW_BREAKPOINT if PERF_EVENTS && (CPU_V6 || CPU_V6K || CPU_V7)

arch/arm/kernel/entry-ftrace.S

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,21 @@ ENDPROC(ftrace_graph_regs_caller)
257257

258258
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
259259
ENTRY(return_to_handler)
260-
stmdb sp!, {r0-r3}
261-
add r0, sp, #16 @ sp at exit of instrumented routine
260+
mov ip, sp @ sp at exit of instrumented routine
261+
sub sp, #PT_REGS_SIZE
262+
str r0, [sp, #S_R0]
263+
str r1, [sp, #S_R1]
264+
str r2, [sp, #S_R2]
265+
str r3, [sp, #S_R3]
266+
str ip, [sp, #S_FP]
267+
mov r0, sp
262268
bl ftrace_return_to_handler
263-
mov lr, r0 @ r0 has real ret addr
264-
ldmia sp!, {r0-r3}
269+
mov lr, r0 @ r0 has real ret addr
270+
ldr r3, [sp, #S_R3]
271+
ldr r2, [sp, #S_R2]
272+
ldr r1, [sp, #S_R1]
273+
ldr r0, [sp, #S_R0]
274+
add sp, sp, #PT_REGS_SIZE @ restore stack pointer
265275
ret lr
266276
ENDPROC(return_to_handler)
267277
#endif

0 commit comments

Comments
 (0)