GNU Linux-libre 4.19.268-gnu1
[releases.git] / arch / powerpc / kernel / trace / ftrace_64_pg.S
1 /*
2  * Split from ftrace_64.S
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version
7  * 2 of the License, or (at your option) any later version.
8  */
9
10 #include <linux/magic.h>
11 #include <asm/ppc_asm.h>
12 #include <asm/asm-offsets.h>
13 #include <asm/ftrace.h>
14 #include <asm/ppc-opcode.h>
15 #include <asm/export.h>
16
17 _GLOBAL_TOC(ftrace_caller)
18         lbz     r3, PACA_FTRACE_ENABLED(r13)
19         cmpdi   r3, 0
20         beqlr
21
22         /* Taken from output of objdump from lib64/glibc */
23         mflr    r3
24         ld      r11, 0(r1)
25         stdu    r1, -112(r1)
26         std     r3, 128(r1)
27         ld      r4, 16(r11)
28         subi    r3, r3, MCOUNT_INSN_SIZE
29 .globl ftrace_call
30 ftrace_call:
31         bl      ftrace_stub
32         nop
33 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
34 .globl ftrace_graph_call
35 ftrace_graph_call:
36         b       ftrace_graph_stub
37 _GLOBAL(ftrace_graph_stub)
38 #endif
39         ld      r0, 128(r1)
40         mtlr    r0
41         addi    r1, r1, 112
42
43 _GLOBAL(ftrace_stub)
44         blr
45
46 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
47 _GLOBAL(ftrace_graph_caller)
48         /* load r4 with local address */
49         ld      r4, 128(r1)
50         subi    r4, r4, MCOUNT_INSN_SIZE
51
52         /* Grab the LR out of the caller stack frame */
53         ld      r11, 112(r1)
54         ld      r3, 16(r11)
55
56         bl      prepare_ftrace_return
57         nop
58
59         /*
60          * prepare_ftrace_return gives us the address we divert to.
61          * Change the LR in the callers stack frame to this.
62          */
63         ld      r11, 112(r1)
64         std     r3, 16(r11)
65
66         ld      r0, 128(r1)
67         mtlr    r0
68         addi    r1, r1, 112
69         blr
70 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */