Skip to content

Commit 5eff5db

Browse files
neocturnegregkh
authored andcommitted
mips: ftrace: fix static function graph tracing
commit 6fb8656 upstream. ftrace_graph_caller was never run after calling ftrace_trace_function, breaking the function graph tracer. Fix this, bringing it in line with the x86 implementation. While we're at it, also streamline the control flow of _mcount a bit to reduce the number of branches. This issue was reported before: https://www.linux-mips.org/archives/linux-mips/2014-11/msg00295.html Signed-off-by: Matthias Schiffer <[email protected]> Tested-by: Matt Redfearn <[email protected]> Patchwork: https://patchwork.linux-mips.org/patch/18929/ Signed-off-by: Paul Burton <[email protected]> Cc: [email protected] # v3.17+ Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 5f7a15a commit 5eff5db

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

arch/mips/kernel/mcount.S

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,20 @@ NESTED(_mcount, PT_SIZE, ra)
119119
EXPORT_SYMBOL(_mcount)
120120
PTR_LA t1, ftrace_stub
121121
PTR_L t2, ftrace_trace_function /* Prepare t2 for (1) */
122-
bne t1, t2, static_trace
122+
beq t1, t2, fgraph_trace
123123
nop
124124

125+
MCOUNT_SAVE_REGS
126+
127+
move a0, ra /* arg1: self return address */
128+
jalr t2 /* (1) call *ftrace_trace_function */
129+
move a1, AT /* arg2: parent's return address */
130+
131+
MCOUNT_RESTORE_REGS
132+
133+
fgraph_trace:
125134
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
135+
PTR_LA t1, ftrace_stub
126136
PTR_L t3, ftrace_graph_return
127137
bne t1, t3, ftrace_graph_caller
128138
nop
@@ -131,24 +141,11 @@ EXPORT_SYMBOL(_mcount)
131141
bne t1, t3, ftrace_graph_caller
132142
nop
133143
#endif
134-
b ftrace_stub
135-
#ifdef CONFIG_32BIT
136-
addiu sp, sp, 8
137-
#else
138-
nop
139-
#endif
140144

141-
static_trace:
142-
MCOUNT_SAVE_REGS
143-
144-
move a0, ra /* arg1: self return address */
145-
jalr t2 /* (1) call *ftrace_trace_function */
146-
move a1, AT /* arg2: parent's return address */
147-
148-
MCOUNT_RESTORE_REGS
149145
#ifdef CONFIG_32BIT
150146
addiu sp, sp, 8
151147
#endif
148+
152149
.globl ftrace_stub
153150
ftrace_stub:
154151
RETURN_BACK

0 commit comments

Comments
 (0)