Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef _ASM_S390_FTRACE_H
0003 #define _ASM_S390_FTRACE_H
0004 
0005 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
0006 #define ARCH_SUPPORTS_FTRACE_OPS 1
0007 #define MCOUNT_INSN_SIZE    6
0008 
0009 #ifndef __ASSEMBLY__
0010 
0011 #ifdef CONFIG_CC_IS_CLANG
0012 /* https://bugs.llvm.org/show_bug.cgi?id=41424 */
0013 #define ftrace_return_address(n) 0UL
0014 #else
0015 #define ftrace_return_address(n) __builtin_return_address(n)
0016 #endif
0017 
0018 void ftrace_caller(void);
0019 
0020 extern void *ftrace_func;
0021 
0022 struct dyn_arch_ftrace { };
0023 
0024 #define MCOUNT_ADDR 0
0025 #define FTRACE_ADDR ((unsigned long)ftrace_caller)
0026 
0027 #define KPROBE_ON_FTRACE_NOP    0
0028 #define KPROBE_ON_FTRACE_CALL   1
0029 
0030 struct module;
0031 struct dyn_ftrace;
0032 
0033 bool ftrace_need_init_nop(void);
0034 #define ftrace_need_init_nop ftrace_need_init_nop
0035 
0036 int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
0037 #define ftrace_init_nop ftrace_init_nop
0038 
0039 static inline unsigned long ftrace_call_adjust(unsigned long addr)
0040 {
0041     return addr;
0042 }
0043 
0044 struct ftrace_regs {
0045     struct pt_regs regs;
0046 };
0047 
0048 static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
0049 {
0050     struct pt_regs *regs = &fregs->regs;
0051 
0052     if (test_pt_regs_flag(regs, PIF_FTRACE_FULL_REGS))
0053         return regs;
0054     return NULL;
0055 }
0056 
0057 static __always_inline void ftrace_instruction_pointer_set(struct ftrace_regs *fregs,
0058                                unsigned long ip)
0059 {
0060     fregs->regs.psw.addr = ip;
0061 }
0062 
0063 /*
0064  * When an ftrace registered caller is tracing a function that is
0065  * also set by a register_ftrace_direct() call, it needs to be
0066  * differentiated in the ftrace_caller trampoline. To do this,
0067  * place the direct caller in the ORIG_GPR2 part of pt_regs. This
0068  * tells the ftrace_caller that there's a direct caller.
0069  */
0070 static inline void arch_ftrace_set_direct_caller(struct pt_regs *regs, unsigned long addr)
0071 {
0072     regs->orig_gpr2 = addr;
0073 }
0074 
0075 /*
0076  * Even though the system call numbers are identical for s390/s390x a
0077  * different system call table is used for compat tasks. This may lead
0078  * to e.g. incorrect or missing trace event sysfs files.
0079  * Therefore simply do not trace compat system calls at all.
0080  * See kernel/trace/trace_syscalls.c.
0081  */
0082 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
0083 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
0084 {
0085     return is_compat_task();
0086 }
0087 
0088 #define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
0089 static inline bool arch_syscall_match_sym_name(const char *sym,
0090                            const char *name)
0091 {
0092     /*
0093      * Skip __s390_ and __s390x_ prefix - due to compat wrappers
0094      * and aliasing some symbols of 64 bit system call functions
0095      * may get the __s390_ prefix instead of the __s390x_ prefix.
0096      */
0097     return !strcmp(sym + 7, name) || !strcmp(sym + 8, name);
0098 }
0099 
0100 #endif /* __ASSEMBLY__ */
0101 
0102 #ifdef CONFIG_FUNCTION_TRACER
0103 
0104 #define FTRACE_NOP_INSN .word 0xc004, 0x0000, 0x0000 /* brcl 0,0 */
0105 
0106 #ifndef CC_USING_HOTPATCH
0107 
0108 #define FTRACE_GEN_MCOUNT_RECORD(name)      \
0109     .section __mcount_loc, "a", @progbits;  \
0110     .quad name;             \
0111     .previous;
0112 
0113 #else /* !CC_USING_HOTPATCH */
0114 
0115 #define FTRACE_GEN_MCOUNT_RECORD(name)
0116 
0117 #endif /* !CC_USING_HOTPATCH */
0118 
0119 #define FTRACE_GEN_NOP_ASM(name)        \
0120     FTRACE_GEN_MCOUNT_RECORD(name)      \
0121     FTRACE_NOP_INSN
0122 
0123 #else /* CONFIG_FUNCTION_TRACER */
0124 
0125 #define FTRACE_GEN_NOP_ASM(name)
0126 
0127 #endif /* CONFIG_FUNCTION_TRACER */
0128 
0129 #endif /* _ASM_S390_FTRACE_H */