xref: /openbmc/linux/arch/s390/include/asm/ftrace.h (revision e825b29a)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_S390_FTRACE_H
3 #define _ASM_S390_FTRACE_H
4 
5 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
6 #define ARCH_SUPPORTS_FTRACE_OPS 1
7 #define MCOUNT_INSN_SIZE	6
8 
9 #ifndef __ASSEMBLY__
10 
11 #ifdef CONFIG_CC_IS_CLANG
12 /* https://bugs.llvm.org/show_bug.cgi?id=41424 */
13 #define ftrace_return_address(n) 0UL
14 #else
15 #define ftrace_return_address(n) __builtin_return_address(n)
16 #endif
17 
18 void ftrace_caller(void);
19 
20 extern char ftrace_graph_caller_end;
21 extern void *ftrace_func;
22 
23 struct dyn_arch_ftrace { };
24 
25 #define MCOUNT_ADDR 0
26 #define FTRACE_ADDR ((unsigned long)ftrace_caller)
27 
28 #define KPROBE_ON_FTRACE_NOP	0
29 #define KPROBE_ON_FTRACE_CALL	1
30 
31 struct module;
32 struct dyn_ftrace;
33 
34 bool ftrace_need_init_nop(void);
35 #define ftrace_need_init_nop ftrace_need_init_nop
36 
37 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
38 #define ftrace_init_nop ftrace_init_nop
39 
40 static inline unsigned long ftrace_call_adjust(unsigned long addr)
41 {
42 	return addr;
43 }
44 
45 /*
46  * Even though the system call numbers are identical for s390/s390x a
47  * different system call table is used for compat tasks. This may lead
48  * to e.g. incorrect or missing trace event sysfs files.
49  * Therefore simply do not trace compat system calls at all.
50  * See kernel/trace/trace_syscalls.c.
51  */
52 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
53 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
54 {
55 	return is_compat_task();
56 }
57 
58 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
59 static inline bool arch_syscall_match_sym_name(const char *sym,
60 					       const char *name)
61 {
62 	/*
63 	 * Skip __s390_ and __s390x_ prefix - due to compat wrappers
64 	 * and aliasing some symbols of 64 bit system call functions
65 	 * may get the __s390_ prefix instead of the __s390x_ prefix.
66 	 */
67 	return !strcmp(sym + 7, name) || !strcmp(sym + 8, name);
68 }
69 
70 #endif /* __ASSEMBLY__ */
71 #endif /* _ASM_S390_FTRACE_H */
72