mcount.S 2.0 KB

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