s390x/snippets: Fix compilation with Clang 15
PATCH 1/1 s390x/snippets: Fix compilation with Clang 15
Clang complains:
s390x/snippets/c/cstart.S:22:13: error: invalid operand for instruction
lghi %r15, stackptr
^
Let's load the address with "larl" instead, like we already do it in s390x/cstart64.S. For this we should also switch to 64-bit mode first, then we also don't have to clear r15 right in front of this anymore.
Changing the code here triggered another problem: initial_cr0 must be aligned on a double-word boundary, otherwise the lctlg instruction will fail with an specification exception. This was just working by accident so far - add an ".align 8" now to avoid the problem.
--- s390x/snippets/c/cstart.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
s390x/snippets/c/cstart.S +4 -3
@@ -15,12 +15,12 @@ start: larl %r1, initial_cr0 lctlg %c0, %c0, 0(%r1) /* XOR all registers with themselves to clear them fully. */ - .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14 xgr \i,\i .endr - /* 0x3000 is the stack page for now */ - lghi %r15, stackptr sam64 + /* 0x3000 is the stack page for now */ + larl %r15, stackptr brasl %r14, main /* * If main() returns, we stop the CPU with the code below. We also
@@ -37,6 +37,7 @@ exit: xgr %r0, %r0 sigp %r2, %r0, SIGP_STOP + .align 8 initial_cr0: /* enable AFP-register control, so FP regs (+BFP instr) can be used */ .quad 0x0000000000040000
Signature · 1 line
2.31.1
Quoted 10 lines · On Tue, 4 Apr 2023 12:14:34 +0200 Thomas Huth <[email protected]> wrote:
Clang complains:
s390x/snippets/c/cstart.S:22:13: error: invalid operand for instruction
lghi %r15, stackptr^Let's load the address with "larl" instead, like we already do it in
s390x/cstart64.S. For this we should also switch to 64-bit mode first, then we also don't have to clear r15 right in front of this anymore.
Quoted 7 lines
Changing the code here triggered another problem:
initial_cr0must be aligned on a double-word boundary, otherwise the lctlg instruction will fail with an specification exception. This was just working by accident so far - add an ".align 8" now to avoid the problem.Signed-off-by Thomas Huth <[email protected]>
Quoted 32 lines
--- s390x/snippets/c/cstart.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)s390x/snippets/c/cstart.S +4
-3@@ -15,12 +15,12 @@ start: larl %r1, initial_cr0 lctlg %c0, %c0, 0(%r1) /* XOR all registers with themselves to clear them fully. */ - .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14 xgr \i,\i .endr - /* 0x3000 is the stack page for now */ - lghi %r15, stackptr sam64 + /* 0x3000 is the stack page for now */ + larl %r15, stackptr brasl %r14, main /* * If main() returns, we stop the CPU with the code below. We also@@ -37,6 +37,7 @@ exit: xgr %r0, %r0 sigp %r2, %r0, SIGP_STOP + .align 8 initial_cr0: /* enable AFP-register control, so FP regs (+BFP instr) can be used */ .quad 0x0000000000040000
Quoted 26 lines · Thomas Huth
Clang complains:
s390x/snippets/c/cstart.S:22:13: error: invalid operand for instruction
lghi %r15, stackptr^Let's load the address with "larl" instead, like we already do it in
s390x/cstart64.S. For this we should also switch to 64-bit mode first, then we also don't have to clear r15 right in front of this anymore.Changing the code here triggered another problem:
initial_cr0must be aligned on a double-word boundary, otherwise the lctlg instruction will fail with an specification exception. This was just working by accident so far - add an ".align 8" now to avoid the problem.Signed-off-by Thomas Huth <[email protected]>--- s390x/snippets/c/cstart.S | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)s390x/snippets/c/cstart.S +0
-0
s390x/snippets/c/cstart.S start: · line 18
Quoted 5 lines
s390x/snippets/c/cstart.S +1
-1@@ -15,12 +15,12 @@ start: larl %r1, initial_cr0 lctlg %c0, %c0, 0(%r1) /* XOR all registers with themselves to clear them fully. */ - .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 + .irp i, 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14
Eh, I would have left that in, it doesn't hurt us after all.
Quoted 18 lines
s390x/snippets/c/cstart.S +3
-2xgr \i,\i .endr - /* 0x3000 is the stack page for now */ - lghi %r15, stackptr sam64 + /* 0x3000 is the stack page for now */ + larl %r15, stackptr brasl %r14, main /* * If main() returns, we stop the CPU with the code below. We also@@ -37,6 +37,7 @@ exit: xgr %r0, %r0 sigp %r2, %r0, SIGP_STOP + .align 8 initial_cr0: /* enable AFP-register control, so FP regs (+BFP instr) can be used */ .quad 0x0000000000040000
Quoting Thomas Huth (2023-04-04 12:14:34)
Quoted 10 lines
Clang complains:
s390x/snippets/c/cstart.S:22:13: error: invalid operand for instruction
lghi %r15, stackptr^Let's load the address with "larl" instead, like we already do it in
s390x/cstart64.S. For this we should also switch to 64-bit mode first, then we also don't have to clear r15 right in front of this anymore.
Quoted 7 lines
Changing the code here triggered another problem:
initial_cr0must be aligned on a double-word boundary, otherwise the lctlg instruction will fail with an specification exception. This was just working by accident so far - add an ".align 8" now to avoid the problem.Signed-off-by Thomas Huth <[email protected]>