Skip to contentSkip to conversation

target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting

PATCH Superseded Ilya Leoshkevich 7 participants 15 messages Jun 23, 2021 – Jul 12, 2021

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

v5 cover target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting

qemu-s390x puts a wrong value into SIGILL's siginfo_t's psw.addr: it should be a pointer to the instruction following the illegal instruction, but at the moment it is a pointer to the illegal instruction itself. This breaks OpenJDK, which relies on this value. A similar problem exists for SIGFPE and SIGTRAP.

Patch 1 fixes the issue, patch 2 adds a test.

v1: https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06592.html
v1 -> v2: Use a better buglink (Cornelia), simplify the inline asm
magic in the test and add an explanation (David).

v2: https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06649.html
v2 -> v3: Fix SIGSEGV handling (found when trying to run valgrind under

          qemu-user).

v3: https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg00299.html
v3 -> v4: Fix compiling the test on Ubuntu 20.04 (Jonathan).

v4: https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg05848.html
v4 -> v5: Greatly simplify the fix (Ulrich).

Note: the compare-and-trap SIGFPE issue is being fixed separately.
https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg05690.html

Ilya Leoshkevich (2):
target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting tests/tcg/s390x: Test SIGILL and SIGSEGV handling

 linux-user/s390x/cpu_loop.c     |   5 +
 tests/tcg/s390x/Makefile.target |   1 +
 tests/tcg/s390x/signal.c        | 165 ++++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 tests/tcg/s390x/signal.c
Signature · 1 line
2.31.1
#1 lore raw

PATCH v5 1/2 target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting

For SIGILL, SIGFPE and SIGTRAP the PSW must point after the instruction, and at the instruction for other signals. Currently under qemu-user it always points at the instruction.

Fix by advancing psw.addr for these signals.

---
 linux-user/s390x/cpu_loop.c | 5 +++++
 1 file changed, 5 insertions(+)
linux-user/s390x/cpu_loop.c +5 -0
index 30568139df..230217feeb 100644
@@ -133,6 +133,11 @@ void cpu_loop(CPUS390XState *env)
 
         do_signal_pc:
             addr = env->psw.addr;
+            /*
+             * For SIGILL, SIGFPE and SIGTRAP the PSW must point after the
+             * instruction.
+             */
+            env->psw.addr += env->int_pgm_ilen;
         do_signal:
             info.si_signo = sig;
             info.si_errno = 0;
Signature · 1 line
2.31.1
#2 lore raw
Quoted 18 lines · Ilya Leoshkevich

For SIGILL, SIGFPE and SIGTRAP the PSW must point after the instruction, and at the instruction for other signals. Currently under qemu-user it always points at the instruction.

Fix by advancing psw.addr for these signals.

---
  linux-user/s390x/cpu_loop.c | 5 +++++
  1 file changed, 5 insertions(+)
linux-user/s390x/cpu_loop.c +0 -0
index 30568139df..230217feeb 100644

linux-user/s390x/cpu_loop.c void cpu_loop(CPUS390XState *env) · line 140

Quoted 8 lines
linux-user/s390x/cpu_loop.c +5 -0
@@ -133,6 +133,11 @@ void cpu_loop(CPUS390XState *env)
 
          do_signal_pc:
              addr = env->psw.addr;
+            /*
+             * For SIGILL, SIGFPE and SIGTRAP the PSW must point after the
+             * instruction.
+             */
+            env->psw.addr += env->int_pgm_ilen;

We also reach this path via EXCP_DEBUG. How can we expect env->int_pgm_ilen to contain something sensible in that case?

Signature · 3 lines
Thanks,

David / dhildenb
#3 lore raw
Quoted 25 lines · David Hildenbrand
Quoted 24 lines · Ilya Leoshkevich

For SIGILL, SIGFPE and SIGTRAP the PSW must point after the instruction, and at the instruction for other signals. Currently under
qemu-user it always points at the instruction.

Fix by advancing psw.addr for these signals.

---
  linux-user/s390x/cpu_loop.c | 5 +++++

  1 file changed, 5 insertions(+)
linux- renamed from linux-user/s390x/cpu_loop.c +0 -0

user/s390x/cpu_loop.c
index 30568139df..230217feeb 100644

