mcount.S 1.3 KB

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