ftrace.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #ifdef CONFIG_FUNCTION_TRACER
  27. #define MCOUNT_ADDR ((long)(mcount))
  28. #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
  29. #ifndef __ASSEMBLY__
  30. extern void mcount(void);
  31. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  32. {
  33. /*
  34. * call mcount is "e8 <4 byte offset>"
  35. * The addr points to the 4 byte offset and the caller of this
  36. * function wants the pointer to e8. Simply subtract one.
  37. */
  38. return addr - 1;
  39. }
  40. #ifdef CONFIG_DYNAMIC_FTRACE
  41. struct dyn_arch_ftrace {
  42. /* No extra data needed for x86 */
  43. };
  44. #endif /* CONFIG_DYNAMIC_FTRACE */
  45. #endif /* __ASSEMBLY__ */
  46. #endif /* CONFIG_FUNCTION_TRACER */
  47. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  48. #ifndef __ASSEMBLY__
  49. /*
  50. * Stack of return addresses for functions
  51. * of a thread.
  52. * Used in struct thread_info
  53. */
  54. struct ftrace_ret_stack {
  55. unsigned long ret;
  56. unsigned long func;
  57. unsigned long long calltime;
  58. };
  59. /*
  60. * Primary handler of a function return.
  61. * It relays on ftrace_return_to_handler.
  62. * Defined in entry_32/64.S
  63. */
  64. extern void return_to_handler(void);
  65. #endif /* __ASSEMBLY__ */
  66. #endif /* CONFIG_FUNCTION_GRAPH_TRACER */
  67. #endif /* _ASM_X86_FTRACE_H */