linux-user/s390x/cpu_loop.c +0 -0
@@ -133,6 +133,11 @@ void cpu_loop(CPUS390XState *env)


          do_signal_pc:
              addr = env->psw.addr;
+            /*

Quoted 8 lines
Quoted 5 lines

+             * For SIGILL, SIGFPE and SIGTRAP the PSW must point after the
+             * instruction.
+             */
+            env->psw.addr += env->int_pgm_ilen;

We also reach this path via EXCP_DEBUG. How can we expect env->int_pgm_ilen to contain something sensible in that case?

You are right, this breaks breakpoints after getting any PGM exception (they turn into "Program received signal SIGTRAP, Trace/breakpoint trap." instead of the usual "Breakpoint N").

We don't need a PSW rewind here, since it's already incremented throught the following sequence:

1) GDB asks QEMU to set a breakpoint using a $Z0 packet.
2) translator_loop() notices the breakpoint and calls s390x_tr_breakpoint_check().
3) s390x_tr_breakpoint_check() sets DisasContextBase.is_jmp to DISAS_PC_STALE and increments DisasContextBase.pc_next by 2.
4) translator_loop() calls s390x_tr_tb_stop().
5) s390x_tr_tb_stop() calls update_psw_addr(), so the JITed code increments the PSWA by 2 as well.
6) s390x_tr_tb_stop() calls gen_exception(EXCP_DEBUG).

What do you think about the following amend?

linux-user/s390x/cpu_loop.c +2 -1
@@ -64,7 +64,13 @@ void cpu_loop(CPUS390XState *env)
         case EXCP_DEBUG:
             sig = TARGET_SIGTRAP;
             n = TARGET_TRAP_BRKPT;
-            goto do_signal_pc;
+            /*
+             * For SIGTRAP the PSW must point after the instruction,

which it
+ * already does thanks to s390x_tr_tb_stop(). si_addr
doesn't need
+ * to be filled.
+ */
+ addr = 0;

+            goto do_signal;
         case EXCP_PGM:
             n = env->int_pgm_code;
             switch (n) {
@@ -134,8 +140,7 @@ void cpu_loop(CPUS390XState *env)
         do_signal_pc:
             addr = env->psw.addr;
             /*

- * For SIGILL, SIGFPE and SIGTRAP the PSW must point after
the
- * instruction.
+ * For SIGILL and SIGFPE the PSW must point after the
instruction.

              */
             env->psw.addr += env->int_pgm_ilen;
         do_signal:

Best regards,
Ilya

#4 lore raw
Quoted 66 lines · Ilya Leoshkevich
Quoted 22 lines · David Hildenbrand
Quoted 21 lines · Ilya Leoshkevich

For SIGILL, SIGFPE and SIGTRAP the PSW must point after the instruction, and at the instruction for other signals. Currently under
qemu-user it always points at the instruction.

Fix by advancing psw.addr for these signals.

---
   linux-user/s390x/cpu_loop.c | 5 +++++
   1 file changed, 5 insertions(+)
linux- renamed from linux-user/s390x/cpu_loop.c +0 -0

user/s390x/cpu_loop.c
index 30568139df..230217feeb 100644

linux-user/s390x/cpu_loop.c +0 -0
@@ -133,6 +133,11 @@ void cpu_loop(CPUS390XState *env)
 
Quoted 11 lines
Quoted 8 lines
linux-user/s390x/cpu_loop.c +2 -0
           do_signal_pc:
               addr = env->psw.addr;
+            /*
+             * For SIGILL, SIGFPE and SIGTRAP the PSW must point

after the
+             * instruction.
+             */
+            env->psw.addr += env->int_pgm_ilen;

We also reach this path via EXCP_DEBUG. How can we expect env->int_pgm_ilen to contain something sensible in that case?

You are right, this breaks breakpoints after getting any PGM exception (they turn into "Program received signal SIGTRAP, Trace/breakpoint trap." instead of the usual "Breakpoint N").

We don't need a PSW rewind here, since it's already incremented throught the following sequence:

1) GDB asks QEMU to set a breakpoint using a $Z0 packet.
2) translator_loop() notices the breakpoint and calls

    s390x_tr_breakpoint_check().

