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