~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/s390/kernel/mcount.S

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0 */
  2 /*
  3  * Copyright IBM Corp. 2008, 2009
  4  *
  5  */
  6 
  7 #include <linux/linkage.h>
  8 #include <asm/asm-offsets.h>
  9 #include <asm/ftrace.h>
 10 #include <asm/nospec-insn.h>
 11 #include <asm/ptrace.h>
 12 #include <asm/march.h>
 13 
 14 #define STACK_FRAME_SIZE_PTREGS         (STACK_FRAME_OVERHEAD + __PT_SIZE)
 15 #define STACK_PTREGS                    (STACK_FRAME_OVERHEAD)
 16 #define STACK_PTREGS_GPRS               (STACK_PTREGS + __PT_GPRS)
 17 #define STACK_PTREGS_PSW                (STACK_PTREGS + __PT_PSW)
 18 
 19 #define STACK_FRAME_SIZE_FREGS          (STACK_FRAME_OVERHEAD + __FTRACE_REGS_SIZE)
 20 #define STACK_FREGS                     (STACK_FRAME_OVERHEAD)
 21 #define STACK_FREGS_PTREGS              (STACK_FRAME_OVERHEAD + __FTRACE_REGS_PT_REGS)
 22 #define STACK_FREGS_PTREGS_GPRS         (STACK_FREGS_PTREGS + __PT_GPRS)
 23 #define STACK_FREGS_PTREGS_PSW          (STACK_FREGS_PTREGS + __PT_PSW)
 24 #define STACK_FREGS_PTREGS_ORIG_GPR2    (STACK_FREGS_PTREGS + __PT_ORIG_GPR2)
 25 #define STACK_FREGS_PTREGS_FLAGS        (STACK_FREGS_PTREGS + __PT_FLAGS)
 26 
 27 /* packed stack: allocate just enough for r14, r15 and backchain */
 28 #define TRACED_FUNC_FRAME_SIZE  24
 29 
 30 #ifdef CONFIG_FUNCTION_TRACER
 31 
 32         GEN_BR_THUNK %r1
 33         GEN_BR_THUNK %r14
 34 
 35         .section .kprobes.text, "ax"
 36 
 37 SYM_FUNC_START(ftrace_stub)
 38         BR_EX   %r14
 39 SYM_FUNC_END(ftrace_stub)
 40 
 41 SYM_CODE_START(ftrace_stub_direct_tramp)
 42         lgr     %r1, %r0
 43         BR_EX   %r1
 44 SYM_CODE_END(ftrace_stub_direct_tramp)
 45 
 46         .macro  ftrace_regs_entry, allregs=0
 47         stg     %r14,(__SF_GPRS+8*8)(%r15)      # save traced function caller
 48 
 49         .if \allregs == 1
 50         # save psw mask
 51         # don't put any instructions clobbering CC before this point
 52         epsw    %r1,%r14
 53         risbg   %r14,%r1,0,31,32
 54         .endif
 55 
 56         lgr     %r1,%r15
 57         # allocate stack frame for ftrace_caller to contain traced function
 58         aghi    %r15,-TRACED_FUNC_FRAME_SIZE
 59         stg     %r1,__SF_BACKCHAIN(%r15)
 60         stg     %r0,(__SF_GPRS+8*8)(%r15)
 61         stg     %r15,(__SF_GPRS+9*8)(%r15)
 62         # allocate ftrace_regs and stack frame for ftrace_trace_function
 63         aghi    %r15,-STACK_FRAME_SIZE_FREGS
 64         stg     %r1,(STACK_FREGS_PTREGS_GPRS+15*8)(%r15)
 65         xc      STACK_FREGS_PTREGS_ORIG_GPR2(8,%r15),STACK_FREGS_PTREGS_ORIG_GPR2(%r15)
 66 
 67         .if \allregs == 1
 68         stg     %r14,(STACK_FREGS_PTREGS_PSW)(%r15)
 69         mvghi   STACK_FREGS_PTREGS_FLAGS(%r15),_PIF_FTRACE_FULL_REGS
 70         .else
 71         xc      STACK_FREGS_PTREGS_FLAGS(8,%r15),STACK_FREGS_PTREGS_FLAGS(%r15)
 72         .endif
 73 
 74         lg      %r14,(__SF_GPRS+8*8)(%r1)       # restore original return address
 75         aghi    %r1,-TRACED_FUNC_FRAME_SIZE
 76         stg     %r1,__SF_BACKCHAIN(%r15)
 77         stg     %r0,(STACK_FREGS_PTREGS_PSW+8)(%r15)
 78         stmg    %r2,%r14,(STACK_FREGS_PTREGS_GPRS+2*8)(%r15)
 79         .endm
 80 
 81 SYM_CODE_START(ftrace_regs_caller)
 82         ftrace_regs_entry       1
 83         j       ftrace_common
 84 SYM_CODE_END(ftrace_regs_caller)
 85 
 86 SYM_CODE_START(ftrace_caller)
 87         ftrace_regs_entry       0
 88         j       ftrace_common
 89 SYM_CODE_END(ftrace_caller)
 90 
 91 SYM_CODE_START(ftrace_common)
 92 #ifdef MARCH_HAS_Z196_FEATURES
 93         aghik   %r2,%r0,-MCOUNT_INSN_SIZE
 94         lgrl    %r4,function_trace_op
 95         lgrl    %r1,ftrace_func
 96 #else
 97         lgr     %r2,%r0
 98         aghi    %r2,-MCOUNT_INSN_SIZE
 99         larl    %r4,function_trace_op
