Skip to content

Commit e460ab2

Browse files
committed
sh: Fix up stack overflow check with ftrace disabled.
Presently the STACK_CHECK() code is called in to multiple times, although it's only necessary from the mcount entry. The code still attempts to treat the nop case as an ftrace path resulting in superfluous code flow for the case where ftrace is disabled. And finally, this also fixes up references to a few undefined symbols when FUNCTION_TRACER=n. Signed-off-by: Paul Mundt <lethal@linux-sh.org>
1 parent a470b95 commit e460ab2

1 file changed

Lines changed: 40 additions & 36 deletions

File tree

‎arch/sh/lib/mcount.S‎

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* arch/sh/lib/mcount.S
33
*
4-
* Copyright (C) 2008 Paul Mundt
4+
* Copyright (C) 2008, 2009 Paul Mundt
55
* Copyright (C) 2008, 2009 Matt Fleming
66
*
77
* This file is subject to the terms and conditions of the GNU General Public
@@ -86,13 +86,18 @@
8686
.type mcount,@function
8787
_mcount:
8888
mcount:
89+
STACK_CHECK()
90+
91+
#ifndef CONFIG_FUNCTION_TRACER
92+
rts
93+
nop
94+
#else
8995
#ifndef CONFIG_DYNAMIC_FTRACE
9096
mov.l .Lfunction_trace_stop, r0
9197
mov.l @r0, r0
9298
tst r0, r0
9399
bf ftrace_stub
94100
#endif
95-
STACK_CHECK()
96101

97102
MCOUNT_ENTER()
98103

@@ -174,8 +179,6 @@ ftrace_caller:
174179
tst r0, r0
175180
bf ftrace_stub
176181

177-
STACK_CHECK()
178-
179182
MCOUNT_ENTER()
180183

181184
.globl ftrace_call
@@ -211,38 +214,6 @@ ftrace_stub:
211214
rts
212215
nop
213216

214-
#ifdef CONFIG_STACK_DEBUG
215-
.globl stack_panic
216-
stack_panic:
217-
mov.l .Ldump_stack, r0
218-
jsr @r0
219-
nop
220-
221-
mov.l .Lpanic, r0
222-
jsr @r0
223-
mov.l .Lpanic_s, r4
224-
225-
rts
226-
nop
227-
228-
.align 2
229-
.L_ebss:
230-
.long _ebss
231-
.L_init_thread_union:
232-
.long init_thread_union
233-
.Lpanic:
234-
.long panic
235-
.Lpanic_s:
236-
.long .Lpanic_str
237-
.Ldump_stack:
238-
.long dump_stack
239-
240-
.section .rodata
241-
.align 2
242-
.Lpanic_str:
243-
.string "Stack error"
244-
#endif /* CONFIG_STACK_DEBUG */
245-
246217
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
247218
.globl ftrace_graph_caller
248219
ftrace_graph_caller:
@@ -304,3 +275,36 @@ return_to_handler:
304275
.Lftrace_return_to_handler:
305276
.long ftrace_return_to_handler
306277
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
278+
#endif /* CONFIG_FUNCTION_TRACER */
279+
280+
#ifdef CONFIG_STACK_DEBUG
281+
.globl stack_panic
282+
stack_panic:
283+
mov.l .Ldump_stack, r0
284+
jsr @r0
285+
nop
286+
287+
mov.l .Lpanic, r0
288+
jsr @r0
289+
mov.l .Lpanic_s, r4
290+
291+
rts
292+
nop
293+
294+
.align 2
295+
.L_ebss:
296+
.long _ebss
297+
.L_init_thread_union:
298+
.long init_thread_union
299+
.Lpanic:
300+
.long panic
301+
.Lpanic_s:
302+
.long .Lpanic_str
303+
.Ldump_stack:
304+
.long dump_stack
305+
306+
.section .rodata
307+
.align 2
308+
.Lpanic_str:
309+
.string "Stack error"
310+
#endif /* CONFIG_STACK_DEBUG */

0 commit comments

Comments
 (0)