Skip to content

Commit

Permalink
sh: Fix up stack overflow check with ftrace disabled.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Paul Mundt committed Jul 11, 2009
1 parent a470b95 commit e460ab2
Showing 1 changed file with 40 additions and 36 deletions.
76 changes: 40 additions & 36 deletions arch/sh/lib/mcount.S
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* arch/sh/lib/mcount.S
*
* Copyright (C) 2008 Paul Mundt
* Copyright (C) 2008, 2009 Paul Mundt
* Copyright (C) 2008, 2009 Matt Fleming
*
* This file is subject to the terms and conditions of the GNU General Public
Expand Down Expand Up @@ -86,13 +86,18 @@
.type mcount,@function
_mcount:
mcount:
STACK_CHECK()

#ifndef CONFIG_FUNCTION_TRACER
rts
nop
#else
#ifndef CONFIG_DYNAMIC_FTRACE
mov.l .Lfunction_trace_stop, r0
mov.l @r0, r0
tst r0, r0
bf ftrace_stub
#endif
STACK_CHECK()

MCOUNT_ENTER()

Expand Down Expand Up @@ -174,8 +179,6 @@ ftrace_caller:
tst r0, r0
bf ftrace_stub

STACK_CHECK()

MCOUNT_ENTER()

.globl ftrace_call
Expand Down Expand Up @@ -211,38 +214,6 @@ ftrace_stub:
rts
nop

#ifdef CONFIG_STACK_DEBUG
.globl stack_panic
stack_panic:
mov.l .Ldump_stack, r0
jsr @r0
nop

mov.l .Lpanic, r0
jsr @r0
mov.l .Lpanic_s, r4

rts
nop

.align 2
.L_ebss:
.long _ebss
.L_init_thread_union:
.long init_thread_union
.Lpanic:
.long panic
.Lpanic_s:
.long .Lpanic_str
.Ldump_stack:
.long dump_stack

.section .rodata
.align 2
.Lpanic_str:
.string "Stack error"
#endif /* CONFIG_STACK_DEBUG */

#ifdef CONFIG_FUNCTION_GRAPH_TRACER
.globl ftrace_graph_caller
ftrace_graph_caller:
Expand Down Expand Up @@ -304,3 +275,36 @@ return_to_handler:
.Lftrace_return_to_handler:
.long ftrace_return_to_handler
#endif /* CONFIG_FUNCTION_GRAPH_TRACER */
#endif /* CONFIG_FUNCTION_TRACER */

#ifdef CONFIG_STACK_DEBUG
.globl stack_panic
stack_panic:
mov.l .Ldump_stack, r0
jsr @r0
nop

mov.l .Lpanic, r0
jsr @r0
mov.l .Lpanic_s, r4

rts
nop

.align 2
.L_ebss:
.long _ebss
.L_init_thread_union:
.long init_thread_union
.Lpanic:
.long panic
.Lpanic_s:
.long .Lpanic_str
.Ldump_stack:
.long dump_stack

.section .rodata
.align 2
.Lpanic_str:
.string "Stack error"
#endif /* CONFIG_STACK_DEBUG */

0 comments on commit e460ab2

Please sign in to comment.