blob: a8475014c4ad5ee070f8d0f4c477284788c88854 [file] [log] [blame]
H. Peter Anvin1965aae2008-10-22 22:26:29 -07001#ifndef _ASM_X86_FTRACE_H
2#define _ASM_X86_FTRACE_H
Abhishek Sagar395a59d2008-06-21 23:47:27 +05303
Cyrill Gorcunovd680fe42008-12-13 00:09:08 +03004#ifdef __ASSEMBLY__
5
Steven Rostedt08f6fba2012-04-30 16:20:23 -04006 /* skip is set if the stack was already partially adjusted */
7 .macro MCOUNT_SAVE_FRAME skip=0
8 /*
9 * We add enough stack to save all regs.
10 */
11 subq $(SS+8-\skip), %rsp
12 movq %rax, RAX(%rsp)
13 movq %rcx, RCX(%rsp)
14 movq %rdx, RDX(%rsp)
15 movq %rsi, RSI(%rsp)
16 movq %rdi, RDI(%rsp)
17 movq %r8, R8(%rsp)
18 movq %r9, R9(%rsp)
19 /* Move RIP to its proper location */
20 movq SS+8(%rsp), %rdx
21 movq %rdx, RIP(%rsp)
Cyrill Gorcunovd680fe42008-12-13 00:09:08 +030022 .endm
23
Steven Rostedt08f6fba2012-04-30 16:20:23 -040024 .macro MCOUNT_RESTORE_FRAME skip=0
25 movq R9(%rsp), %r9
26 movq R8(%rsp), %r8
27 movq RDI(%rsp), %rdi
28 movq RSI(%rsp), %rsi
29 movq RDX(%rsp), %rdx
30 movq RCX(%rsp), %rcx
31 movq RAX(%rsp), %rax
32 addq $(SS+8-\skip), %rsp
Cyrill Gorcunovd680fe42008-12-13 00:09:08 +030033 .endm
34
35#endif
36
Ingo Molnar4944dd62008-10-27 10:50:54 +010037#ifdef CONFIG_FUNCTION_TRACER
Abhishek Sagar395a59d2008-06-21 23:47:27 +053038#define MCOUNT_ADDR ((long)(mcount))
39#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
40
Steven Rostedt28fb5df2011-08-10 22:00:55 -040041#ifdef CONFIG_DYNAMIC_FTRACE
Steven Rostedt2f5f6ad2011-08-08 16:57:47 -040042#define ARCH_SUPPORTS_FTRACE_OPS 1
Steven Rostedt08f6fba2012-04-30 16:20:23 -040043#ifdef CONFIG_X86_64
44#define ARCH_SUPPORTS_FTRACE_SAVE_REGS
45#endif
Steven Rostedt2f5f6ad2011-08-08 16:57:47 -040046#endif
47
Abhishek Sagar395a59d2008-06-21 23:47:27 +053048#ifndef __ASSEMBLY__
49extern void mcount(void);
Steven Rostedta192cd02012-05-30 13:26:37 -040050extern atomic_t modifying_ftrace_code;
Steven Rostedt68bf21a2008-08-14 15:45:08 -040051
52static inline unsigned long ftrace_call_adjust(unsigned long addr)
53{
54 /*
Martin Schwidefsky521ccb52011-05-10 10:10:41 +020055 * addr is the address of the mcount call instruction.
56 * recordmcount does the necessary offset calculation.
Steven Rostedt68bf21a2008-08-14 15:45:08 -040057 */
Martin Schwidefsky521ccb52011-05-10 10:10:41 +020058 return addr;
Steven Rostedt68bf21a2008-08-14 15:45:08 -040059}
Steven Rostedt31e88902008-11-14 16:21:19 -080060
61#ifdef CONFIG_DYNAMIC_FTRACE
62
63struct dyn_arch_ftrace {
64 /* No extra data needed for x86 */
65};
66
Steven Rostedt08d636b2011-08-16 09:57:10 -040067int ftrace_int3_handler(struct pt_regs *regs);
68
Steven Rostedt31e88902008-11-14 16:21:19 -080069#endif /* CONFIG_DYNAMIC_FTRACE */
Steven Rostedta26a2a22008-10-31 00:03:22 -040070#endif /* __ASSEMBLY__ */
Ingo Molnar4944dd62008-10-27 10:50:54 +010071#endif /* CONFIG_FUNCTION_TRACER */
Abhishek Sagar395a59d2008-06-21 23:47:27 +053072
H. Peter Anvin1965aae2008-10-22 22:26:29 -070073#endif /* _ASM_X86_FTRACE_H */