treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152
[linux-block.git] / arch / powerpc / kernel / trace / ftrace_64_pg.S
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Split from ftrace_64.S
4  */
5
6 #include <linux/magic.h>
7 #include <asm/ppc_asm.h>
8 #include <asm/asm-offsets.h>
9 #include <asm/ftrace.h>
10 #include <asm/ppc-opcode.h>
11 #include <asm/export.h>
12
13 _GLOBAL_TOC(ftrace_caller)
14         lbz     r3, PACA_FTRACE_ENABLED(r13)
15         cmpdi   r3, 0
16         beqlr
17
18         /* Taken from output of objdump from lib64/glibc */
19         mflr    r3
20         ld      r11, 0(r1)
21         stdu    r1, -112(r1)
22         std     r3, 128(r1)
23         ld      r4, 16(r11)
24         subi    r3, r3, MCOUNT_INSN_SIZE
25 .globl ftrace_call
26 ftrace_call:
27         bl      ftrace_stub
28         nop
29 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
30 .globl ftrace_graph_call
31 ftrace_graph_call:
32         b       ftrace_graph_stub
33 _GLOBAL(ftrace_graph_stub)
34 #endif
35         ld      r0, 128(r1)
36         mtlr    r0
37         addi    r1, r1, 112
38
39 _GLOBAL(ftrace_stub)
40         blr
41
42 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
43 _GLOBAL(ftrace_graph_caller)
44         /* load r4 with local address */
45         ld      r4, 128(r1)
46         subi    r4, r4, MCOUNT_INSN_SIZE
47
48         /* Grab the LR out of the caller stack frame */
49         ld      r11, 112(r1)
50         ld      r3, 16(r11)
51
52         bl      prepare_ftrace_return
53         nop
54
55         /*
56          * prepare_ftrace_return gives us the address we divert to.
57          * Change the LR in the callers stack frame to this.
58          */
59         ld      r11, 112(r1)
60         std     r3, 16(r11)
61
62         ld      r0, 128(r1)
63         mtlr    r0
64         addi    r1, r1, 112
65         blr
66 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */