mcount.S 2.0 KB

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