s390/test_unwind: use raw opcode instead of invalid instruction
PATCH 1/1 s390/test_unwind: use raw opcode instead of invalid instruction
Building with clang & LLVM_IAS=1 leads to an error:
arch/s390/lib/test_unwind.c:179:4: error: invalid register pair
" mvcl %%r1,%%r1\n"
^The test creates an invalid instruction that would trap at runtime, but the LLVM inline assembler tries to validate it at compile time too.
Use the raw instruction opcode instead.
--- arch/s390/lib/test_unwind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/s390/lib/test_unwind.c +1 -1
@@ -176,7 +176,7 @@ static noinline int unwindme_func4(struct unwindme *u)* trigger specification exception */ asmvolatile ( -" mvcl %%r1,%%r1\n" +" .insn e,0x0e11\n" /* mvcl %%r1,%%r1" */ "0: nopr %%r7\n" EX_TABLE(0b, 0b) :);
Signature · 1 line
2.25.1
Quoted 6 lines · Ilie Halip
Building with clang & LLVM_IAS=1 leads to an error:
arch/s390/lib/test_unwind.c:179:4: error: invalid register pair " mvcl %%r1,%%r1\n" ^
Quoted 8 lines
The test creates an invalid instruction that would trap at runtime, but the LLVM inline assembler tries to validate it at compile time too.
Use the raw instruction opcode instead.
Reported-by Nick Desaulniers <[email protected]>Signed-off-by Ilie Halip <[email protected]>
Ilie, thanks for the patch!
So if I understand
https://sourceware.org/binutils/docs/as/s390-Directives.html#s390-Directives
https://sourceware.org/binutils/docs/as/s390-Formats.html
that e, prefix is for 16B opcodes?
LGTM, thanks again.
I triple checked that GAS, clang, and GNU objdump are in agreement in terms of encoding here.
Quoted 20 lines
--- arch/s390/lib/test_unwind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/lib/test_unwind.c +1
-2@@ -176,7 +176,7 @@ static noinline int unwindme_func4(struct unwindme *u)* trigger specification exception */ asmvolatile ( -" mvcl %%r1,%%r1\n" +" .insn e,0x0e11\n" /* mvcl %%r1,%%r1" */ "0: nopr %%r7\n" EX_TABLE(0b, 0b) :); --2.25.1
Signature · 2 lines
Thanks, ~Nick Desaulniers
Am 19.11.21 um 02:10 schrieb Nick Desaulniers:
Quoted 16 lines · Ilie Halip
Quoted 6 lines
Building with clang & LLVM_IAS=1 leads to an error:
arch/s390/lib/test_unwind.c:179:4: error: invalid register pair " mvcl %%r1,%%r1\n" ^Quoted 8 lines
The test creates an invalid instruction that would trap at runtime, but the LLVM inline assembler tries to validate it at compile time too.
Use the raw instruction opcode instead.
Reported-by Nick Desaulniers <[email protected]>Signed-off-by Ilie Halip <[email protected]>
Quoted 6 lines
Ilie, thanks for the patch!
So if I understand
https://sourceware.org/binutils/docs/as/s390-Directives.html#s390-Directives
https://sourceware.org/binutils/docs/as/s390-Formats.html
thate,prefix is for 16B opcodes?
e is an instruction format as specified by the architecture. See http://publibfp.dhe.ibm.com/epubs/pdf/a227832c.pdf
without any parameters.
Normally RR would be the right thing for MVCL, but since we try to build an invalid opcode without the assembler noticing (ab)using e seem like a safer approach.
Quoted 4 lines
LGTM, thanks again.
Suggested-by Ulrich Weigand <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>
added those and added my RB. applied to the s390 tree. Thanks
Quoted 26 lines
I triple checked that GAS, clang, and GNU objdump are in agreement in terms of encoding here.
Quoted 20 lines
--- arch/s390/lib/test_unwind.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/s390/lib/test_unwind.c +1
-2@@ -176,7 +176,7 @@ static noinline int unwindme_func4(struct unwindme *u)* trigger specification exception */ asmvolatile ( -" mvcl %%r1,%%r1\n" +" .insn e,0x0e11\n" /* mvcl %%r1,%%r1" */ "0: nopr %%r7\n" EX_TABLE(0b, 0b) :); --2.25.1
Am 19.11.21 um 10:39 schrieb Christian Borntraeger:
Quoted 21 lines
Am 19.11.21 um 02:10 schrieb Nick Desaulniers:
Quoted 18 lines · Ilie Halip
Quoted 6 lines
Building with clang & LLVM_IAS=1 leads to an error:
arch/s390/lib/test_unwind.c:179:4: error: invalid register pair " mvcl %%r1,%%r1\n"
^Quoted 8 lines
The test creates an invalid instruction that would trap at runtime, but the LLVM inline assembler tries to validate it at compile time too.
Use the raw instruction opcode instead.
Reported-by Nick Desaulniers <[email protected]>Signed-off-by Ilie Halip <[email protected]>Ilie, thanks for the patch!
Quoted 7 lines
Quoted 4 lines
So if I understand
https://sourceware.org/binutils/docs/as/s390-Directives.html#s390-Directives
https://sourceware.org/binutils/docs/as/s390-Formats.html
thate,prefix is for 16B opcodes?e is an instruction format as specified by the architecture. See http://publibfp.dhe.ibm.com/epubs/pdf/a227832c.pdf
(page 5-3 for the instruction formats and page 7-289 for MVCL)
Heiko Carstens
maintainerQuoted 17 lines · Christian Borntraeger
Quoted 4 lines
So if I understand
https://sourceware.org/binutils/docs/as/s390-Directives.html#s390-Directives
https://sourceware.org/binutils/docs/as/s390-Formats.html
thate,prefix is for 16B opcodes?e is an instruction format as specified by the architecture. See http://publibfp.dhe.ibm.com/epubs/pdf/a227832c.pdf
without any parameters.
Normally RR would be the right thing for MVCL, but since we try to build an invalid opcode without the assembler noticing (ab)using e seem like a safer approach.Quoted 4 lines
LGTM, thanks again.
Suggested-by Ulrich Weigand <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>added those and added my RB. applied to the s390 tree. Thanks
..
Quoted 10 lines
Quoted 10 lines
arch/s390/lib/test_unwind.c static noinline int unwindme_func4(struct unwindme *u) · line 179
Quoted 10 lines
arch/s390/lib/test_unwind.c +1
-1@@ -176,7 +176,7 @@ static noinline int unwindme_func4(struct unwindme *u)* trigger specification exception */ asmvolatile ( - " mvcl %%r1,%%r1\n" + " .insn e,0x0e11\n" /* mvcl %%r1,%%r1" */
Sorry, I disagree with this. As you said above rr would be the correct format for this instruction. If we go for the e format then we should also use an instruction with e format.
Which in this case would simply be an illegal opcode, which would be sufficient for what this code is good for: ".insn e,0x0000".
Plus a fixup of the comment above, since this would generate an operation insteand of a specification exception. Just a generic "exception" would be good enough for the comment.
Am 19.11.21 um 11:54 schrieb Heiko Carstens:
Quoted 19 lines · Christian Borntraeger
Quoted 17 lines
Quoted 4 lines
So if I understand
https://sourceware.org/binutils/docs/as/s390-Directives.html#s390-Directives
https://sourceware.org/binutils/docs/as/s390-Formats.html
thate,prefix is for 16B opcodes?e is an instruction format as specified by the architecture. See http://publibfp.dhe.ibm.com/epubs/pdf/a227832c.pdf
without any parameters.
Normally RR would be the right thing for MVCL, but since we try to build an invalid opcode without the assembler noticing (ab)using e seem like a safer approach.Quoted 4 lines
LGTM, thanks again.
Suggested-by Ulrich Weigand <[email protected]>Reviewed-by Nick Desaulniers <[email protected]>added those and added my RB. applied to the s390 tree. Thanks
..
Quoted 16 lines
Quoted 10 lines
Quoted 10 lines
arch/s390/lib/test_unwind.c static noinline int unwindme_func4(struct unwindme *u) · line 179
Quoted 10 lines
arch/s390/lib/test_unwind.c +1
-1@@ -176,7 +176,7 @@ static noinline int unwindme_func4(struct unwindme *u)* trigger specification exception */ asmvolatile ( - " mvcl %%r1,%%r1\n" + " .insn e,0x0e11\n" /* mvcl %%r1,%%r1" */Sorry, I disagree with this. As you said above rr would be the correct format for this instruction. If we go for the e format then we should also use an instruction with e format.
Which in this case would simply be an illegal opcode, which would be sufficient for what this code is good for: ".insn e,0x0000".
Why not simply use .short then?
Heiko Carstens
maintainerQuoted 10 lines · Christian Borntraeger
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
arch/s390/lib/test_unwind.c static noinline int unwindme_func4(struct unwindme *u) · line 179
Quoted 2 lines
arch/s390/lib/test_unwind.c +1
-1-" mvcl %%r1,%%r1\n" +" .insn e,0x0e11\n" /* mvcl %%r1,%%r1" */ Sorry, I disagree with this. As you said above rr would be the correct format for this instruction. If we go for the e format then we should also use an instruction with e format.
Which in this case would simply be an illegal opcode, which would be sufficient for what this code is good for: ".insn e,0x0000".Why not simply use .short then?
.short bypasses all sanity checks while .insn does not, so I think that should be preferred. But I don't care too much.
Am 19.11.21 um 12:09 schrieb Heiko Carstens:
Quoted 10 lines · Christian Borntraeger
Quoted 9 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
arch/s390/lib/test_unwind.c static noinline int unwindme_func4(struct unwindme *u) · line 179
Quoted 2 lines
arch/s390/lib/test_unwind.c +1
-1-" mvcl %%r1,%%r1\n" +" .insn e,0x0e11\n" /* mvcl %%r1,%%r1" */ Sorry, I disagree with this. As you said above rr would be the correct format for this instruction. If we go for the e format then we should also use an instruction with e format.
Which in this case would simply be an illegal opcode, which would be sufficient for what this code is good for: ".insn e,0x0000".
Quoted 4 lines
Quoted 1 line
Why not simply use .short then?
.short bypasses all sanity checks while .insn does not, so I think that should be preferred. But I don't care too much.
Heiko,
I am fine with ".insn e,0x0000" and the a changed comment that changes "specification exception" to "operation exception". Do you want Ilie to resend or simply fixup?
Heiko Carstens
maintainerQuoted 13 lines · Christian Borntraeger
Am 19.11.21 um 12:09 schrieb Heiko Carstens:
Quoted 12 lines · Christian Borntraeger
Quoted 10 lines
Quoted 8 lines
Quoted 2 lines
Quoted 2 lines
Review
Quoted 2 lines
(quoted diff) +1
-1- " mvcl %%r1,%%r1\n" + " .insn e,0x0e11\n" /* mvcl %%r1,%%r1" */Sorry, I disagree with this. As you said above rr would be the correct format for this instruction. If we go for the e format then we should also use an instruction with e format.
Which in this case would simply be an illegal opcode, which would be sufficient for what this code is good for: ".insn e,0x0000".Why not simply use .short then?
Quoted 7 lines
Quoted 2 lines
.short bypasses all sanity checks while .insn does not, so I think that should be preferred. But I don't care too much.
Heiko,
I am fine with ".insn e,0x0000" and the a changed comment that changes "specification exception" to "operation exception". Do you want Ilie to resend or simply fixup?
I'll simply change it. Let's don't spend more time on this.