ftrace.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef _ASM_X86_FTRACE_H
  2. #define _ASM_X86_FTRACE_H
  3. #ifdef __ASSEMBLY__
  4. .macro MCOUNT_SAVE_FRAME
  5. /* taken from glibc */
  6. subq $0x38, %rsp
  7. movq %rax, (%rsp)
  8. movq %rcx, 8(%rsp)
  9. movq %rdx, 16(%rsp)
  10. movq %rsi, 24(%rsp)
  11. movq %rdi, 32(%rsp)
  12. movq %r8, 40(%rsp)
  13. movq %r9, 48(%rsp)
  14. .endm
  15. .macro MCOUNT_RESTORE_FRAME
  16. movq 48(%rsp), %r9
  17. movq 40(%rsp), %r8
  18. movq 32(%rsp), %rdi
  19. movq 24(%rsp), %rsi
  20. movq 16(%rsp), %rdx
  21. movq 8(%rsp), %rcx
  22. movq (%rsp), %rax
  23. addq $0x38, %rsp
  24. .endm
  25. #endif
  26. /* FIXME: I don't want to stay hardcoded */
  27. #ifdef CONFIG_X86_64
  28. # define FTRACE_SYSCALL_MAX 296
  29. #else
  30. # define FTRACE_SYSCALL_MAX 333
  31. #endif
  32. #ifdef CONFIG_FUNCTION_TRACER
  33. #define MCOUNT_ADDR ((long)(mcount))
  34. #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
  35. #ifndef __ASSEMBLY__
  36. extern void mcount(void);
  37. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  38. {
  39. /*
  40. * call mcount is "e8 <4 byte offset>"
  41. * The addr points to the 4 byte offset and the caller of this
  42. * function wants the pointer to e8. Simply subtract one.
  43. */
  44. return addr - 1;
  45. }
  46. #ifdef CONFIG_DYNAMIC_FTRACE
  47. struct dyn_arch_ftrace {
  48. /* No extra data needed for x86 */
  49. };
  50. #endif /* CONFIG_DYNAMIC_FTRACE */
  51. #endif /* __ASSEMBLY__ */
  52. #endif /* CONFIG_FUNCTION_TRACER */
  53. #endif /* _ASM_X86_FTRACE_H */