2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com)
|
|
|
|
*
|
|
|
|
* This file implements mcount(), which is used to collect profiling data.
|
|
|
|
* This can also be tweaked for kernel stack overflow detection.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/linkage.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is the main variant and is called by C code. GCC's -pg option
|
|
|
|
* automatically instruments every C function with a call to this.
|
|
|
|
*/
|
|
|
|
|
|
|
|
.text
|
2008-05-13 23:06:59 -06:00
|
|
|
.align 32
|
|
|
|
.globl _mcount
|
|
|
|
.type _mcount,#function
|
|
|
|
.globl mcount
|
|
|
|
.type mcount,#function
|
2005-04-16 16:20:36 -06:00
|
|
|
_mcount:
|
2008-05-13 23:06:59 -06:00
|
|
|
mcount:
|
2008-10-06 17:06:12 -06:00
|
|
|
#ifdef CONFIG_FUNCTION_TRACER
|
2008-05-13 23:06:59 -06:00
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
2010-04-12 23:35:24 -06:00
|
|
|
/* Do nothing, the retl/nop below is all we need. */
|
2008-05-13 23:06:59 -06:00
|
|
|
#else
|
2010-04-12 23:35:24 -06:00
|
|
|
sethi %hi(function_trace_stop), %g1
|
|
|
|
lduw [%g1 + %lo(function_trace_stop)], %g2
|
2010-04-07 05:41:33 -06:00
|
|
|
brnz,pn %g2, 2f
|
2010-04-12 23:35:24 -06:00
|
|
|
sethi %hi(ftrace_trace_function), %g1
|
2008-05-13 23:06:59 -06:00
|
|
|
sethi %hi(ftrace_stub), %g2
|
|
|
|
ldx [%g1 + %lo(ftrace_trace_function)], %g1
|
|
|
|
or %g2, %lo(ftrace_stub), %g2
|
|
|
|
cmp %g1, %g2
|
|
|
|
be,pn %icc, 1f
|
2010-04-07 05:41:33 -06:00
|
|
|
mov %i7, %g3
|
2010-04-13 19:59:02 -06:00
|
|
|
save %sp, -176, %sp
|
2010-04-07 05:41:33 -06:00
|
|
|
mov %g3, %o1
|
2010-04-06 20:59:46 -06:00
|
|
|
jmpl %g1, %o7
|
|
|
|
mov %i7, %o0
|
|
|
|
ret
|
|
|
|
restore
|
2008-05-13 23:06:59 -06:00
|
|
|
/* not reached */
|
|
|
|
1:
|
2010-04-07 05:41:33 -06:00
|
|
|
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
|
|
sethi %hi(ftrace_graph_return), %g1
|
|
|
|
ldx [%g1 + %lo(ftrace_graph_return)], %g3
|
|
|
|
cmp %g2, %g3
|
|
|
|
bne,pn %xcc, 5f
|
|
|
|
sethi %hi(ftrace_graph_entry_stub), %g2
|
|
|
|
sethi %hi(ftrace_graph_entry), %g1
|
|
|
|
or %g2, %lo(ftrace_graph_entry_stub), %g2
|
|
|
|
ldx [%g1 + %lo(ftrace_graph_entry)], %g1
|
|
|
|
cmp %g1, %g2
|
|
|
|
be,pt %xcc, 2f
|
|
|
|
nop
|
|
|
|
5: mov %i7, %g2
|
|
|
|
mov %fp, %g3
|
2010-04-13 19:59:02 -06:00
|
|
|
save %sp, -176, %sp
|
2010-04-07 05:41:33 -06:00
|
|
|
mov %g2, %l0
|
|
|
|
ba,pt %xcc, ftrace_graph_caller
|
|
|
|
mov %g3, %l1
|
|
|
|
#endif
|
|
|
|
2:
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
2008-05-13 23:06:59 -06:00
|
|
|
#endif
|
|
|
|
retl
|
2005-04-16 16:20:36 -06:00
|
|
|
nop
|
2008-05-13 23:06:59 -06:00
|
|
|
.size _mcount,.-_mcount
|
|
|
|
.size mcount,.-mcount
|
|
|
|
|
2008-10-06 17:06:12 -06:00
|
|
|
#ifdef CONFIG_FUNCTION_TRACER
|
2008-05-13 23:06:59 -06:00
|
|
|
.globl ftrace_stub
|
|
|
|
.type ftrace_stub,#function
|
|
|
|
ftrace_stub:
|
|
|
|
retl
|
|
|
|
nop
|
|
|
|
.size ftrace_stub,.-ftrace_stub
|
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
|
|
|
.globl ftrace_caller
|
|
|
|
.type ftrace_caller,#function
|
|
|
|
ftrace_caller:
|
2010-04-12 23:35:24 -06:00
|
|
|
sethi %hi(function_trace_stop), %g1
|
2010-04-06 20:59:46 -06:00
|
|
|
mov %i7, %g2
|
2010-04-07 05:41:33 -06:00
|
|
|
lduw [%g1 + %lo(function_trace_stop)], %g1
|
|
|
|
brnz,pn %g1, ftrace_stub
|
|
|
|
mov %fp, %g3
|
2010-04-13 19:59:02 -06:00
|
|
|
save %sp, -176, %sp
|
2010-04-06 20:59:46 -06:00
|
|
|
mov %g2, %o1
|
2010-04-07 05:41:33 -06:00
|
|
|
mov %g2, %l0
|
|
|
|
mov %g3, %l1
|
2008-05-13 23:06:59 -06:00
|
|
|
.globl ftrace_call
|
|
|
|
ftrace_call:
|
|
|
|
call ftrace_stub
|
2010-04-06 20:59:46 -06:00
|
|
|
mov %i7, %o0
|
2010-04-07 05:41:33 -06:00
|
|
|
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
|
|
.globl ftrace_graph_call
|
|
|
|
ftrace_graph_call:
|
|
|
|
call ftrace_stub
|
|
|
|
nop
|
|
|
|
#endif
|
2010-04-06 20:59:46 -06:00
|
|
|
ret
|
|
|
|
restore
|
2010-04-07 05:41:33 -06:00
|
|
|
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
|
|
.size ftrace_graph_call,.-ftrace_graph_call
|
|
|
|
#endif
|
2010-04-12 23:35:24 -06:00
|
|
|
.size ftrace_call,.-ftrace_call
|
2008-05-13 23:06:59 -06:00
|
|
|
.size ftrace_caller,.-ftrace_caller
|
|
|
|
#endif
|
|
|
|
#endif
|
2010-04-07 05:41:33 -06:00
|
|
|
|
|
|
|
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
|
|
|
|
ENTRY(ftrace_graph_caller)
|
|
|
|
mov %l0, %o0
|
|
|
|
mov %i7, %o1
|
|
|
|
call prepare_ftrace_return
|
|
|
|
mov %l1, %o2
|
|
|
|
ret
|
|
|
|
restore %o0, -8, %i7
|
|
|
|
END(ftrace_graph_caller)
|
|
|
|
|
|
|
|
ENTRY(return_to_handler)
|
2010-04-13 19:59:02 -06:00
|
|
|
save %sp, -176, %sp
|
2010-04-07 05:41:33 -06:00
|
|
|
call ftrace_return_to_handler
|
|
|
|
mov %fp, %o0
|
|
|
|
jmpl %o0 + 8, %g0
|
|
|
|
restore
|
|
|
|
END(return_to_handler)
|
|
|
|
#endif
|