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)
54 /* load r4 with local address */
56 subi r4, r4, MCOUNT_INSN_SIZE
58 /* Grab the LR out of the caller stack frame */
61 bl prepare_ftrace_return
65 * prepare_ftrace_return gives us the address we divert to.
66 * Change the LR in the callers stack frame to this.
71 /* old link register ends up in ctr reg */
74 _GLOBAL(return_to_handler)
75 /* need to save return values */
82 bl ftrace_return_to_handler
85 /* return value has real return address */
93 /* Jump back to real return address */
95 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */