Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 2 | #ifndef _ASM_X86_FTRACE_H |
| 3 | #define _ASM_X86_FTRACE_H |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 4 | |
Ingo Molnar | 4944dd6 | 2008-10-27 10:50:54 +0100 | [diff] [blame] | 5 | #ifdef CONFIG_FUNCTION_TRACER |
Steven Rostedt | d57c5d5 | 2011-02-09 13:32:18 -0500 | [diff] [blame] | 6 | #ifdef CC_USING_FENTRY |
Minfei Huang | c93bf92 | 2015-07-12 17:52:24 +0800 | [diff] [blame] | 7 | # define MCOUNT_ADDR ((unsigned long)(__fentry__)) |
Steven Rostedt | d57c5d5 | 2011-02-09 13:32:18 -0500 | [diff] [blame] | 8 | #else |
Minfei Huang | c93bf92 | 2015-07-12 17:52:24 +0800 | [diff] [blame] | 9 | # define MCOUNT_ADDR ((unsigned long)(mcount)) |
Josh Poimboeuf | e4a744e | 2016-08-19 06:52:55 -0500 | [diff] [blame] | 10 | # define HAVE_FUNCTION_GRAPH_FP_TEST |
Steven Rostedt | d57c5d5 | 2011-02-09 13:32:18 -0500 | [diff] [blame] | 11 | #endif |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 12 | #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */ |
| 13 | |
Steven Rostedt | 28fb5df | 2011-08-10 22:00:55 -0400 | [diff] [blame] | 14 | #ifdef CONFIG_DYNAMIC_FTRACE |
Steven Rostedt | 2f5f6ad | 2011-08-08 16:57:47 -0400 | [diff] [blame] | 15 | #define ARCH_SUPPORTS_FTRACE_OPS 1 |
Steven Rostedt | 08f6fba | 2012-04-30 16:20:23 -0400 | [diff] [blame] | 16 | #endif |
Steven Rostedt | 2f5f6ad | 2011-08-08 16:57:47 -0400 | [diff] [blame] | 17 | |
Josh Poimboeuf | 471bd10 | 2016-08-19 06:53:00 -0500 | [diff] [blame] | 18 | #define HAVE_FUNCTION_GRAPH_RET_ADDR_PTR |
| 19 | |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 20 | #ifndef __ASSEMBLY__ |
| 21 | extern void mcount(void); |
Steven Rostedt | a192cd0 | 2012-05-30 13:26:37 -0400 | [diff] [blame] | 22 | extern atomic_t modifying_ftrace_code; |
Steven Rostedt | d57c5d5 | 2011-02-09 13:32:18 -0500 | [diff] [blame] | 23 | extern void __fentry__(void); |
Steven Rostedt | 68bf21a | 2008-08-14 15:45:08 -0400 | [diff] [blame] | 24 | |
| 25 | static inline unsigned long ftrace_call_adjust(unsigned long addr) |
| 26 | { |
| 27 | /* |
Martin Schwidefsky | 521ccb5 | 2011-05-10 10:10:41 +0200 | [diff] [blame] | 28 | * addr is the address of the mcount call instruction. |
| 29 | * recordmcount does the necessary offset calculation. |
Steven Rostedt | 68bf21a | 2008-08-14 15:45:08 -0400 | [diff] [blame] | 30 | */ |
Martin Schwidefsky | 521ccb5 | 2011-05-10 10:10:41 +0200 | [diff] [blame] | 31 | return addr; |
Steven Rostedt | 68bf21a | 2008-08-14 15:45:08 -0400 | [diff] [blame] | 32 | } |
Steven Rostedt | 31e8890 | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 33 | |
| 34 | #ifdef CONFIG_DYNAMIC_FTRACE |
| 35 | |
| 36 | struct dyn_arch_ftrace { |
| 37 | /* No extra data needed for x86 */ |
| 38 | }; |
| 39 | |
Steven Rostedt | 08d636b | 2011-08-16 09:57:10 -0400 | [diff] [blame] | 40 | int ftrace_int3_handler(struct pt_regs *regs); |
| 41 | |
Steven Rostedt (Red Hat) | 1026ff9 | 2014-07-11 23:23:53 -0400 | [diff] [blame] | 42 | #define FTRACE_GRAPH_TRAMP_ADDR FTRACE_GRAPH_ADDR |
| 43 | |
Steven Rostedt | 31e8890 | 2008-11-14 16:21:19 -0800 | [diff] [blame] | 44 | #endif /* CONFIG_DYNAMIC_FTRACE */ |
Steven Rostedt | a26a2a2 | 2008-10-31 00:03:22 -0400 | [diff] [blame] | 45 | #endif /* __ASSEMBLY__ */ |
Ingo Molnar | 4944dd6 | 2008-10-27 10:50:54 +0100 | [diff] [blame] | 46 | #endif /* CONFIG_FUNCTION_TRACER */ |
Abhishek Sagar | 395a59d | 2008-06-21 23:47:27 +0530 | [diff] [blame] | 47 | |
Steven Rostedt | f431b63 | 2013-02-12 16:18:59 -0500 | [diff] [blame] | 48 | |
| 49 | #if !defined(__ASSEMBLY__) && !defined(COMPILE_OFFSETS) |
| 50 | |
| 51 | #if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION) |
| 52 | #include <asm/compat.h> |
| 53 | |
| 54 | /* |
| 55 | * Because ia32 syscalls do not map to x86_64 syscall numbers |
| 56 | * this screws up the trace output when tracing a ia32 task. |
| 57 | * Instead of reporting bogus syscalls, just do not trace them. |
| 58 | * |
Adam Buchbinder | 6a6256f | 2016-02-23 15:34:30 -0800 | [diff] [blame] | 59 | * If the user really wants these, then they should use the |
Steven Rostedt | f431b63 | 2013-02-12 16:18:59 -0500 | [diff] [blame] | 60 | * raw syscall tracepoints with filtering. |
| 61 | */ |
| 62 | #define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1 |
| 63 | static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) |
| 64 | { |
Andy Lutomirski | f970165 | 2016-03-22 14:25:27 -0700 | [diff] [blame] | 65 | if (in_compat_syscall()) |
Steven Rostedt | f431b63 | 2013-02-12 16:18:59 -0500 | [diff] [blame] | 66 | return true; |
| 67 | return false; |
| 68 | } |
| 69 | #endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_IA32_EMULATION */ |
| 70 | #endif /* !__ASSEMBLY__ && !COMPILE_OFFSETS */ |
| 71 | |
H. Peter Anvin | 1965aae | 2008-10-22 22:26:29 -0700 | [diff] [blame] | 72 | #endif /* _ASM_X86_FTRACE_H */ |