3) s390x_tr_breakpoint_check() sets DisasContextBase.is_jmp to DISAS_PC_STALE and increments DisasContextBase.pc_next by 2.
4) translator_loop() calls s390x_tr_tb_stop().
5) s390x_tr_tb_stop() calls update_psw_addr(), so the JITed code increments the PSWA by 2 as well.
6) s390x_tr_tb_stop() calls gen_exception(EXCP_DEBUG).

What do you think about the following amend?

linux-user/s390x/cpu_loop.c +2 -1
@@ -64,7 +64,13 @@ void cpu_loop(CPUS390XState *env)
          case EXCP_DEBUG:
              sig = TARGET_SIGTRAP;
              n = TARGET_TRAP_BRKPT;
-            goto do_signal_pc;
+            /*
+             * For SIGTRAP the PSW must point after the instruction,

which it
+ * already does thanks to s390x_tr_tb_stop(). si_addr
doesn't need

linux-user/s390x/cpu_loop.c

Quoted 4 lines
linux-user/s390x/cpu_loop.c +4 -0
+             * to be filled.
+             */
+            addr = 0;
+            goto do_signal;

Looks better to me, but I'm not an expert on signals, so I cannot tell what si_addr is supposed to contain in that case.

Signature · 3 lines
Thanks,

David / dhildenb
#5 lore raw
Quoted 67 lines · David Hildenbrand
Quoted 66 lines · Ilya Leoshkevich
Quoted 25 lines · David Hildenbrand
Quoted 24 lines · Ilya Leoshkevich

For SIGILL, SIGFPE and SIGTRAP the PSW must point after the instruction, and at the instruction for other signals. Currently under
qemu-user it always points at the instruction.

Fix by advancing psw.addr for these signals.

---
   linux-user/s390x/cpu_loop.c | 5 +++++

   1 file changed, 5 insertions(+)
linux- renamed from linux-user/s390x/cpu_loop.c +0 -0

user/s390x/cpu_loop.c
index 30568139df..230217feeb 100644

linux-user/s390x/cpu_loop.c +0 -0
@@ -133,6 +133,11 @@ void cpu_loop(CPUS390XState *env)


           do_signal_pc:
               addr = env->psw.addr;
+            /*

Quoted 8 lines
Quoted 5 lines

+             * For SIGILL, SIGFPE and SIGTRAP the PSW must point after the
+             * instruction.
+             */
+            env->psw.addr += env->int_pgm_ilen;

We also reach this path via EXCP_DEBUG. How can we expect env->int_pgm_ilen to contain something sensible in that case?

You are right, this breaks breakpoints after getting any PGM exception
(they turn into "Program received signal SIGTRAP, Trace/breakpoint trap." instead of the usual "Breakpoint N").

We don't need a PSW rewind here, since it's already incremented throught the following sequence:

1) GDB asks QEMU to set a breakpoint using a $Z0 packet.
2) translator_loop() notices the breakpoint and calls s390x_tr_breakpoint_check().
3) s390x_tr_breakpoint_check() sets DisasContextBase.is_jmp to DISAS_PC_STALE and increments DisasContextBase.pc_next by 2.
4) translator_loop() calls s390x_tr_tb_stop().
5) s390x_tr_tb_stop() calls update_psw_addr(), so the JITed code increments the PSWA by 2 as well.
6) s390x_tr_tb_stop() calls gen_exception(EXCP_DEBUG).

What do you think about the following amend?

linux-user/s390x/cpu_loop.c +0 -0
@@ -64,7 +64,13 @@ void cpu_loop(CPUS390XState *env)

          case EXCP_DEBUG:
              sig = TARGET_SIGTRAP;
              n = TARGET_TRAP_BRKPT;
-            goto do_signal_pc;
+            /*
+             * For SIGTRAP the PSW must point after the instruction, which it
+             * already does thanks to s390x_tr_tb_stop(). si_addr

Quoted 9 lines
Quoted 5 lines

doesn't need
+             * to be filled.
+             */
+            addr = 0;
+            goto do_signal;

Looks better to me, but I'm not an expert on signals, so I cannot tell what si_addr is supposed to contain in that case.

