mcount.S 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. #include <asm/ptrace.h>
  11. .section .kprobes.text, "ax"
  12. ENTRY(ftrace_stub)
  13. br %r14
  14. #define STACK_FRAME_SIZE (STACK_FRAME_OVERHEAD + __PT_SIZE)
  15. #define STACK_PTREGS (STACK_FRAME_OVERHEAD)
  16. #define STACK_PTREGS_GPRS (STACK_PTREGS + __PT_GPRS)
  17. #define STACK_PTREGS_PSW (STACK_PTREGS + __PT_PSW)
  18. ENTRY(_mcount)
  19. br %r14
  20. ENTRY(ftrace_caller)
  21. .globl ftrace_regs_caller
  22. .set ftrace_regs_caller,ftrace_caller
  23. lgr %r1,%r15
  24. aghi %r15,-STACK_FRAME_SIZE
  25. stg %r1,__SF_BACKCHAIN(%r15)
  26. stg %r1,(STACK_PTREGS_GPRS+15*8)(%r15)
  27. stg %r0,(STACK_PTREGS_PSW+8)(%r15)
  28. stmg %r2,%r14,(STACK_PTREGS_GPRS+2*8)(%r15)
  29. #ifdef CONFIG_HAVE_MARCH_Z196_FEATURES
  30. aghik %r2,%r0,-MCOUNT_INSN_SIZE
  31. lgrl %r4,function_trace_op
  32. lgrl %r1,ftrace_trace_function
  33. #else
  34. lgr %r2,%r0
  35. aghi %r2,-MCOUNT_INSN_SIZE
  36. larl %r4,function_trace_op
  37. lg %r4,0(%r4)
  38. larl %r1,ftrace_trace_function
  39. lg %r1,0(%r1)
  40. #endif
  41. lgr %r3,%r14
  42. la %r5,STACK_PTREGS(%r15)
  43. basr %r14,%r1
  44. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  45. # The j instruction gets runtime patched to a nop instruction.
  46. # See ftrace_enable_ftrace_graph_caller.
  47. ENTRY(ftrace_graph_caller)
  48. j ftrace_graph_caller_end
  49. lg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
  50. lg %r3,(STACK_PTREGS_PSW+8)(%r15)
  51. brasl %r14,prepare_ftrace_return
  52. stg %r2,(STACK_PTREGS_GPRS+14*8)(%r15)
  53. ftrace_graph_caller_end:
  54. .globl ftrace_graph_caller_end
  55. #endif
  56. lg %r1,(STACK_PTREGS_PSW+8)(%r15)
  57. lmg %r2,%r15,(STACK_PTREGS_GPRS+2*8)(%r15)
  58. br %r1
  59. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  60. ENTRY(return_to_handler)
  61. stmg %r2,%r5,32(%r15)
  62. lgr %r1,%r15
  63. aghi %r15,-STACK_FRAME_OVERHEAD
  64. stg %r1,__SF_BACKCHAIN(%r15)
  65. brasl %r14,ftrace_return_to_handler
  66. aghi %r15,STACK_FRAME_OVERHEAD
  67. lgr %r14,%r2
  68. lmg %r2,%r5,32(%r15)
  69. br %r14
  70. #endif