xref: /openbmc/linux/arch/x86/include/asm/ftrace.h (revision 981ab3f1)
1 #ifndef _ASM_X86_FTRACE_H
2 #define _ASM_X86_FTRACE_H
3 
4 #ifdef CONFIG_FUNCTION_TRACER
5 #ifdef CC_USING_FENTRY
6 # define MCOUNT_ADDR		((unsigned long)(__fentry__))
7 #else
8 # define MCOUNT_ADDR		((unsigned long)(mcount))
9 # define HAVE_FUNCTION_GRAPH_FP_TEST
10 #endif
11 #define MCOUNT_INSN_SIZE	5 /* sizeof mcount call */
12 
13 #ifdef CONFIG_DYNAMIC_FTRACE
14 #define ARCH_SUPPORTS_FTRACE_OPS 1
15 #endif
16 
17 #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR
18 
19 #ifndef __ASSEMBLY__
20 extern void mcount(void);
21 extern atomic_t modifying_ftrace_code;
22 extern void __fentry__(void);
23 
24 static inline unsigned long ftrace_call_adjust(unsigned long addr)
25 {
26 	/*
27 	 * addr is the address of the mcount call instruction.
28 	 * recordmcount does the necessary offset calculation.
29 	 */
30 	return addr;
31 }
32 
33 #ifdef CONFIG_DYNAMIC_FTRACE
34 
35 struct dyn_arch_ftrace {
36 	/* No extra data needed for x86 */
37 };
38 
39 int ftrace_int3_handler(struct pt_regs *regs);
40 
41 #define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR
42 
43 #endif /*  CONFIG_DYNAMIC_FTRACE */
44 #endif /* __ASSEMBLY__ */
45 #endif /* CONFIG_FUNCTION_TRACER */
46 
47 
48 #if !defined(__ASSEMBLY__) && !defined(COMPILE_OFFSETS)
49 
50 #if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION)
51 #include <asm/compat.h>
52 
53 /*
54  * Because ia32 syscalls do not map to x86_64 syscall numbers
55  * this screws up the trace output when tracing a ia32 task.
56  * Instead of reporting bogus syscalls, just do not trace them.
57  *
58  * If the user really wants these, then they should use the
59  * raw syscall tracepoints with filtering.
60  */
61 #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1
62 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs)
63 {
64 	if (in_compat_syscall())
65 		return true;
66 	return false;
67 }
68 #endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_IA32_EMULATION */
69 #endif /* !__ASSEMBLY__  && !COMPILE_OFFSETS */
70 
71 #endif /* _ASM_X86_FTRACE_H */
72