Thanks, I'll send a v6 then. I used rt_sigaction(2) man here:

When SIGTRAP is delivered in response to a ptrace(2) event (PTRACE_EVENT_foo), si_addr is not populated

I think EXCP_DEBUG corresponds only to this case - there doesn't seem to be a way to generate it without attaching gdb.

#6 lore raw
Quoted 6 lines · Ilya Leoshkevich
Quoted 4 lines · David Hildenbrand

Looks better to me, but I'm not an expert on signals, so I cannot tell what si_addr is supposed to contain in that case.

Quoted 7 lines

Thanks, I'll send a v6 then. I used rt_sigaction(2) man here:

When SIGTRAP is delivered in response to a ptrace(2) event (PTRACE_EVENT_foo), si_addr is not populated

I think EXCP_DEBUG corresponds only to this case - there doesn't seem to be a way to generate it without attaching gdb.

The s390x Linux kernel does in fact set si_addr to the address of the instruction triggering the signal for SIGTRAP, just like for SIGILL or SIGFPE. On the other hand, GDB does not rely on that (since this is not the case on other platforms, like the man page above indicates), so this looks OK to me.

Bye,
Ulrich

Signature · 3 lines
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  [email protected]
#7 lore raw

PATCH v5 2/2 tests/tcg/s390x: Test SIGILL and SIGSEGV handling

In reply to Ilya Leoshkevich

Verify that s390x-specific uc_mcontext.psw.addr is reported correctly.

---
 tests/tcg/s390x/Makefile.target |   1 +
 tests/tcg/s390x/signal.c        | 165 ++++++++++++++++++++++++++++++++
 2 files changed, 166 insertions(+)
 create mode 100644 tests/tcg/s390x/signal.c
tests/tcg/s390x/Makefile.target +1 -0
index 241ef28f61..cdb7d85316 100644
@@ -8,3 +8,4 @@ TESTS+=exrl-trtr
 TESTS+=pack
 TESTS+=mvo
 TESTS+=mvc
+TESTS+=signal
tests/tcg/s390x/signal.c new file +165 -0

165 lines not on this page · raw message

Signature · 1 line
2.31.1
#8 lore raw
In reply to Ilya Leoshkevich
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Type: series
Message-id: [email protected]
Subject: [PATCH v5 0/2] target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
- [tag update] patchew/[email protected] -> patchew/[email protected]
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
56bc4f3 tests/tcg/s390x: Test SIGILL and SIGSEGV handling b6b6d39 target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting

=== OUTPUT BEGIN ===
1/2 Checking commit b6b6d3978456 (target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting) 2/2 Checking commit 56bc4f3bb893 (tests/tcg/s390x: Test SIGILL and SIGSEGV handling)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating?
#26:
new file mode 100644

ERROR: externs should be avoided in .c files
#44: FILE: tests/tcg/s390x/signal.c:14:
+void illegal_op(void);

ERROR: externs should be avoided in .c files
#45: FILE: tests/tcg/s390x/signal.c:15:
+void after_illegal_op(void);

ERROR: externs should be avoided in .c files
#51: FILE: tests/tcg/s390x/signal.c:21:
+void stg(void *dst, unsigned long src);

ERROR: externs should be avoided in .c files
#56: FILE: tests/tcg/s390x/signal.c:26:
+void mvc_8(void *dst, void *src);

total: 4 errors, 1 warnings, 169 lines checked

Patch 2/2 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

=== OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#9 lore raw
In reply to Ilya Leoshkevich
Quoted 29 lines · Ilya Leoshkevich

qemu-s390x puts a wrong value into SIGILL's siginfo_t's psw.addr: it should be a pointer to the instruction following the illegal instruction, but at the moment it is a pointer to the illegal instruction itself. This breaks OpenJDK, which relies on this value. A similar problem exists for SIGFPE and SIGTRAP.

Patch 1 fixes the issue, patch 2 adds a test.

v1: https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06592.html
v1 -> v2: Use a better buglink (Cornelia), simplify the inline asm
magic in the test and add an explanation (David).

v2: https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06649.html
v2 -> v3: Fix SIGSEGV handling (found when trying to run valgrind under

          qemu-user).

v3: https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg00299.html
v3 -> v4: Fix compiling the test on Ubuntu 20.04 (Jonathan).

