1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2000 Anton Blanchard (anton@linuxcare.com)
5 * This file implements mcount(), which is used to collect profiling data.
6 * This can also be tweaked for kernel stack overflow detection.
9 #include <linux/linkage.h>
10 #include <asm/export.h>
13 * This is the main variant and is called by C code. GCC's -pg option
14 * automatically instruments every C function with a call to this.
20 .type _mcount,#function
21 EXPORT_SYMBOL(_mcount)
23 .type mcount,#function
26 #ifdef CONFIG_FUNCTION_TRACER
27 #ifdef CONFIG_DYNAMIC_FTRACE
28 /* Do nothing, the retl/nop below is all we need. */
30 sethi %hi(ftrace_trace_function), %g1
31 sethi %hi(ftrace_stub), %g2
32 ldx [%g1 + %lo(ftrace_trace_function)], %g1
33 or %g2, %lo(ftrace_stub), %g2
45 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
46 sethi %hi(ftrace_graph_return), %g1
47 ldx [%g1 + %lo(ftrace_graph_return)], %g3
50 sethi %hi(ftrace_graph_entry_stub), %g2
51 sethi %hi(ftrace_graph_entry), %g1
52 or %g2, %lo(ftrace_graph_entry_stub), %g2
53 ldx [%g1 + %lo(ftrace_graph_entry)], %g1
61 ba,pt %xcc, ftrace_graph_caller
69 .size _mcount,.-_mcount
72 #ifdef CONFIG_FUNCTION_TRACER
74 .type ftrace_stub,#function
78 .size ftrace_stub,.-ftrace_stub
79 #ifdef CONFIG_DYNAMIC_FTRACE
81 .type ftrace_caller,#function
93 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
94 .globl ftrace_graph_call
101 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
102 .size ftrace_graph_call,.-ftrace_graph_call
104 .size ftrace_call,.-ftrace_call
105 .size ftrace_caller,.-ftrace_caller
109 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
110 ENTRY(ftrace_graph_caller)
113 call prepare_ftrace_return
117 END(ftrace_graph_caller)
119 ENTRY(return_to_handler)
121 call ftrace_return_to_handler
125 END(return_to_handler)