xref: /linux/arch/s390/include/asm/nospec-insn.h (revision 0e9ab8e4d44ae9d9aaf213bfd2c90bbe7289337b)
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/dwarf.h>
6 
7 #ifdef __ASSEMBLY__
8 
9 #ifdef CC_USING_EXPOLINE
10 
11 /*
12  * The expoline macros are used to create thunks in the same format
13  * as gcc generates them. The 'comdat' section flag makes sure that
14  * the various thunks are merged into a single copy.
15  */
16 	.macro __THUNK_PROLOG_NAME name
17 #ifdef CONFIG_EXPOLINE_EXTERN
18 	.pushsection .text,"ax",@progbits
19 	.align 16,0x07
20 #else
21 	.pushsection .text.\name,"axG",@progbits,\name,comdat
22 #endif
23 	.globl \name
24 	.hidden \name
25 	.type \name,@function
26 \name:
27 	CFI_STARTPROC
28 	.endm
29 
30 	.macro __THUNK_EPILOG_NAME name
31 	CFI_ENDPROC
32 #ifdef CONFIG_EXPOLINE_EXTERN
33 	.size \name, .-\name
34 #endif
35 	.popsection
36 	.endm
37 
38 	.macro __THUNK_PROLOG_BR r1
39 	__THUNK_PROLOG_NAME __s390_indirect_jump_r\r1
40 	.endm
41 
42 	.macro __THUNK_EPILOG_BR r1
43 	__THUNK_EPILOG_NAME __s390_indirect_jump_r\r1
44 	.endm
45 
46 	.macro __THUNK_BR r1
47 	jg	__s390_indirect_jump_r\r1
48 	.endm
49 
50 	.macro __THUNK_BRASL r1,r2
51 	brasl	\r1,__s390_indirect_jump_r\r2
52 	.endm
53 
54 	.macro	__DECODE_R expand,reg
55 	.set .L__decode_fail,1
56 	.irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
57 	.ifc \reg,%r\r1
58 	\expand \r1
59 	.set .L__decode_fail,0
60 	.endif
61 	.endr
62 	.if .L__decode_fail == 1
63 	.error "__DECODE_R failed"
64 	.endif
65 	.endm
66 
67 	.macro	__DECODE_RR expand,rsave,rtarget
68 	.set .L__decode_fail,1
69 	.irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
70 	.ifc \rsave,%r\r1
71 	.irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
72 	.ifc \rtarget,%r\r2
73 	\expand \r1,\r2
74 	.set .L__decode_fail,0
75 	.endif
76 	.endr
77 	.endif
78 	.endr
79 	.if .L__decode_fail == 1
80 	.error "__DECODE_RR failed"
81 	.endif
82 	.endm
83 
84 	.macro __THUNK_EX_BR reg
85 	exrl	0,555f
86 	j	.
87 555:	br	\reg
88 	.endm
89 
90 #ifdef CONFIG_EXPOLINE_EXTERN
91 	.macro GEN_BR_THUNK reg
92 	.endm
93 	.macro GEN_BR_THUNK_EXTERN reg
94 #else
95 	.macro GEN_BR_THUNK reg
96 #endif
97 	__DECODE_R __THUNK_PROLOG_BR,\reg
98 	__THUNK_EX_BR \reg
99 	__DECODE_R __THUNK_EPILOG_BR,\reg
100 	.endm
101 
102 	.macro BR_EX reg
103 557:	__DECODE_R __THUNK_BR,\reg
104 	.pushsection .s390_indirect_branches,"a",@progbits
105 	.long	557b-.
106 	.popsection
107 	.endm
108 
109 	.macro BASR_EX rsave,rtarget
110 559:	__DECODE_RR __THUNK_BRASL,\rsave,\rtarget
111 	.pushsection .s390_indirect_branches,"a",@progbits
112 	.long	559b-.
113 	.popsection
114 	.endm
115 
116 #else
117 	.macro GEN_BR_THUNK reg
118 	.endm
119 
120 	 .macro BR_EX reg
121 	br	\reg
122 	.endm
123 
124 	.macro BASR_EX rsave,rtarget
125 	basr	\rsave,\rtarget
126 	.endm
127 #endif /* CC_USING_EXPOLINE */
128 
129 #endif /* __ASSEMBLY__ */
130 
131 #endif /* _ASM_S390_NOSPEC_ASM_H */
132