1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #ifndef _ASM_S390_FTRACE_H 3 #define _ASM_S390_FTRACE_H 4 5 #define ARCH_SUPPORTS_FTRACE_OPS 1 6 #define MCOUNT_INSN_SIZE 6 7 8 #ifndef __ASSEMBLY__ 9 #include <asm/stacktrace.h> 10 11 static __always_inline unsigned long return_address(unsigned int n) 12 { 13 struct stack_frame *sf; 14 15 if (!n) 16 return (unsigned long)__builtin_return_address(0); 17 18 sf = (struct stack_frame *)current_frame_address(); 19 do { 20 sf = (struct stack_frame *)sf->back_chain; 21 if (!sf) 22 return 0; 23 } while (--n); 24 return sf->gprs[8]; 25 } 26 #define ftrace_return_address(n) return_address(n) 27 28 void ftrace_caller(void); 29 30 extern void *ftrace_func; 31 32 struct dyn_arch_ftrace { }; 33 34 #define MCOUNT_ADDR 0 35 #define FTRACE_ADDR ((unsigned long)ftrace_caller) 36 37 #define KPROBE_ON_FTRACE_NOP 0 38 #define KPROBE_ON_FTRACE_CALL 1 39 40 struct module; 41 struct dyn_ftrace; 42 43 bool ftrace_need_init_nop(void); 44 #define ftrace_need_init_nop ftrace_need_init_nop 45 46 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec); 47 #define ftrace_init_nop ftrace_init_nop 48 49 static inline unsigned long ftrace_call_adjust(unsigned long addr) 50 { 51 return addr; 52 } 53 54 struct ftrace_regs { 55 struct pt_regs regs; 56 }; 57 58 static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs) 59 { 60 struct pt_regs *regs = &fregs->regs; 61 62 if (test_pt_regs_flag(regs, PIF_FTRACE_FULL_REGS)) 63 return regs; 64 return NULL; 65 } 66 67 #ifdef CONFIG_FUNCTION_GRAPH_TRACER 68 struct fgraph_ret_regs { 69 unsigned long gpr2; 70 unsigned long fp; 71 }; 72 73 static __always_inline unsigned long fgraph_ret_regs_return_value(struct fgraph_ret_regs *ret_regs) 74 { 75 return ret_regs->gpr2; 76 } 77 78 static __always_inline unsigned long fgraph_ret_regs_frame_pointer(struct fgraph_ret_regs *ret_regs) 79 { 80 return ret_regs->fp; 81 } 82 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ 83 84 static __always_inline unsigned long 85 ftrace_regs_get_instruction_pointer(const struct ftrace_regs *fregs) 86 { 87 return fregs->regs.psw.addr; 88 } 89 90 static __always_inline void 91 ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs, 92 unsigned long ip) 93 { 94 fregs->regs.psw.addr = ip; 95 } 96 97 #define ftrace_regs_get_argument(fregs, n) \ 98 regs_get_kernel_argument(&(fregs)->regs, n) 99 #define ftrace_regs_get_stack_pointer(fregs) \ 100 kernel_stack_pointer(&(fregs)->regs) 101 #define ftrace_regs_return_value(fregs) \ 102 regs_return_value(&(fregs)->regs) 103 #define ftrace_regs_set_return_value(fregs, ret) \ 104 regs_set_return_value(&(fregs)->regs, ret) 105 #define ftrace_override_function_with_return(fregs) \ 106 override_function_with_return(&(fregs)->regs) 107 #define ftrace_regs_query_register_offset(name) \ 108 regs_query_register_offset(name) 109 110 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS 111 /* 112 * When an ftrace registered caller is tracing a function that is 113 * also set by a register_ftrace_direct() call, it needs to be 114 * differentiated in the ftrace_caller trampoline. To do this, 115 * place the direct caller in the ORIG_GPR2 part of pt_regs. This 116 * tells the ftrace_caller that there's a direct caller. 117 */ 118 static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, unsigned long addr) 119 { 120 struct pt_regs *regs = &fregs->regs; 121 regs->orig_gpr2 = addr; 122 } 123 #endif /* CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */ 124 125 /* 126 * Even though the system call numbers are identical for s390/s390x a 127 * different system call table is used for compat tasks. This may lead 128 * to e.g. incorrect or missing trace event sysfs files. 129 * Therefore simply do not trace compat system calls at all. 130 * See kernel/trace/trace_syscalls.c. 131 */ 132 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 133 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) 134 { 135 return is_compat_task(); 136 } 137 138 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME 139 static inline bool arch_syscall_match_sym_name(const char *sym, 140 const char *name) 141 { 142 /* 143 * Skip __s390_ and __s390x_ prefix - due to compat wrappers 144 * and aliasing some symbols of 64 bit system call functions 145 * may get the __s390_ prefix instead of the __s390x_ prefix. 146 */ 147 return !strcmp(sym + 7, name) || !strcmp(sym + 8, name); 148 } 149 150 #endif /* __ASSEMBLY__ */ 151 152 #ifdef CONFIG_FUNCTION_TRACER 153 154 #define FTRACE_NOP_INSN .word 0xc004, 0x0000, 0x0000 /* brcl 0,0 */ 155 156 #ifndef CC_USING_HOTPATCH 157 158 #define FTRACE_GEN_MCOUNT_RECORD(name) \ 159 .section __mcount_loc, "a", @progbits; \ 160 .quad name; \ 161 .previous; 162 163 #else /* !CC_USING_HOTPATCH */ 164 165 #define FTRACE_GEN_MCOUNT_RECORD(name) 166 167 #endif /* !CC_USING_HOTPATCH */ 168 169 #define FTRACE_GEN_NOP_ASM(name) \ 170 FTRACE_GEN_MCOUNT_RECORD(name) \ 171 FTRACE_NOP_INSN 172 173 #else /* CONFIG_FUNCTION_TRACER */ 174 175 #define FTRACE_GEN_NOP_ASM(name) 176 177 #endif /* CONFIG_FUNCTION_TRACER */ 178 179 #endif /* _ASM_S390_FTRACE_H */ 180
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.