Skip to content

Commit 2268169

Browse files
author
Vasily Gorbik
committed
s390: remove unused expoline to BC instructions
This reverts commit 6deaa3b ("s390: extend expoline to BC instructions"). Expolines to BC instructions were added to be utilized by commit de5cb6e ("s390: use expoline thunks in the BPF JIT"). But corresponding code has been removed by commit e1cf4be ("bpf, s390x: remove ld_abs/ld_ind"). And compiler does not generate such expolines as well. Compared to regular expolines, expolines to BC instructions contain displacement and all possible variations cannot be generated in advance, making kpatch support more complicated. So, remove those to avoid future usages. Acked-by: Heiko Carstens <hca@linux.ibm.com> Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 7d8484c commit 2268169

2 files changed

Lines changed: 5 additions & 77 deletions

File tree

arch/s390/include/asm/nospec-insn.h

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,10 @@ _LC_BR_R1 = __LC_BR_R1
3535
__THUNK_PROLOG_NAME __s390_indirect_jump_r\r2\()use_r\r1
3636
.endm
3737

38-
.macro __THUNK_PROLOG_BC d0,r1,r2
39-
__THUNK_PROLOG_NAME __s390_indirect_branch_\d0\()_\r2\()use_\r1
40-
.endm
41-
4238
.macro __THUNK_BR r1,r2
4339
jg __s390_indirect_jump_r\r2\()use_r\r1
4440
.endm
4541

46-
.macro __THUNK_BC d0,r1,r2
47-
jg __s390_indirect_branch_\d0\()_\r2\()use_\r1
48-
.endm
49-
5042
.macro __THUNK_BRASL r1,r2,r3
5143
brasl \r1,__s390_indirect_jump_r\r3\()use_r\r2
5244
.endm
@@ -89,23 +81,6 @@ _LC_BR_R1 = __LC_BR_R1
8981
.endif
9082
.endm
9183

92-
.macro __DECODE_DRR expand,disp,reg,ruse
93-
.set __decode_fail,1
94-
.irp r1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
95-
.ifc \reg,%r\r1
96-
.irp r2,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
97-
.ifc \ruse,%r\r2
98-
\expand \disp,\r1,\r2
99-
.set __decode_fail,0
100-
.endif
101-
.endr
102-
.endif
103-
.endr
104-
.if __decode_fail == 1
105-
.error "__DECODE_DRR failed"
106-
.endif
107-
.endm
108-
10984
.macro __THUNK_EX_BR reg,ruse
11085
# Be very careful when adding instructions to this macro!
11186
# The ALTERNATIVE replacement code has a .+10 which targets
@@ -126,42 +101,17 @@ _LC_BR_R1 = __LC_BR_R1
126101
555: br \reg
127102
.endm
128103

129-
.macro __THUNK_EX_BC disp,reg,ruse
130-
#ifdef CONFIG_HAVE_MARCH_Z10_FEATURES
131-
exrl 0,556f
132-
j .
133-
#else
134-
larl \ruse,556f
135-
ex 0,0(\ruse)
136-
j .
137-
#endif
138-
556: b \disp(\reg)
139-
.endm
140-
141104
.macro GEN_BR_THUNK reg,ruse=%r1
142105
__DECODE_RR __THUNK_PROLOG_BR,\reg,\ruse
143106
__THUNK_EX_BR \reg,\ruse
144107
__THUNK_EPILOG
145108
.endm
146109

147-
.macro GEN_B_THUNK disp,reg,ruse=%r1
148-
__DECODE_DRR __THUNK_PROLOG_BC,\disp,\reg,\ruse
149-
__THUNK_EX_BC \disp,\reg,\ruse
150-
__THUNK_EPILOG
151-
.endm
152-
153110
.macro BR_EX reg,ruse=%r1
154111
557: __DECODE_RR __THUNK_BR,\reg,\ruse
155112
.pushsection .s390_indirect_branches,"a",@progbits
156113
.long 557b-.
157114
.popsection
158-
.endm
159-
160-
.macro B_EX disp,reg,ruse=%r1
161-
558: __DECODE_DRR __THUNK_BC,\disp,\reg,\ruse
162-
.pushsection .s390_indirect_branches,"a",@progbits
163-
.long 558b-.
164-
.popsection
165115
.endm
166116

167117
.macro BASR_EX rsave,rtarget,ruse=%r1
@@ -173,17 +123,10 @@ _LC_BR_R1 = __LC_BR_R1
173123

174124
#else
175125
.macro GEN_BR_THUNK reg,ruse=%r1
176-
.endm
177-
178-
.macro GEN_B_THUNK disp,reg,ruse=%r1
179126
.endm
180127

181128
.macro BR_EX reg,ruse=%r1
182129
br \reg
183-
.endm
184-
185-
.macro B_EX disp,reg,ruse=%r1
186-
b \disp(\reg)
187130
.endm
188131

189132
.macro BASR_EX rsave,rtarget,ruse=%r1

arch/s390/kernel/nospec-branch.c

Lines changed: 5 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ static void __init_or_module __nospec_revert(s32 *start, s32 *end)
105105
s32 *epo;
106106

107107
/* Second part of the instruction replace is always a nop */
108+
memcpy(insnbuf + 2, branch, sizeof(branch));
108109
for (epo = start; epo < end; epo++) {
109110
instr = (u8 *) epo + *epo;
110111
if (instr[0] == 0xc0 && (instr[1] & 0x0f) == 0x04)
@@ -125,34 +126,18 @@ static void __init_or_module __nospec_revert(s32 *start, s32 *end)
125126
br = thunk + (*(int *)(thunk + 2)) * 2;
126127
else
127128
continue;
128-
/* Check for unconditional branch 0x07f? or 0x47f???? */
129-
if ((br[0] & 0xbf) != 0x07 || (br[1] & 0xf0) != 0xf0)
129+
if (br[0] != 0x07 || (br[1] & 0xf0) != 0xf0)
130130
continue;
131-
132-
memcpy(insnbuf + 2, branch, sizeof(branch));
133131
switch (type) {
134132
case BRCL_EXPOLINE:
133+
/* brcl to thunk, replace with br + nop */
135134
insnbuf[0] = br[0];
136135
insnbuf[1] = (instr[1] & 0xf0) | (br[1] & 0x0f);
137-
if (br[0] == 0x47) {
138-
/* brcl to b, replace with bc + nopr */
139-
insnbuf[2] = br[2];
140-
insnbuf[3] = br[3];
141-
} else {
142-
/* brcl to br, replace with bcr + nop */
143-
}
144136
break;
145137
case BRASL_EXPOLINE:
138+
/* brasl to thunk, replace with basr + nop */
139+
insnbuf[0] = 0x0d;
146140
insnbuf[1] = (instr[1] & 0xf0) | (br[1] & 0x0f);
147-
if (br[0] == 0x47) {
148-
/* brasl to b, replace with bas + nopr */
149-
insnbuf[0] = 0x4d;
150-
insnbuf[2] = br[2];
151-
insnbuf[3] = br[3];
152-
} else {
153-
/* brasl to br, replace with basr + nop */
154-
insnbuf[0] = 0x0d;
155-
}
156141
break;
157142
}
158143

0 commit comments

Comments
 (0)