1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_S390_FTRACE_H
3 #define _ASM_S390_FTRACE_H
5 #define ARCH_SUPPORTS_FTRACE_OPS 1
6 #define MCOUNT_INSN_SIZE 6
9 #include <asm/stacktrace.h>
11 static __always_inline unsigned long return_address(unsigned int n)
13 struct stack_frame *sf;
16 return (unsigned long)__builtin_return_address(0);
18 sf = (struct stack_frame *)current_frame_address();
20 sf = (struct stack_frame *)sf->back_chain;
26 #define ftrace_return_address(n) return_address(n)
28 void ftrace_caller(void);
30 extern void *ftrace_func;
32 struct dyn_arch_ftrace { };
35 #define FTRACE_ADDR ((unsigned long)ftrace_caller)
37 #define KPROBE_ON_FTRACE_NOP 0
38 #define KPROBE_ON_FTRACE_CALL 1
43 bool ftrace_need_init_nop(void);
44 #define ftrace_need_init_nop ftrace_need_init_nop
46 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
47 #define ftrace_init_nop ftrace_init_nop
49 static inline unsigned long ftrace_call_adjust(unsigned long addr)
54 #include <linux/ftrace_regs.h>
56 static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
58 struct pt_regs *regs = &arch_ftrace_regs(fregs)->regs;
60 if (test_pt_regs_flag(regs, PIF_FTRACE_FULL_REGS))
65 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
66 struct fgraph_ret_regs {
71 static __always_inline unsigned long fgraph_ret_regs_return_value(struct fgraph_ret_regs *ret_regs)
73 return ret_regs->gpr2;
76 static __always_inline unsigned long fgraph_ret_regs_frame_pointer(struct fgraph_ret_regs *ret_regs)
80 #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
82 static __always_inline void
83 ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs,
86 arch_ftrace_regs(fregs)->regs.psw.addr = ip;
89 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
91 * When an ftrace registered caller is tracing a function that is
92 * also set by a register_ftrace_direct() call, it needs to be
93 * differentiated in the ftrace_caller trampoline. To do this,
94 * place the direct caller in the ORIG_GPR2 part of pt_regs. This
95 * tells the ftrace_caller that there's a direct caller.
97 static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, unsigned long addr)
99 struct pt_regs *regs = &arch_ftrace_regs(fregs)->regs;
100 regs->orig_gpr2 = addr;
102 #endif /* CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */
105 * Even though the system call numbers are identical for s390/s390x a
106 * different system call table is used for compat tasks. This may lead
107 * to e.g. incorrect or missing trace event sysfs files.
108 * Therefore simply do not trace compat system calls at all.
109 * See kernel/trace/trace_syscalls.c.
111 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
112 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
114 return is_compat_task();
117 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
118 static inline bool arch_syscall_match_sym_name(const char *sym,
122 * Skip __s390_ and __s390x_ prefix - due to compat wrappers
123 * and aliasing some symbols of 64 bit system call functions
124 * may get the __s390_ prefix instead of the __s390x_ prefix.
126 return !strcmp(sym + 7, name) || !strcmp(sym + 8, name);
129 #endif /* __ASSEMBLY__ */
131 #ifdef CONFIG_FUNCTION_TRACER
133 #define FTRACE_NOP_INSN .word 0xc004, 0x0000, 0x0000 /* brcl 0,0 */
135 #ifndef CC_USING_HOTPATCH
137 #define FTRACE_GEN_MCOUNT_RECORD(name) \
138 .section __mcount_loc, "a", @progbits; \
142 #else /* !CC_USING_HOTPATCH */
144 #define FTRACE_GEN_MCOUNT_RECORD(name)
146 #endif /* !CC_USING_HOTPATCH */
148 #define FTRACE_GEN_NOP_ASM(name) \
149 FTRACE_GEN_MCOUNT_RECORD(name) \
152 #else /* CONFIG_FUNCTION_TRACER */
154 #define FTRACE_GEN_NOP_ASM(name)
156 #endif /* CONFIG_FUNCTION_TRACER */
158 #endif /* _ASM_S390_FTRACE_H */