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