GNU Linux-libre 4.19.264-gnu1
[releases.git] / arch / powerpc / kernel / trace / ftrace_64.S
1 /*
2  * Split from entry_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(mcount)
18 _GLOBAL(_mcount)
19 EXPORT_SYMBOL(_mcount)
20         mflr    r12
21         mtctr   r12
22         mtlr    r0
23         bctr
24
25 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
26 _GLOBAL(return_to_handler)
27         /* need to save return values */
28         std     r4,  -32(r1)
29         std     r3,  -24(r1)
30         /* save TOC */
31         std     r2,  -16(r1)
32         std     r31, -8(r1)
33         mr      r31, r1
34         stdu    r1, -112(r1)
35
36         /*
37          * We might be called from a module.
38          * Switch to our TOC to run inside the core kernel.
39          */
40         ld      r2, PACATOC(r13)
41
42         bl      ftrace_return_to_handler
43         nop
44
45         /* return value has real return address */
46         mtlr    r3
47
48         ld      r1, 0(r1)
49         ld      r4,  -32(r1)
50         ld      r3,  -24(r1)
51         ld      r2,  -16(r1)
52         ld      r31, -8(r1)
53
54         /* Jump back to real return address */
55         blr
56 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */