ftrace.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef _ASM_S390_FTRACE_H
  2. #define _ASM_S390_FTRACE_H
  3. #define ARCH_SUPPORTS_FTRACE_OPS 1
  4. #ifdef CC_USING_HOTPATCH
  5. #define MCOUNT_INSN_SIZE 6
  6. #else
  7. #define MCOUNT_INSN_SIZE 24
  8. #define MCOUNT_RETURN_FIXUP 18
  9. #endif
  10. #ifndef __ASSEMBLY__
  11. #define ftrace_return_address(n) __builtin_return_address(n)
  12. void _mcount(void);
  13. void ftrace_caller(void);
  14. extern char ftrace_graph_caller_end;
  15. extern unsigned long ftrace_plt;
  16. struct dyn_arch_ftrace { };
  17. #define MCOUNT_ADDR ((unsigned long)_mcount)
  18. #define FTRACE_ADDR ((unsigned long)ftrace_caller)
  19. #define KPROBE_ON_FTRACE_NOP 0
  20. #define KPROBE_ON_FTRACE_CALL 1
  21. static inline unsigned long ftrace_call_adjust(unsigned long addr)
  22. {
  23. return addr;
  24. }
  25. struct ftrace_insn {
  26. u16 opc;
  27. s32 disp;
  28. } __packed;
  29. static inline void ftrace_generate_nop_insn(struct ftrace_insn *insn)
  30. {
  31. #ifdef CONFIG_FUNCTION_TRACER
  32. #ifdef CC_USING_HOTPATCH
  33. /* brcl 0,0 */
  34. insn->opc = 0xc004;
  35. insn->disp = 0;
  36. #else
  37. /* jg .+24 */
  38. insn->opc = 0xc0f4;
  39. insn->disp = MCOUNT_INSN_SIZE / 2;
  40. #endif
  41. #endif
  42. }
  43. static inline int is_ftrace_nop(struct ftrace_insn *insn)
  44. {
  45. #ifdef CONFIG_FUNCTION_TRACER
  46. #ifdef CC_USING_HOTPATCH
  47. if (insn->disp == 0)
  48. return 1;
  49. #else
  50. if (insn->disp == MCOUNT_INSN_SIZE / 2)
  51. return 1;
  52. #endif
  53. #endif
  54. return 0;
  55. }
  56. static inline void ftrace_generate_call_insn(struct ftrace_insn *insn,
  57. unsigned long ip)
  58. {
  59. #ifdef CONFIG_FUNCTION_TRACER
  60. unsigned long target;
  61. /* brasl r0,ftrace_caller */
  62. target = is_module_addr((void *) ip) ? ftrace_plt : FTRACE_ADDR;
  63. insn->opc = 0xc005;
  64. insn->disp = (target - ip) / 2;
  65. #endif
  66. }
  67. #endif /* __ASSEMBLY__ */
  68. #endif /* _ASM_S390_FTRACE_H */