mcount.S 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright IBM Corp. 2008, 2009
  3. *
  4. * Author(s): Heiko Carstens <heiko.carstens@de.ibm.com>,
  5. *
  6. */
  7. #include <linux/linkage.h>
  8. #include <asm/asm-offsets.h>
  9. #include <asm/ftrace.h>
  10. .section .kprobes.text, "ax"
  11. ENTRY(ftrace_stub)
  12. br %r14
  13. ENTRY(_mcount)
  14. #ifdef CONFIG_DYNAMIC_FTRACE
  15. br %r14
  16. ENTRY(ftrace_caller)
  17. #endif
  18. stm %r2,%r5,16(%r15)
  19. bras %r1,1f
  20. 0: .long ftrace_trace_function
  21. 1: st %r14,56(%r15)
  22. lr %r0,%r15
  23. ahi %r15,-96
  24. l %r3,100(%r15)
  25. la %r2,0(%r14)
  26. st %r0,__SF_BACKCHAIN(%r15)
  27. la %r3,0(%r3)
  28. ahi %r2,-MCOUNT_INSN_SIZE
  29. l %r14,0b-0b(%r1)
  30. l %r14,0(%r14)
  31. basr %r14,%r14
  32. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  33. l %r2,100(%r15)
  34. l %r3,152(%r15)
  35. ENTRY(ftrace_graph_caller)
  36. # The bras instruction gets runtime patched to call prepare_ftrace_return.
  37. # See ftrace_enable_ftrace_graph_caller. The patched instruction is:
  38. # bras %r14,prepare_ftrace_return
  39. bras %r14,0f
  40. 0: st %r2,100(%r15)
  41. #endif
  42. ahi %r15,96
  43. l %r14,56(%r15)
  44. lm %r2,%r5,16(%r15)
  45. br %r14
  46. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  47. ENTRY(return_to_handler)
  48. stm %r2,%r5,16(%r15)
  49. st %r14,56(%r15)
  50. lr %r0,%r15
  51. ahi %r15,-96
  52. st %r0,__SF_BACKCHAIN(%r15)
  53. bras %r1,0f
  54. .long ftrace_return_to_handler
  55. 0: l %r2,0b-0b(%r1)
  56. basr %r14,%r2
  57. lr %r14,%r2
  58. ahi %r15,96
  59. lm %r2,%r5,16(%r15)
  60. br %r14
  61. #endif