v4: https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg05848.html
v4 -> v5: Greatly simplify the fix (Ulrich).

Note: the compare-and-trap SIGFPE issue is being fixed separately.
https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg05690.html

Ilya Leoshkevich (2):
target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting tests/tcg/s390x: Test SIGILL and SIGSEGV handling

Quoted 5 lines
 linux-user/s390x/cpu_loop.c     |   5 +
 tests/tcg/s390x/Makefile.target |   1 +
 tests/tcg/s390x/signal.c        | 165 ++++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 tests/tcg/s390x/signal.c

What's the status of this and <[email protected]>? linux-user is not really my turf, but it would be sad if this fell through the cracks.

#10 lore raw

Le 02/07/2021 à 12:34, Cornelia Huck a écrit :

Quoted 37 lines · Ilya Leoshkevich
Quoted 30 lines

qemu-s390x puts a wrong value into SIGILL's siginfo_t's psw.addr: it should be a pointer to the instruction following the illegal instruction, but at the moment it is a pointer to the illegal instruction itself. This breaks OpenJDK, which relies on this value. A similar problem exists for SIGFPE and SIGTRAP.

Patch 1 fixes the issue, patch 2 adds a test.

v1: https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06592.html
v1 -> v2: Use a better buglink (Cornelia), simplify the inline asm
magic in the test and add an explanation (David).

v2: https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06649.html
v2 -> v3: Fix SIGSEGV handling (found when trying to run valgrind under

          qemu-user).

v3: https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg00299.html
v3 -> v4: Fix compiling the test on Ubuntu 20.04 (Jonathan).

v4: https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg05848.html
v4 -> v5: Greatly simplify the fix (Ulrich).

Note: the compare-and-trap SIGFPE issue is being fixed separately.
https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg05690.html

Ilya Leoshkevich (2):
target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting tests/tcg/s390x: Test SIGILL and SIGSEGV handling

Quoted 5 lines
 linux-user/s390x/cpu_loop.c     |   5 +
 tests/tcg/s390x/Makefile.target |   1 +
 tests/tcg/s390x/signal.c        | 165 ++++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 tests/tcg/s390x/signal.c
Quoted 5 lines

What's the status of this and <[email protected]>? linux-user is not really my turf, but it would be sad if this fell through the cracks.

If from the S390x point of view they are correct, I can collect them via linux-user.

Thanks,
Laurent

#11 lore raw
Quoted 38 lines · Laurent Vivier

Le 02/07/2021 à 12:34, Cornelia Huck a écrit :

Quoted 37 lines · Ilya Leoshkevich
Quoted 35 lines

qemu-s390x puts a wrong value into SIGILL's siginfo_t's psw.addr: it should be a pointer to the instruction following the illegal instruction, but at the moment it is a pointer to the illegal instruction itself. This breaks OpenJDK, which relies on this value. A similar problem exists for SIGFPE and SIGTRAP.

Patch 1 fixes the issue, patch 2 adds a test.

v1: https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06592.html
v1 -> v2: Use a better buglink (Cornelia), simplify the inline asm
magic in the test and add an explanation (David).

v2: https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06649.html
v2 -> v3: Fix SIGSEGV handling (found when trying to run valgrind under

          qemu-user).

v3: https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg00299.html
v3 -> v4: Fix compiling the test on Ubuntu 20.04 (Jonathan).

v4: https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg05848.html
v4 -> v5: Greatly simplify the fix (Ulrich).

Note: the compare-and-trap SIGFPE issue is being fixed separately.
https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg05690.html

Ilya Leoshkevich (2):
target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting tests/tcg/s390x: Test SIGILL and SIGSEGV handling

 linux-user/s390x/cpu_loop.c     |   5 +
 tests/tcg/s390x/Makefile.target |   1 +
 tests/tcg/s390x/signal.c        | 165 ++++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 tests/tcg/s390x/signal.c
Quoted 7 lines
Quoted 5 lines

What's the status of this and <[email protected]>? linux-user is not really my turf, but it would be sad if this fell through the cracks.

If from the S390x point of view they are correct, I can collect them via linux-user.

