mcount.S 2.0 KB

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