blob: 783b107eacbcfef6176a9454b72314990c6adfd4 [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
6 .macro MCOUNT_SAVE_FRAME
7 /* taken from glibc */
8 subq $0x38, %rsp
9 movq %rax, (%rsp)
10 movq %rcx, 8(%rsp)
11 movq %rdx, 16(%rsp)
12 movq %rsi, 24(%rsp)
13 movq %rdi, 32(%rsp)
14 movq %r8, 40(%rsp)
15 movq %r9, 48(%rsp)
16 .endm
17
18 .macro MCOUNT_RESTORE_FRAME
19 movq 48(%rsp), %r9
20 movq 40(%rsp), %r8
21 movq 32(%rsp), %rdi
22 movq 24(%rsp), %rsi
23 movq 16(%rsp), %rdx
24 movq 8(%rsp), %rcx
25 movq (%rsp), %rax
26 addq $0x38, %rsp
27 .endm
28
29#endif
30
Ingo Molnar4944dd62008-10-27 10:50:54 +010031#ifdef CONFIG_FUNCTION_TRACER
Abhishek Sagar395a59d2008-06-21 23:47:27 +053032#define MCOUNT_ADDR ((long)(mcount))
33#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
34
Steven Rostedt2f5f6ad2011-08-08 16:57:47 -040035#if defined(CONFIG_DYNAMIC_FTRACE) && defined(CONFIG_X86_64)
36#define ARCH_SUPPORTS_FTRACE_OPS 1
37#endif
38
Abhishek Sagar395a59d2008-06-21 23:47:27 +053039#ifndef __ASSEMBLY__
40extern void mcount(void);
Steven Rostedta192cd02012-05-30 13:26:37 -040041extern atomic_t modifying_ftrace_code;
Steven Rostedt68bf21a2008-08-14 15:45:08 -040042
43static inline unsigned long ftrace_call_adjust(unsigned long addr)
44{
45 /*
Martin Schwidefsky521ccb52011-05-10 10:10:41 +020046 * addr is the address of the mcount call instruction.
47 * recordmcount does the necessary offset calculation.
Steven Rostedt68bf21a2008-08-14 15:45:08 -040048 */
Martin Schwidefsky521ccb52011-05-10 10:10:41 +020049 return addr;
Steven Rostedt68bf21a2008-08-14 15:45:08 -040050}
Steven Rostedt31e88902008-11-14 16:21:19 -080051
52#ifdef CONFIG_DYNAMIC_FTRACE
53
54struct dyn_arch_ftrace {
55 /* No extra data needed for x86 */
56};
57
Steven Rostedt08d636b2011-08-16 09:57:10 -040058int ftrace_int3_handler(struct pt_regs *regs);
59
Steven Rostedt31e88902008-11-14 16:21:19 -080060#endif /* CONFIG_DYNAMIC_FTRACE */
Steven Rostedta26a2a22008-10-31 00:03:22 -040061#endif /* __ASSEMBLY__ */
Ingo Molnar4944dd62008-10-27 10:50:54 +010062#endif /* CONFIG_FUNCTION_TRACER */
Abhishek Sagar395a59d2008-06-21 23:47:27 +053063
H. Peter Anvin1965aae2008-10-22 22:26:29 -070064#endif /* _ASM_X86_FTRACE_H */