ftrace/x86: Add save_regs for i386 function calls
[firefly-linux-kernel-4.4.55.git] / arch / x86 / include / asm / ftrace.h
1 #ifndef _ASM_X86_FTRACE_H
2 #define _ASM_X86_FTRACE_H
3
4 #ifdef __ASSEMBLY__
5
6         /* 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)
22         .endm
23
24         .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
33         .endm
34
35 #endif
36
37 #ifdef CONFIG_FUNCTION_TRACER
38 #define MCOUNT_ADDR             ((long)(mcount))
39 #define MCOUNT_INSN_SIZE        5 /* sizeof mcount call */
40
41 #ifdef CONFIG_DYNAMIC_FTRACE
42 #define ARCH_SUPPORTS_FTRACE_OPS 1
43 #define ARCH_SUPPORTS_FTRACE_SAVE_REGS
44 #endif
45
46 #ifndef __ASSEMBLY__
47 extern void mcount(void);
48 extern atomic_t modifying_ftrace_code;
49
50 static inline unsigned long ftrace_call_adjust(unsigned long addr)
51 {
52         /*
53          * addr is the address of the mcount call instruction.
54          * recordmcount does the necessary offset calculation.
55          */
56         return addr;
57 }
58
59 #ifdef CONFIG_DYNAMIC_FTRACE
60
61 struct dyn_arch_ftrace {
62         /* No extra data needed for x86 */
63 };
64
65 int ftrace_int3_handler(struct pt_regs *regs);
66
67 #endif /*  CONFIG_DYNAMIC_FTRACE */
68 #endif /* __ASSEMBLY__ */
69 #endif /* CONFIG_FUNCTION_TRACER */
70
71 #endif /* _ASM_X86_FTRACE_H */