1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * Split from entry_32.S
6 #include <linux/magic.h>
8 #include <asm/ppc_asm.h>
9 #include <asm/asm-offsets.h>
10 #include <asm/ftrace.h>
11 #include <asm/export.h>
16 * It is required that _mcount on PPC32 must preserve the
17 * link register. But we have r0 to play with. We use r0
18 * to push the return address back to the caller of mcount
19 * into the ctr register, restore the link register and
20 * then jump back using the ctr register.
28 _GLOBAL(ftrace_caller)
30 /* r3 ends up with link register */
31 subi r3, r3, MCOUNT_INSN_SIZE
36 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
37 .globl ftrace_graph_call
40 _GLOBAL(ftrace_graph_stub)
43 /* old link register ends up in ctr reg */
46 EXPORT_SYMBOL(_mcount)
51 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
52 _GLOBAL(ftrace_graph_caller)
53 /* load r4 with local address */
55 subi r4, r4, MCOUNT_INSN_SIZE
57 /* Grab the LR out of the caller stack frame */
60 bl prepare_ftrace_return
64 * prepare_ftrace_return gives us the address we divert to.
65 * Change the LR in the callers stack frame to this.
70 /* old link register ends up in ctr reg */
73 _GLOBAL(return_to_handler)
74 /* need to save return values */
81 bl ftrace_return_to_handler
84 /* return value has real return address */
92 /* Jump back to real return address */
94 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */