2008-10-23 12:26:29 +07:00
|
|
|
#ifndef _ASM_X86_FTRACE_H
|
|
|
|
#define _ASM_X86_FTRACE_H
|
2008-06-22 01:17:27 +07:00
|
|
|
|
2008-12-13 04:09:08 +07:00
|
|
|
#ifdef __ASSEMBLY__
|
|
|
|
|
2012-05-01 03:20:23 +07:00
|
|
|
/* skip is set if the stack was already partially adjusted */
|
|
|
|
.macro MCOUNT_SAVE_FRAME skip=0
|
|
|
|
/*
|
|
|
|
* We add enough stack to save all regs.
|
|
|
|
*/
|
|
|
|
subq $(SS+8-\skip), %rsp
|
|
|
|
movq %rax, RAX(%rsp)
|
|
|
|
movq %rcx, RCX(%rsp)
|
|
|
|
movq %rdx, RDX(%rsp)
|
|
|
|
movq %rsi, RSI(%rsp)
|
|
|
|
movq %rdi, RDI(%rsp)
|
|
|
|
movq %r8, R8(%rsp)
|
|
|
|
movq %r9, R9(%rsp)
|
|
|
|
/* Move RIP to its proper location */
|
|
|
|
movq SS+8(%rsp), %rdx
|
|
|
|
movq %rdx, RIP(%rsp)
|
2008-12-13 04:09:08 +07:00
|
|
|
.endm
|
|
|
|
|
2012-05-01 03:20:23 +07:00
|
|
|
.macro MCOUNT_RESTORE_FRAME skip=0
|
|
|
|
movq R9(%rsp), %r9
|
|
|
|
movq R8(%rsp), %r8
|
|
|
|
movq RDI(%rsp), %rdi
|
|
|
|
movq RSI(%rsp), %rsi
|
|
|
|
movq RDX(%rsp), %rdx
|
|
|
|
movq RCX(%rsp), %rcx
|
|
|
|
movq RAX(%rsp), %rax
|
|
|
|
addq $(SS+8-\skip), %rsp
|
2008-12-13 04:09:08 +07:00
|
|
|
.endm
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2008-10-07 06:06:12 +07:00
|
|
|
#ifdef CONFIG_FUNCTION_TRACER
|
ftrace/x86: Add support for -mfentry to x86_64
If the kernel is compiled with gcc 4.6.0 which supports -mfentry,
then use that instead of mcount.
With mcount, frame pointers are forced with the -pg option and we
get something like:
<can_vma_merge_before>:
55 push %rbp
48 89 e5 mov %rsp,%rbp
53 push %rbx
41 51 push %r9
e8 fe 6a 39 00 callq ffffffff81483d00 <mcount>
31 c0 xor %eax,%eax
48 89 fb mov %rdi,%rbx
48 89 d7 mov %rdx,%rdi
48 33 73 30 xor 0x30(%rbx),%rsi
48 f7 c6 ff ff ff f7 test $0xfffffffff7ffffff,%rsi
With -mfentry, frame pointers are no longer forced and the call looks
like this:
<can_vma_merge_before>:
e8 33 af 37 00 callq ffffffff81461b40 <__fentry__>
53 push %rbx
48 89 fb mov %rdi,%rbx
31 c0 xor %eax,%eax
48 89 d7 mov %rdx,%rdi
41 51 push %r9
48 33 73 30 xor 0x30(%rbx),%rsi
48 f7 c6 ff ff ff f7 test $0xfffffffff7ffffff,%rsi
This adds the ftrace hook at the beginning of the function before a
frame is set up, and allows the function callbacks to be able to access
parameters. As kprobes now can use function tracing (at least on x86)
this speeds up the kprobe hooks that are at the beginning of the
function.
Link: http://lkml.kernel.org/r/20120807194100.130477900@goodmis.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2011-02-10 01:32:18 +07:00
|
|
|
#ifdef CC_USING_FENTRY
|
|
|
|
# define MCOUNT_ADDR ((long)(__fentry__))
|
|
|
|
#else
|
|
|
|
# define MCOUNT_ADDR ((long)(mcount))
|
|
|
|
#endif
|
2008-06-22 01:17:27 +07:00
|
|
|
#define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
|
|
|
|
|
2011-08-11 09:00:55 +07:00
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
2011-08-09 03:57:47 +07:00
|
|
|
#define ARCH_SUPPORTS_FTRACE_OPS 1
|
2012-05-01 03:20:23 +07:00
|
|
|
#define ARCH_SUPPORTS_FTRACE_SAVE_REGS
|
|
|
|
#endif
|
2011-08-09 03:57:47 +07:00
|
|
|
|
2008-06-22 01:17:27 +07:00
|
|
|
#ifndef __ASSEMBLY__
|
|
|
|
extern void mcount(void);
|
2012-05-31 00:26:37 +07:00
|
|
|
extern atomic_t modifying_ftrace_code;
|
ftrace/x86: Add support for -mfentry to x86_64
If the kernel is compiled with gcc 4.6.0 which supports -mfentry,
then use that instead of mcount.
With mcount, frame pointers are forced with the -pg option and we
get something like:
<can_vma_merge_before>:
55 push %rbp
48 89 e5 mov %rsp,%rbp
53 push %rbx
41 51 push %r9
e8 fe 6a 39 00 callq ffffffff81483d00 <mcount>
31 c0 xor %eax,%eax
48 89 fb mov %rdi,%rbx
48 89 d7 mov %rdx,%rdi
48 33 73 30 xor 0x30(%rbx),%rsi
48 f7 c6 ff ff ff f7 test $0xfffffffff7ffffff,%rsi
With -mfentry, frame pointers are no longer forced and the call looks
like this:
<can_vma_merge_before>:
e8 33 af 37 00 callq ffffffff81461b40 <__fentry__>
53 push %rbx
48 89 fb mov %rdi,%rbx
31 c0 xor %eax,%eax
48 89 d7 mov %rdx,%rdi
41 51 push %r9
48 33 73 30 xor 0x30(%rbx),%rsi
48 f7 c6 ff ff ff f7 test $0xfffffffff7ffffff,%rsi
This adds the ftrace hook at the beginning of the function before a
frame is set up, and allows the function callbacks to be able to access
parameters. As kprobes now can use function tracing (at least on x86)
this speeds up the kprobe hooks that are at the beginning of the
function.
Link: http://lkml.kernel.org/r/20120807194100.130477900@goodmis.org
Acked-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
2011-02-10 01:32:18 +07:00
|
|
|
extern void __fentry__(void);
|
2008-08-15 02:45:08 +07:00
|
|
|
|
|
|
|
static inline unsigned long ftrace_call_adjust(unsigned long addr)
|
|
|
|
{
|
|
|
|
/*
|
2011-05-10 15:10:41 +07:00
|
|
|
* addr is the address of the mcount call instruction.
|
|
|
|
* recordmcount does the necessary offset calculation.
|
2008-08-15 02:45:08 +07:00
|
|
|
*/
|
2011-05-10 15:10:41 +07:00
|
|
|
return addr;
|
2008-08-15 02:45:08 +07:00
|
|
|
}
|
2008-11-15 07:21:19 +07:00
|
|
|
|
|
|
|
#ifdef CONFIG_DYNAMIC_FTRACE
|
|
|
|
|
|
|
|
struct dyn_arch_ftrace {
|
|
|
|
/* No extra data needed for x86 */
|
|
|
|
};
|
|
|
|
|
2011-08-16 20:57:10 +07:00
|
|
|
int ftrace_int3_handler(struct pt_regs *regs);
|
|
|
|
|
2008-11-15 07:21:19 +07:00
|
|
|
#endif /* CONFIG_DYNAMIC_FTRACE */
|
2008-10-31 11:03:22 +07:00
|
|
|
#endif /* __ASSEMBLY__ */
|
2008-10-07 06:06:12 +07:00
|
|
|
#endif /* CONFIG_FUNCTION_TRACER */
|
2008-06-22 01:17:27 +07:00
|
|
|
|
2008-10-23 12:26:29 +07:00
|
|
|
#endif /* _ASM_X86_FTRACE_H */
|