Skip to content

Commit e9953b7

Browse files
committed
s390/boot: workaround llvm IAS bug
For at least the mvc and clc instructions llvm's integrated assembler can generate incorrect code. In particular this happens with decompressor boot code. The reason seems to be that relocations for the second displacement of each instruction are at incorrect locations (-/+: gas vs llvm IAS): mvc __LC_IO_NEW_PSW(16),.Lnewpsw results in 4: d2 0f 01 f0 00 00 mvc 496(16,%r0),0 - 8: R_390_12 .head.text+0x10 + 6: R_390_12 .head.text+0x10 and clc 0(3,%r4),.L_hdr results in 258: d5 02 40 00 00 00 clc 0(3,%r4),0 - 25c: R_390_12 .head.text+0x324 + 25a: R_390_12 .head.text+0x324 Workaround this by writing the code in a different way. Tested-by: Nathan Chancellor <[email protected]> Tested-by: Nick Desaulniers <[email protected]> Link: llvm/llvm-project#55411 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Heiko Carstens <[email protected]>
1 parent adda746 commit e9953b7

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

arch/s390/boot/head.S

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ ipl_start:
4242
# subroutine to wait for end I/O
4343
#
4444
.Lirqwait:
45-
mvc __LC_IO_NEW_PSW(16),.Lnewpsw # set up IO interrupt psw
45+
larl %r13,.Lnewpsw # set up IO interrupt psw
46+
mvc __LC_IO_NEW_PSW(16),0(%r13)
4647
lpsw .Lwaitpsw
4748
.Lioint:
4849
br %r14
@@ -155,9 +156,11 @@ ipl_start:
155156
lr %r2,%r3
156157
.Lnotrunc:
157158
l %r4,.Linitrd
158-
clc 0(3,%r4),.L_hdr # if it is HDRx
159+
larl %r13,.L_hdr
160+
clc 0(3,%r4),0(%r13) # if it is HDRx
159161
bz .Lagain1 # skip dataset header
160-
clc 0(3,%r4),.L_eof # if it is EOFx
162+
larl %r13,.L_eof
163+
clc 0(3,%r4),0(%r13) # if it is EOFx
161164
bz .Lagain1 # skip dateset trailer
162165

163166
lr %r5,%r2
@@ -181,9 +184,11 @@ ipl_start:
181184
.Lrdcont:
182185
l %r2,.Linitrd
183186

184-
clc 0(3,%r2),.L_hdr # skip HDRx and EOFx
187+
larl %r13,.L_hdr # skip HDRx and EOFx
188+
clc 0(3,%r2),0(%r13)
185189
bz .Lagain2
186-
clc 0(3,%r2),.L_eof
190+
larl %r13,.L_eof
191+
clc 0(3,%r2),0(%r13)
187192
bz .Lagain2
188193

189194
#
@@ -260,20 +265,23 @@ SYM_CODE_START_LOCAL(startup_normal)
260265
.fill 16,4,0x0
261266
0: lmh %r0,%r15,0(%r13) # clear high-order half of gprs
262267
sam64 # switch to 64 bit addressing mode
263-
basr %r13,0 # get base
264-
.LPG0:
265-
mvc __LC_EXT_NEW_PSW(16),.Lext_new_psw-.LPG0(%r13)
266-
mvc __LC_PGM_NEW_PSW(16),.Lpgm_new_psw-.LPG0(%r13)
267-
mvc __LC_IO_NEW_PSW(16),.Lio_new_psw-.LPG0(%r13)
268+
larl %r13,.Lext_new_psw
269+
mvc __LC_EXT_NEW_PSW(16),0(%r13)
270+
larl %r13,.Lpgm_new_psw
271+
mvc __LC_PGM_NEW_PSW(16),0(%r13)
272+
larl %r13,.Lio_new_psw
273+
mvc __LC_IO_NEW_PSW(16),0(%r13)
268274
xc 0x200(256),0x200 # partially clear lowcore
269275
xc 0x300(256),0x300
270276
xc 0xe00(256),0xe00
271277
xc 0xf00(256),0xf00
272-
lctlg %c0,%c15,.Lctl-.LPG0(%r13) # load control registers
278+
larl %r13,.Lctl
279+
lctlg %c0,%c15,0(%r13) # load control registers
273280
stcke __LC_BOOT_CLOCK
274281
mvc __LC_LAST_UPDATE_CLOCK(8),__LC_BOOT_CLOCK+1
275-
spt 6f-.LPG0(%r13)
276-
mvc __LC_LAST_UPDATE_TIMER(8),6f-.LPG0(%r13)
282+
larl %r13,6f
283+
spt 0(%r13)
284+
mvc __LC_LAST_UPDATE_TIMER(8),0(%r13)
277285
larl %r15,_stack_end-STACK_FRAME_OVERHEAD
278286
brasl %r14,sclp_early_setup_buffer
279287
brasl %r14,verify_facilities

0 commit comments

Comments
 (0)