kprobes_trampoline.S 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * Author: Patrick Stählin <me@packi.ch>
  4. */
  5. #include <linux/linkage.h>
  6. #include <asm/asm.h>
  7. #include <asm/asm-offsets.h>
  8. .text
  9. .altmacro
  10. .macro save_all_base_regs
  11. REG_S x1, PT_RA(sp)
  12. REG_S x3, PT_GP(sp)
  13. REG_S x4, PT_TP(sp)
  14. REG_S x5, PT_T0(sp)
  15. REG_S x6, PT_T1(sp)
  16. REG_S x7, PT_T2(sp)
  17. REG_S x8, PT_S0(sp)
  18. REG_S x9, PT_S1(sp)
  19. REG_S x10, PT_A0(sp)
  20. REG_S x11, PT_A1(sp)
  21. REG_S x12, PT_A2(sp)
  22. REG_S x13, PT_A3(sp)
  23. REG_S x14, PT_A4(sp)
  24. REG_S x15, PT_A5(sp)
  25. REG_S x16, PT_A6(sp)
  26. REG_S x17, PT_A7(sp)
  27. REG_S x18, PT_S2(sp)
  28. REG_S x19, PT_S3(sp)
  29. REG_S x20, PT_S4(sp)
  30. REG_S x21, PT_S5(sp)
  31. REG_S x22, PT_S6(sp)
  32. REG_S x23, PT_S7(sp)
  33. REG_S x24, PT_S8(sp)
  34. REG_S x25, PT_S9(sp)
  35. REG_S x26, PT_S10(sp)
  36. REG_S x27, PT_S11(sp)
  37. REG_S x28, PT_T3(sp)
  38. REG_S x29, PT_T4(sp)
  39. REG_S x30, PT_T5(sp)
  40. REG_S x31, PT_T6(sp)
  41. .endm
  42. .macro restore_all_base_regs
  43. REG_L x3, PT_GP(sp)
  44. REG_L x4, PT_TP(sp)
  45. REG_L x5, PT_T0(sp)
  46. REG_L x6, PT_T1(sp)
  47. REG_L x7, PT_T2(sp)
  48. REG_L x8, PT_S0(sp)
  49. REG_L x9, PT_S1(sp)
  50. REG_L x10, PT_A0(sp)
  51. REG_L x11, PT_A1(sp)
  52. REG_L x12, PT_A2(sp)
  53. REG_L x13, PT_A3(sp)
  54. REG_L x14, PT_A4(sp)
  55. REG_L x15, PT_A5(sp)
  56. REG_L x16, PT_A6(sp)
  57. REG_L x17, PT_A7(sp)
  58. REG_L x18, PT_S2(sp)
  59. REG_L x19, PT_S3(sp)
  60. REG_L x20, PT_S4(sp)
  61. REG_L x21, PT_S5(sp)
  62. REG_L x22, PT_S6(sp)
  63. REG_L x23, PT_S7(sp)
  64. REG_L x24, PT_S8(sp)
  65. REG_L x25, PT_S9(sp)
  66. REG_L x26, PT_S10(sp)
  67. REG_L x27, PT_S11(sp)
  68. REG_L x28, PT_T3(sp)
  69. REG_L x29, PT_T4(sp)
  70. REG_L x30, PT_T5(sp)
  71. REG_L x31, PT_T6(sp)
  72. .endm
  73. ENTRY(kretprobe_trampoline)
  74. addi sp, sp, -(PT_SIZE_ON_STACK)
  75. save_all_base_regs
  76. move a0, sp /* pt_regs */
  77. call trampoline_probe_handler
  78. /* use the result as the return-address */
  79. move ra, a0
  80. restore_all_base_regs
  81. addi sp, sp, PT_SIZE_ON_STACK
  82. ret
  83. ENDPROC(kretprobe_trampoline)