GNU Linux-libre 4.14.324-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 #ifdef CONFIG_DYNAMIC_FTRACE
18 _GLOBAL_TOC(ftrace_caller)
19         /* Taken from output of objdump from lib64/glibc */
20         mflr    r3
21         ld      r11, 0(r1)
22         stdu    r1, -112(r1)
23         std     r3, 128(r1)
24         ld      r4, 16(r11)
25         subi    r3, r3, MCOUNT_INSN_SIZE
26 .globl ftrace_call
27 ftrace_call:
28         bl      ftrace_stub
29         nop
30 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
31 .globl ftrace_graph_call
32 ftrace_graph_call:
33         b       ftrace_graph_stub
34 _GLOBAL(ftrace_graph_stub)
35 #endif
36         ld      r0, 128(r1)
37         mtlr    r0
38         addi    r1, r1, 112
39
40 _GLOBAL(ftrace_stub)
41         blr
42 #endif /* CONFIG_DYNAMIC_FTRACE */
43
44 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
45 _GLOBAL(ftrace_graph_caller)
46         /* load r4 with local address */
47         ld      r4, 128(r1)
48         subi    r4, r4, MCOUNT_INSN_SIZE
49
50         /* Grab the LR out of the caller stack frame */
51         ld      r11, 112(r1)
52         ld      r3, 16(r11)
53
54         bl      prepare_ftrace_return
55         nop
56
57         /*
58          * prepare_ftrace_return gives us the address we divert to.
59          * Change the LR in the callers stack frame to this.
60          */
61         ld      r11, 112(r1)
62         std     r3, 16(r11)
63
64         ld      r0, 128(r1)
65         mtlr    r0
66         addi    r1, r1, 112
67         blr
68 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */