Skip to content

Commit c50c84c

Browse files
author
Martin Schwidefsky
committed
s390/kernel: use expoline for indirect branches
The assember code in arch/s390/kernel uses a few more indirect branches which need to be done with execute trampolines for CONFIG_EXPOLINE=y. Cc: [email protected] # 4.16 Fixes: f19fbd5 ("s390: introduce execute-trampolines for branches") Reviewed-by: Hendrik Brueckner <[email protected]> Signed-off-by: Martin Schwidefsky <[email protected]>
1 parent 23a4d7f commit c50c84c

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

arch/s390/kernel/base.S

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,22 @@
99

1010
#include <linux/linkage.h>
1111
#include <asm/asm-offsets.h>
12+
#include <asm/nospec-insn.h>
1213
#include <asm/ptrace.h>
1314
#include <asm/sigp.h>
1415

16+
GEN_BR_THUNK %r9
17+
GEN_BR_THUNK %r14
18+
1519
ENTRY(s390_base_mcck_handler)
1620
basr %r13,0
1721
0: lg %r15,__LC_PANIC_STACK # load panic stack
1822
aghi %r15,-STACK_FRAME_OVERHEAD
1923
larl %r1,s390_base_mcck_handler_fn
20-
lg %r1,0(%r1)
21-
ltgr %r1,%r1
24+
lg %r9,0(%r1)
25+
ltgr %r9,%r9
2226
jz 1f
23-
basr %r14,%r1
27+
BASR_EX %r14,%r9
2428
1: la %r1,4095
2529
lmg %r0,%r15,__LC_GPREGS_SAVE_AREA-4095(%r1)
2630
lpswe __LC_MCK_OLD_PSW
@@ -37,10 +41,10 @@ ENTRY(s390_base_ext_handler)
3741
basr %r13,0
3842
0: aghi %r15,-STACK_FRAME_OVERHEAD
3943
larl %r1,s390_base_ext_handler_fn
40-
lg %r1,0(%r1)
41-
ltgr %r1,%r1
44+
lg %r9,0(%r1)
45+
ltgr %r9,%r9
4246
jz 1f
43-
basr %r14,%r1
47+
BASR_EX %r14,%r9
4448
1: lmg %r0,%r15,__LC_SAVE_AREA_ASYNC
4549
ni __LC_EXT_OLD_PSW+1,0xfd # clear wait state bit
4650
lpswe __LC_EXT_OLD_PSW
@@ -57,10 +61,10 @@ ENTRY(s390_base_pgm_handler)
5761
basr %r13,0
5862
0: aghi %r15,-STACK_FRAME_OVERHEAD
5963
larl %r1,s390_base_pgm_handler_fn
60-
lg %r1,0(%r1)
61-
ltgr %r1,%r1
64+
lg %r9,0(%r1)
65+
ltgr %r9,%r9
6266
jz 1f
63-
basr %r14,%r1
67+
BASR_EX %r14,%r9
6468
lmg %r0,%r15,__LC_SAVE_AREA_SYNC
6569
lpswe __LC_PGM_OLD_PSW
6670
1: lpswe disabled_wait_psw-0b(%r13)
@@ -117,7 +121,7 @@ ENTRY(diag308_reset)
117121
larl %r4,.Lcontinue_psw # Restore PSW flags
118122
lpswe 0(%r4)
119123
.Lcontinue:
120-
br %r14
124+
BR_EX %r14
121125
.align 16
122126
.Lrestart_psw:
123127
.long 0x00080000,0x80000000 + .Lrestart_part2

arch/s390/kernel/reipl.S

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77

88
#include <linux/linkage.h>
99
#include <asm/asm-offsets.h>
10+
#include <asm/nospec-insn.h>
1011
#include <asm/sigp.h>
1112

13+
GEN_BR_THUNK %r9
14+
1215
#
1316
# Issue "store status" for the current CPU to its prefix page
1417
# and call passed function afterwards
@@ -67,9 +70,9 @@ ENTRY(store_status)
6770
st %r4,0(%r1)
6871
st %r5,4(%r1)
6972
stg %r2,8(%r1)
70-
lgr %r1,%r2
73+
lgr %r9,%r2
7174
lgr %r2,%r3
72-
br %r1
75+
BR_EX %r9
7376

7477
.section .bss
7578
.align 8

arch/s390/kernel/swsusp.S

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <asm/ptrace.h>
1414
#include <asm/thread_info.h>
1515
#include <asm/asm-offsets.h>
16+
#include <asm/nospec-insn.h>
1617
#include <asm/sigp.h>
1718

1819
/*
@@ -24,6 +25,8 @@
2425
* (see below) in the resume process.
2526
* This function runs with disabled interrupts.
2627
*/
28+
GEN_BR_THUNK %r14
29+
2730
.section .text
2831
ENTRY(swsusp_arch_suspend)
2932
stmg %r6,%r15,__SF_GPRS(%r15)
@@ -103,7 +106,7 @@ ENTRY(swsusp_arch_suspend)
103106
spx 0x318(%r1)
104107
lmg %r6,%r15,STACK_FRAME_OVERHEAD + __SF_GPRS(%r15)
105108
lghi %r2,0
106-
br %r14
109+
BR_EX %r14
107110

108111
/*
109112
* Restore saved memory image to correct place and restore register context.
@@ -197,11 +200,10 @@ pgm_check_entry:
197200
larl %r15,init_thread_union
198201
ahi %r15,1<<(PAGE_SHIFT+THREAD_SIZE_ORDER)
199202
larl %r2,.Lpanic_string
200-
larl %r3,sclp_early_printk
201203
lghi %r1,0
202204
sam31
203205
sigp %r1,%r0,SIGP_SET_ARCHITECTURE
204-
basr %r14,%r3
206+
brasl %r14,sclp_early_printk
205207
larl %r3,.Ldisabled_wait_31
206208
lpsw 0(%r3)
207209
4:
@@ -267,7 +269,7 @@ restore_registers:
267269
/* Return 0 */
268270
lmg %r6,%r15,STACK_FRAME_OVERHEAD + __SF_GPRS(%r15)
269271
lghi %r2,0
270-
br %r14
272+
BR_EX %r14
271273

272274
.section .data..nosave,"aw",@progbits
273275
.align 8

0 commit comments

Comments
 (0)