100         lg      %r4,0(%r4)
101         larl    %r1,ftrace_func
102         lg      %r1,0(%r1)
103 #endif
104         lgr     %r3,%r14
105         la      %r5,STACK_FREGS(%r15)
106         BASR_EX %r14,%r1
107 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
108 # The j instruction gets runtime patched to a nop instruction.
109 # See ftrace_enable_ftrace_graph_caller.
110 SYM_INNER_LABEL(ftrace_graph_caller, SYM_L_GLOBAL)
111         j       .Lftrace_graph_caller_end
112         lmg     %r2,%r3,(STACK_FREGS_PTREGS_GPRS+14*8)(%r15)
113         lg      %r4,(STACK_FREGS_PTREGS_PSW+8)(%r15)
114         brasl   %r14,prepare_ftrace_return
115         stg     %r2,(STACK_FREGS_PTREGS_GPRS+14*8)(%r15)
116 .Lftrace_graph_caller_end:
117 #endif
118         lg      %r0,(STACK_FREGS_PTREGS_PSW+8)(%r15)
119 #ifdef MARCH_HAS_Z196_FEATURES
120         ltg     %r1,STACK_FREGS_PTREGS_ORIG_GPR2(%r15)
121         locgrz  %r1,%r0
122 #else
123         lg      %r1,STACK_FREGS_PTREGS_ORIG_GPR2(%r15)
124         ltgr    %r1,%r1
125         jnz     0f
126         lgr     %r1,%r0
127 #endif
128 0:      lmg     %r2,%r15,(STACK_FREGS_PTREGS_GPRS+2*8)(%r15)
129         BR_EX   %r1
130 SYM_CODE_END(ftrace_common)
131 
132 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
133 
134 SYM_FUNC_START(return_to_handler)
135         stmg    %r2,%r5,32(%r15)
136         lgr     %r1,%r15
137         aghi    %r15,-(STACK_FRAME_OVERHEAD+__FGRAPH_RET_SIZE)
138         stg     %r1,__SF_BACKCHAIN(%r15)
139         la      %r3,STACK_FRAME_OVERHEAD(%r15)
140         stg     %r1,__FGRAPH_RET_FP(%r3)
141         stg     %r2,__FGRAPH_RET_GPR2(%r3)
142         lgr     %r2,%r3
143         brasl   %r14,ftrace_return_to_handler
144         aghi    %r15,STACK_FRAME_OVERHEAD+__FGRAPH_RET_SIZE
145         lgr     %r14,%r2
146         lmg     %r2,%r5,32(%r15)
147         BR_EX   %r14
148 SYM_FUNC_END(return_to_handler)
149 
150 #endif
151 #endif /* CONFIG_FUNCTION_TRACER */
152 
153 SYM_CODE_START(ftrace_shared_hotpatch_trampoline_br)
154         lmg     %r0,%r1,2(%r1)
155         br      %r1
156 SYM_INNER_LABEL(ftrace_shared_hotpatch_trampoline_br_end, SYM_L_GLOBAL)
157 SYM_CODE_END(ftrace_shared_hotpatch_trampoline_br)
158 
159 #ifdef CONFIG_EXPOLINE
160 SYM_CODE_START(ftrace_shared_hotpatch_trampoline_exrl)
161         lmg     %r0,%r1,2(%r1)
162         exrl    %r0,0f
163         j       .
164 0:      br      %r1
165 SYM_INNER_LABEL(ftrace_shared_hotpatch_trampoline_exrl_end, SYM_L_GLOBAL)
166 SYM_CODE_END(ftrace_shared_hotpatch_trampoline_exrl)
167 #endif /* CONFIG_EXPOLINE */
168 
169 #ifdef CONFIG_RETHOOK
170 
171 SYM_CODE_START(arch_rethook_trampoline)
172         stg     %r14,(__SF_GPRS+8*8)(%r15)
173         lay     %r15,-STACK_FRAME_SIZE_PTREGS(%r15)
174         stmg    %r0,%r14,STACK_PTREGS_GPRS(%r15)
175 
176         # store original stack pointer in backchain and pt_regs
177         lay     %r7,STACK_FRAME_SIZE_PTREGS(%r15)
178         stg     %r7,__SF_BACKCHAIN(%r15)
179         stg     %r7,STACK_PTREGS_GPRS+(15*8)(%r15)
180 
181         # store full psw
182         epsw    %r2,%r3
183         risbg   %r3,%r2,0,31,32
184         stg     %r3,STACK_PTREGS_PSW(%r15)
185         larl    %r1,arch_rethook_trampoline
186         stg     %r1,STACK_PTREGS_PSW+8(%r15)
187 
188         lay     %r2,STACK_PTREGS(%r15)
189         brasl   %r14,arch_rethook_trampoline_callback
190 
191         mvc     __SF_EMPTY(16,%r7),STACK_PTREGS_PSW(%r15)
192         lmg     %r0,%r15,STACK_PTREGS_GPRS(%r15)
193         lpswe   __SF_EMPTY(%r15)
194 SYM_CODE_END(arch_rethook_trampoline)
195 
196 #endif /* CONFIG_RETHOOK */

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php