ftrace.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef _ASM_X86_FTRACE_H
  2. #define _ASM_X86_FTRACE_H
  3. #ifdef __ASSEMBLY__
  4. /* skip is set if the stack was already partially adjusted */
  5. .macro MCOUNT_SAVE_FRAME skip=0
  6. /*
  7. * We add enough stack to save all regs.
  8. */
  9. subq $(SS+8-\skip), %rsp
  10. movq %rax, RAX(%rsp)
  11. movq %rcx, RCX(%rsp)
  12. movq %rdx, RDX(%rsp)
  13. movq %rsi, RSI(%rsp)
  14. movq %rdi, RDI(%rsp)
  15. movq %r8, R8(%rsp)
  16. movq %r9, R9(%rsp)
  17. /* Move RIP to its proper location */
  18. movq SS+8(%rsp), %rdx
  19. movq %rdx, RIP(%rsp)
  20. .endm
  21. .macro MCOUNT_RESTORE_FRAME skip=0
  22. movq R9(%rsp), %r9
  23. movq R8(%rsp), %r8
  24. movq RDI(%rsp), %rdi
  25. movq RSI(%rsp), %rsi
  26. movq RDX(%rsp), %rdx
  27. movq RCX(%rsp), %rcx
  28. movq RAX(%rsp), %rax
  29. addq $(SS+8-\skip), %rsp
  30. .endm
  31. #endif
  32. #ifdef CONFIG_FUNCTION_TRACER
  33. #ifdef CC_USING_FENTRY
  34. # define MCOUNT_ADDR ((long)(__fentry__))
  35. #else
  36. # define MCOUNT_ADDR ((long)(mcount))
  37. #endif
  38. #define MCOUNT_INSN_SIZE 5 /* sizeof mcount call */
  39. #ifdef CONFIG_DYNAMIC_FTRACE
  40. #define ARCH_SUPPORTS_FTRACE_OPS 1
  41. #define ARCH_SUPPORTS_FTRACE_SAVE_REGS
  42. #endif
  43. #ifndef __ASSEMBLY__
  44. extern void mcount(void);
  45. extern atomic_t modifying_ftrace_code;
  46. extern void __fentry__(void);
  47. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  48. {
  49. /*
  50. * addr is the address of the mcount call instruction.
  51. * recordmcount does the necessary offset calculation.
  52. */
  53. return addr;
  54. }
  55. #ifdef CONFIG_DYNAMIC_FTRACE
  56. struct dyn_arch_ftrace {
  57. /* No extra data needed for x86 */
  58. };
  59. int ftrace_int3_handler(struct pt_regs *regs);
  60. #endif /* CONFIG_DYNAMIC_FTRACE */
  61. #endif /* __ASSEMBLY__ */
  62. #endif /* CONFIG_FUNCTION_TRACER */
  63. #endif /* _ASM_X86_FTRACE_H */