Linux Audio

Check our new training course

Loading...
v6.2
  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
 18void ftrace_caller(void);
 19
 
 
 20extern void *ftrace_func;
 21
 22struct dyn_arch_ftrace { };
 23
 24#define MCOUNT_ADDR 0
 25#define FTRACE_ADDR ((unsigned long)ftrace_caller)
 26
 27#define KPROBE_ON_FTRACE_NOP	0
 28#define KPROBE_ON_FTRACE_CALL	1
 29
 30struct module;
 31struct dyn_ftrace;
 32
 33bool ftrace_need_init_nop(void);
 34#define ftrace_need_init_nop ftrace_need_init_nop
 35
 36int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
 37#define ftrace_init_nop ftrace_init_nop
 38
 39static inline unsigned long ftrace_call_adjust(unsigned long addr)
 40{
 41	return addr;
 42}
 43
 44struct ftrace_regs {
 45	struct pt_regs regs;
 46};
 
 47
 48static __always_inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
 49{
 50	struct pt_regs *regs = &fregs->regs;
 51
 52	if (test_pt_regs_flag(regs, PIF_FTRACE_FULL_REGS))
 53		return regs;
 54	return NULL;
 55}
 56
 57static __always_inline unsigned long
 58ftrace_regs_get_instruction_pointer(const struct ftrace_regs *fregs)
 59{
 60	return fregs->regs.psw.addr;
 
 
 
 
 61}
 62
 63static __always_inline void
 64ftrace_regs_set_instruction_pointer(struct ftrace_regs *fregs,
 65				    unsigned long ip)
 66{
 67	fregs->regs.psw.addr = ip;
 68}
 69
 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)
 82
 83#ifdef CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS
 84/*
 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.
 90 */
 91static inline void arch_ftrace_set_direct_caller(struct ftrace_regs *fregs, unsigned long addr)
 92{
 93	struct pt_regs *regs = &fregs->regs;
 94	regs->orig_gpr2 = addr;
 95}
 96#endif /* CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS */
 97
 98/*
 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.
104 */
105#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
106static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
107{
108	return is_compat_task();
109}
110
111#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
112static inline bool arch_syscall_match_sym_name(const char *sym,
113					       const char *name)
114{
115	/*
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.
119	 */
120	return !strcmp(sym + 7, name) || !strcmp(sym + 8, name);
121}
122
123#endif /* __ASSEMBLY__ */
124
125#ifdef CONFIG_FUNCTION_TRACER
126
127#define FTRACE_NOP_INSN .word 0xc004, 0x0000, 0x0000 /* brcl 0,0 */
128
129#ifndef CC_USING_HOTPATCH
130
131#define FTRACE_GEN_MCOUNT_RECORD(name)		\
132	.section __mcount_loc, "a", @progbits;	\
133	.quad name;				\
134	.previous;
135
136#else /* !CC_USING_HOTPATCH */
137
138#define FTRACE_GEN_MCOUNT_RECORD(name)
139
140#endif /* !CC_USING_HOTPATCH */
141
142#define FTRACE_GEN_NOP_ASM(name)		\
143	FTRACE_GEN_MCOUNT_RECORD(name)		\
144	FTRACE_NOP_INSN
145
146#else /* CONFIG_FUNCTION_TRACER */
147
148#define FTRACE_GEN_NOP_ASM(name)
149
150#endif /* CONFIG_FUNCTION_TRACER */
151
152#endif /* _ASM_S390_FTRACE_H */
v5.14.15
  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
 18void ftrace_caller(void);
 19
 20extern char ftrace_graph_caller_end;
 21extern unsigned long ftrace_plt;
 22extern void *ftrace_func;
 23
 24struct dyn_arch_ftrace { };
 25
 26#define MCOUNT_ADDR 0
 27#define FTRACE_ADDR ((unsigned long)ftrace_caller)
 28
 29#define KPROBE_ON_FTRACE_NOP	0
 30#define KPROBE_ON_FTRACE_CALL	1
 31
 32struct module;
 33struct dyn_ftrace;
 34/*
 35 * Either -mhotpatch or -mnop-mcount is used - no explicit init is required
 36 */
 37static inline int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec) { return 0; }
 
 38#define ftrace_init_nop ftrace_init_nop
 39
 40static inline unsigned long ftrace_call_adjust(unsigned long addr)
 41{
 42	return addr;
 43}
 44
 45struct ftrace_insn {
 46	u16 opc;
 47	s32 disp;
 48} __packed;
 49
 50static inline void ftrace_generate_nop_insn(struct ftrace_insn *insn)
 51{
 52#ifdef CONFIG_FUNCTION_TRACER
 53	/* brcl 0,0 */
 54	insn->opc = 0xc004;
 55	insn->disp = 0;
 56#endif
 57}
 58
 59static inline int is_ftrace_nop(struct ftrace_insn *insn)
 
 60{
 61#ifdef CONFIG_FUNCTION_TRACER
 62	if (insn->disp == 0)
 63		return 1;
 64#endif
 65	return 0;
 66}
 67
 68static inline void ftrace_generate_call_insn(struct ftrace_insn *insn,
 69					     unsigned long ip)
 
 70{
 71#ifdef CONFIG_FUNCTION_TRACER
 72	unsigned long target;
 
 
 
 
 
 
 
 
 
 
 
 
 
 73
 74	/* brasl r0,ftrace_caller */
 75	target = is_module_addr((void *) ip) ? ftrace_plt : FTRACE_ADDR;
 76	insn->opc = 0xc005;
 77	insn->disp = (target - ip) / 2;
 78#endif
 
 
 
 
 
 
 
 79}
 
 80
 81/*
 82 * Even though the system call numbers are identical for s390/s390x a
 83 * different system call table is used for compat tasks. This may lead
 84 * to e.g. incorrect or missing trace event sysfs files.
 85 * Therefore simply do not trace compat system calls at all.
 86 * See kernel/trace/trace_syscalls.c.
 87 */
 88#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS
 89static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
 90{
 91	return is_compat_task();
 92}
 93
 94#define ARCH_HAS_SYSCALL_MATCH_SYM_NAME
 95static inline bool arch_syscall_match_sym_name(const char *sym,
 96					       const char *name)
 97{
 98	/*
 99	 * Skip __s390_ and __s390x_ prefix - due to compat wrappers
100	 * and aliasing some symbols of 64 bit system call functions
101	 * may get the __s390_ prefix instead of the __s390x_ prefix.
102	 */
103	return !strcmp(sym + 7, name) || !strcmp(sym + 8, name);
104}
105
106#endif /* __ASSEMBLY__ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107#endif /* _ASM_S390_FTRACE_H */