It's certainly correct that SIGILL, SIGFPE and SIGTRAP are delivered with psw.addr pointing *after* the faulting instruction, that forms in effect part of the kernel ABI on s390x. We're planning to document this in the next revision of the ABI document, see here: https://github.com/IBM/s390x-abi/issues/2

I can also confirm that this patch fixes the problems I was seeing when running the s390x wasmtime JIT under qemu.

Bye,
Ulrich

Signature · 3 lines
  Dr. Ulrich Weigand
  GNU/Linux compilers and toolchain
  [email protected]
Acked-by
#12 lore raw
In reply to Laurent Vivier
Quoted 38 lines · Laurent Vivier

Le 02/07/2021 à 12:34, Cornelia Huck a écrit :

Quoted 37 lines · Ilya Leoshkevich
Quoted 35 lines

qemu-s390x puts a wrong value into SIGILL's siginfo_t's psw.addr: it should be a pointer to the instruction following the illegal instruction, but at the moment it is a pointer to the illegal instruction itself. This breaks OpenJDK, which relies on this value. A similar problem exists for SIGFPE and SIGTRAP.

Patch 1 fixes the issue, patch 2 adds a test.

v1: https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06592.html
v1 -> v2: Use a better buglink (Cornelia), simplify the inline asm
magic in the test and add an explanation (David).

v2: https://lists.nongnu.org/archive/html/qemu-devel/2021-05/msg06649.html
v2 -> v3: Fix SIGSEGV handling (found when trying to run valgrind under

          qemu-user).

v3: https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg00299.html
v3 -> v4: Fix compiling the test on Ubuntu 20.04 (Jonathan).

v4: https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg05848.html
v4 -> v5: Greatly simplify the fix (Ulrich).

Note: the compare-and-trap SIGFPE issue is being fixed separately.
https://lists.nongnu.org/archive/html/qemu-devel/2021-06/msg05690.html

Ilya Leoshkevich (2):
target/s390x: Fix SIGILL/SIGFPE/SIGTRAP psw.addr reporting tests/tcg/s390x: Test SIGILL and SIGSEGV handling

 linux-user/s390x/cpu_loop.c     |   5 +
 tests/tcg/s390x/Makefile.target |   1 +
 tests/tcg/s390x/signal.c        | 165 ++++++++++++++++++++++++++++++++
 3 files changed, 171 insertions(+)
 create mode 100644 tests/tcg/s390x/signal.c
Quoted 7 lines
Quoted 5 lines

What's the status of this and <[email protected]>? linux-user is not really my turf, but it would be sad if this fell through the cracks.

If from the S390x point of view they are correct, I can collect them via linux-user.

Thanks!

#13 lore raw
In reply to Laurent Vivier
Quoted 4 lines · Laurent Vivier

Le 02/07/2021 à 12:34, Cornelia Huck a écrit :

Quoted 3 lines · Ilya Leoshkevich
Quoted 9 lines
Quoted 5 lines

What's the status of this and <[email protected]>? linux-user is not really my turf, but it would be sad if this fell through the cracks.

If from the S390x point of view they are correct, I can collect them via linux-user.

IIUC, the latest versions of these two series should be ready now:

https://lore.kernel.org/qemu-devel/[email protected]/
https://lore.kernel.org/qemu-devel/[email protected]/

Can they still get into 6.1?

Thanks,

Jon

#14 lore raw
Quoted 18 lines · jonathan.albrecht
Quoted 11 lines · Laurent Vivier

Le 02/07/2021 à 12:34, Cornelia Huck a écrit :

Quoted 9 lines · Ilya Leoshkevich

What's the status of this and <[email protected]>? linux-user
is not really my turf, but it would be sad if this fell through the cracks.

Quoted 3 lines

If from the S390x point of view they are correct, I can collect them via linux-user.

IIUC, the latest versions of these two series should be ready now:

Quoted 8 lines

https://lore.kernel.org/qemu-devel/[email protected]/
https://lore.kernel.org/qemu-devel/[email protected]/

Can they still get into 6.1?

Thanks,

Jon

The test patch from my v6 series hasn't been reviewed yet:

https://lore.kernel.org/qemu-devel/[email protected]/

Could anyone have a look, please?

Best regards,
Ilya