ftrace.h 1.4 KB

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