1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_S390_FTRACE_H
3 #define _ASM_S390_FTRACE_H
5 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
6 #define ARCH_SUPPORTS_FTRACE_OPS 1
7 #define MCOUNT_INSN_SIZE 6
11 #ifdef CONFIG_CC_IS_CLANG
12 /* https://bugs.llvm.org/show_bug.cgi?id=41424 */
13 #define ftrace_return_address(n) 0UL
15 #define ftrace_return_address(n) __builtin_return_address(n)
18 void ftrace_caller(void);
20 extern void *ftrace_func;
22 struct dyn_arch_ftrace { };
25 #define FTRACE_ADDR ((unsigned long)ftrace_caller)
27 #define KPROBE_ON_FTRACE_NOP 0
28 #define KPROBE_ON_FTRACE_CALL 1
33 bool ftrace_need_init_nop(void);
34 #define ftrace_need_init_nop ftrace_need_init_nop
36 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
37 #define ftrace_init_nop ftrace_init_nop
39 static inline unsigned long ftrace_call_adjust(unsigned long addr)
48 static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
50 struct pt_regs *regs = &fregs->regs;
52 if (test_pt_regs_flag(regs, PIF_FTRACE_FULL_REGS))
57 static __always_inline unsigned long
58 ftrace_regs_get_instruction_pointer(const struct ftrace_regs *fregs)
60 return fregs->regs.psw.addr;
63 static __always_inline void
64 ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs,
67 fregs->regs.psw.addr = ip;
70 #define ftrace_regs_get_argument(fregs, n) \
71 regs_get_kernel_argument(&(fregs)->regs, n)
72 #define ftrace_regs_get_stack_pointer(fregs) \
73 kernel_stack_pointer(&(fregs)->regs)
74 #define ftrace_regs_return_value(fregs) \
75 regs_return_value(&(fregs)->regs)
76 #define ftrace_regs_set_return_value(fregs, ret) \
77 regs_set_return_value(&(fregs)->regs, ret)
78 #define ftrace_override_function_with_return(fregs) \
79 override_function_with_return(&(fregs)->regs)
80 #define ftrace_regs_query_register_offset(name) \
81 regs_query_register_offset(name)
83 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
85 * When an ftrace registered caller is tracing a function that is
86 * also set by a register_ftrace_direct() call, it needs to be
87 * differentiated in the ftrace_caller trampoline. To do this,
88 * place the direct caller in the ORIG_GPR2 part of pt_regs. This
89 * tells the ftrace_caller that there's a direct caller.
91 static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, unsigned long addr)
93 struct pt_regs *regs = &fregs->regs;
94 regs->orig_gpr2 = addr;
96 #endif /* CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */
99 * Even though the system call numbers are identical for s390/s390x a
100 * different system call table is used for compat tasks. This may lead
101 * to e.g. incorrect or missing trace event sysfs files.
102 * Therefore simply do not trace compat system calls at all.
103 * See kernel/trace/trace_syscalls.c.
105 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
106 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
108 return is_compat_task();
111 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
112 static inline bool arch_syscall_match_sym_name(const char *sym,
116 * Skip __s390_ and __s390x_ prefix - due to compat wrappers
117 * and aliasing some symbols of 64 bit system call functions
118 * may get the __s390_ prefix instead of the __s390x_ prefix.
120 return !strcmp(sym + 7, name) || !strcmp(sym + 8, name);
123 #endif /* __ASSEMBLY__ */
125 #ifdef CONFIG_FUNCTION_TRACER
127 #define FTRACE_NOP_INSN .word 0xc004, 0x0000, 0x0000 /* brcl 0,0 */
129 #ifndef CC_USING_HOTPATCH
131 #define FTRACE_GEN_MCOUNT_RECORD(name) \
132 .section __mcount_loc, "a", @progbits; \
136 #else /* !CC_USING_HOTPATCH */
138 #define FTRACE_GEN_MCOUNT_RECORD(name)
140 #endif /* !CC_USING_HOTPATCH */
142 #define FTRACE_GEN_NOP_ASM(name) \
143 FTRACE_GEN_MCOUNT_RECORD(name) \
146 #else /* CONFIG_FUNCTION_TRACER */
148 #define FTRACE_GEN_NOP_ASM(name)
150 #endif /* CONFIG_FUNCTION_TRACER */
152 #endif /* _ASM_S390_FTRACE_H */