nospec-insn.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_S390_NOSPEC_ASM_H
  3. #define _ASM_S390_NOSPEC_ASM_H
  4. #include <asm/alternative-asm.h>
  5. #include <asm/asm-offsets.h>
  6. #ifdef __ASSEMBLY__
  7. #ifdef CONFIG_EXPOLINE
  8. _LC_BR_R1 = __LC_BR_R1
  9. /*
  10. * The expoline macros are used to create thunks in the same format
  11. * as gcc generates them. The 'comdat' section flag makes sure that
  12. * the various thunks are merged into a single copy.
  13. */
  14. .macro __THUNK_PROLOG_NAME name
  15. .pushsection .text.\name,"axG",@progbits,\name,comdat
  16. .globl \name
  17. .hidden \name
  18. .type \name,@function
  19. \name:
  20. .cfi_startproc
  21. .endm
  22. .macro __THUNK_EPILOG
  23. .cfi_endproc
  24. .popsection
  25. .endm
  26. .macro __THUNK_PROLOG_BR r1,r2
  27. __THUNK_PROLOG_NAME __s390x_indirect_jump_r\r2\()use_r\r1
  28. .endm
  29. .macro __THUNK_PROLOG_BC d0,r1,r2
  30. __THUNK_PROLOG_NAME __s390x_indirect_branch_\d0\()_\r2\()use_\r1
  31. .endm
  32. .macro __THUNK_BR r1,r2
  33. jg __s390x_indirect_jump_r\r2\()use_r\r1
  34. .endm
  35. .macro __THUNK_BC d0,r1,r2
  36. jg __s390x_indirect_branch_\d0\()_\r2\()use_\r1
  37. .endm
  38. .macro __THUNK_BRASL r1,r2,r3
  39. brasl \r1,__s390x_indirect_jump_r\r3\()use_r\r2
  40. .endm
  41. .macro __DECODE_RR expand,reg,ruse
  42. .set __decode_fail,1
  43. .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  44. .ifc \reg,%r\r1
  45. .irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  46. .ifc \ruse,%r\r2
  47. \expand \r1,\r2
  48. .set __decode_fail,0
  49. .endif
  50. .endr
  51. .endif
  52. .endr
  53. .if __decode_fail == 1
  54. .error "__DECODE_RR failed"
  55. .endif
  56. .endm
  57. .macro __DECODE_RRR expand,rsave,rtarget,ruse
  58. .set __decode_fail,1
  59. .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  60. .ifc \rsave,%r\r1
  61. .irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  62. .ifc \rtarget,%r\r2
  63. .irp r3,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  64. .ifc \ruse,%r\r3
  65. \expand \r1,\r2,\r3
  66. .set __decode_fail,0
  67. .endif
  68. .endr
  69. .endif
  70. .endr
  71. .endif
  72. .endr
  73. .if __decode_fail == 1
  74. .error "__DECODE_RRR failed"
  75. .endif
  76. .endm
  77. .macro __DECODE_DRR expand,disp,reg,ruse
  78. .set __decode_fail,1
  79. .irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  80. .ifc \reg,%r\r1
  81. .irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
  82. .ifc \ruse,%r\r2
  83. \expand \disp,\r1,\r2
  84. .set __decode_fail,0
  85. .endif
  86. .endr
  87. .endif
  88. .endr
  89. .if __decode_fail == 1
  90. .error "__DECODE_DRR failed"
  91. .endif
  92. .endm
  93. .macro __THUNK_EX_BR reg,ruse
  94. # Be very careful when adding instructions to this macro!
  95. # The ALTERNATIVE replacement code has a .+10 which targets
  96. # the "br \reg" after the code has been patched.
  97. #ifdef CONFIG_HAVE_MARCH_Z10_FEATURES
  98. exrl 0,555f
  99. j .
  100. #else
  101. .ifc \reg,%r1
  102. ALTERNATIVE "ex %r0,_LC_BR_R1", ".insn ril,0xc60000000000,0,.+10", 35
  103. j .
  104. .else
  105. larl \ruse,555f
  106. ex 0,0(\ruse)
  107. j .
  108. .endif
  109. #endif
  110. 555: br \reg
  111. .endm
  112. .macro __THUNK_EX_BC disp,reg,ruse
  113. #ifdef CONFIG_HAVE_MARCH_Z10_FEATURES
  114. exrl 0,556f
  115. j .
  116. #else
  117. larl \ruse,556f
  118. ex 0,0(\ruse)
  119. j .
  120. #endif
  121. 556: b \disp(\reg)
  122. .endm
  123. .macro GEN_BR_THUNK reg,ruse=%r1
  124. __DECODE_RR __THUNK_PROLOG_BR,\reg,\ruse
  125. __THUNK_EX_BR \reg,\ruse
  126. __THUNK_EPILOG
  127. .endm
  128. .macro GEN_B_THUNK disp,reg,ruse=%r1
  129. __DECODE_DRR __THUNK_PROLOG_BC,\disp,\reg,\ruse
  130. __THUNK_EX_BC \disp,\reg,\ruse
  131. __THUNK_EPILOG
  132. .endm
  133. .macro BR_EX reg,ruse=%r1
  134. 557: __DECODE_RR __THUNK_BR,\reg,\ruse
  135. .pushsection .s390_indirect_branches,"a",@progbits
  136. .long 557b-.
  137. .popsection
  138. .endm
  139. .macro B_EX disp,reg,ruse=%r1
  140. 558: __DECODE_DRR __THUNK_BC,\disp,\reg,\ruse
  141. .pushsection .s390_indirect_branches,"a",@progbits
  142. .long 558b-.
  143. .popsection
  144. .endm
  145. .macro BASR_EX rsave,rtarget,ruse=%r1
  146. 559: __DECODE_RRR __THUNK_BRASL,\rsave,\rtarget,\ruse
  147. .pushsection .s390_indirect_branches,"a",@progbits
  148. .long 559b-.
  149. .popsection
  150. .endm
  151. #else
  152. .macro GEN_BR_THUNK reg,ruse=%r1
  153. .endm
  154. .macro GEN_B_THUNK disp,reg,ruse=%r1
  155. .endm
  156. .macro BR_EX reg,ruse=%r1
  157. br \reg
  158. .endm
  159. .macro B_EX disp,reg,ruse=%r1
  160. b \disp(\reg)
  161. .endm
  162. .macro BASR_EX rsave,rtarget,ruse=%r1
  163. basr \rsave,\rtarget
  164. .endm
  165. #endif
  166. #endif /* __ASSEMBLY__ */
  167. #endif /* _ASM_S390_NOSPEC_ASM_H */