ftrace.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. #endif /* _ASM_X86_FTRACE_H */