1
2
3
4
5
6
7
8
9 #include <linux/linkage.h>
10 #include <asm/asm-offsets.h>
11 #include <asm/ftrace.h>
12 #include <asm/nospec-insn.h>
13 #include <asm/ptrace.h>
14 #include <asm/export.h>
15
16 GEN_BR_THUNK %r1
17 GEN_BR_THUNK %r14
18
19 .section .kprobes.text, "ax"
20
21 ENTRY(ftrace_stub)
22 BR_EX %r14
23 ENDPROC(ftrace_stub)
24
25 #define STACK_FRAME_SIZE (STACK_FRAME_OVERHEAD + __PT_SIZE)
26 #define STACK_PTREGS (STACK_FRAME_OVERHEAD)
27 #define STACK_PTREGS_GPRS (STACK_PTREGS + __PT_GPRS)
28 #define STACK_PTREGS_PSW (STACK_PTREGS + __PT_PSW)
29 #ifdef __PACK_STACK
30
31 #define TRACED_FUNC_FRAME_SIZE 24
32 #else
33 #define TRACED_FUNC_FRAME_SIZE STACK_FRAME_OVERHEAD
34 #endif
35
36 ENTRY(_mcount)
37 BR_EX %r14
38 ENDPROC(_mcount)
39 EXPORT_SYMBOL(_mcount)
40
41 ENTRY(ftrace_caller)
42 .globl ftrace_regs_caller
43 .set ftrace_regs_caller,ftrace_caller
44 stg %r14,(__SF_GPRS+8*8)(%r15) # save traced function caller
45 lgr %r1,%r15
46 #if !(defined(CC_USING_HOTPATCH) || defined(CC_USING_NOP_MCOUNT))
47 aghi %r0,MCOUNT_RETURN_FIXUP
48 #endif
49
50 aghi %r15,-TRACED_FUNC_FRAME_SIZE
51 stg %r1,__SF_BACKCHAIN(%r15)
52 stg %r0,(__SF_GPRS+8*8)(%r15)
53 stg %r15,(__SF_GPRS+9*8)(%r15)
54
55 aghi %r15,-STACK_FRAME_SIZE
56 stg %r1,(STACK_PTREGS_GPRS+15*8)(%r15)
57 aghi %r1,-TRACED_FUNC_FRAME_SIZE
58 stg %r1,__SF_BACKCHAIN(%r15)
59 stg %r0,(STACK_PTREGS_PSW+8)(%r15)
60 stmg %r2,%r14,(STACK_PTREGS_GPRS+2*8)(%r15)
61 #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
62 aghik %r2,%r0,-MCOUNT_INSN_SIZE
63 lgrl %r4,function_trace_op
64 lgrl %r1,ftrace_trace_function
65 #else
66 lgr %r2,%r0
67 aghi %r2,-MCOUNT_INSN_SIZE
68 larl %r4,function_trace_op
69 lg %r4,0(%r4)
70 larl %r1,ftrace_trace_function
71 lg %r1,0(%r1)
72 #endif
73 lgr %r3,%r14
74 la %r5,STACK_PTREGS(%r15)
75 BASR_EX %r14,%r1
76 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
77
78
79 .globl ftrace_graph_caller
80 ftrace_graph_caller:
81 j ftrace_graph_caller_end
82 lmg %r2,%r3,(STACK_PTREGS_GPRS+14*8)(%r15)
83 lg %r4,(STACK_PTREGS_PSW+8)(%r15)
84 brasl %r14,prepare_ftrace_return
85 stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
86 ftrace_graph_caller_end:
87 .globl ftrace_graph_caller_end
88 #endif
89 lg %r1,(STACK_PTREGS_PSW+8)(%r15)
90 lmg %r2,%r15,(STACK_PTREGS_GPRS+2*8)(%r15)
91 BR_EX %r1
92 ENDPROC(ftrace_caller)
93
94 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
95
96 ENTRY(return_to_handler)
97 stmg %r2,%r5,32(%r15)
98 lgr %r1,%r15
99 aghi %r15,-STACK_FRAME_OVERHEAD
100 stg %r1,__SF_BACKCHAIN(%r15)
101 brasl %r14,ftrace_return_to_handler
102 aghi %r15,STACK_FRAME_OVERHEAD
103 lgr %r14,%r2
104 lmg %r2,%r5,32(%r15)
105 BR_EX %r14
106 ENDPROC(return_to_handler)
107
108 #endif