qemu user mode: rt signals not implemented for sparc guests

Bug #1705118 reported by Bruno Haible
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
QEMU
Fix Released
Undecided
Unassigned

Bug Description

The documentation
<https://qemu.weilnetz.de/doc/qemu-doc.html#Features> says that
qemu in user mode supports POSIX signal handling.

Catching SIGSEGV according to POSIX, however, does not work on
  ppc, ppc64, ppc64le, s390x, sparc64.
It does work, however, on
  aarch64, alpha, arm, hppa, m68k, mips, mips64, sh4.

How to reproduce:
The attached program runs fine (exits with code 0) on
  - real hardware Linux/PowerPC64 (in 32-bit and 64-bit mode),
  - real hardware Linux/PowerPC64LE,
  - qemu-system-s390x emulated Linux/s390x,
  - real hardware Linux/SPARC64.
$ gcc -O -Wall testsigsegv.c; ./a.out; echo $?
0

For ppc:
$ powerpc-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -o testsigsegv-ppc
$ ~/inst-qemu/2.9.0/bin/qemu-ppc testsigsegv-ppc
$ echo $?
3

For ppc64:
$ powerpc64-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -o testsigsegv-ppc64
$ ~/inst-qemu/2.9.0/bin/qemu-ppc64 testsigsegv-ppc64
$ echo $?
3

For ppc64le:
$ powerpc64le-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -o testsigsegv-ppc64le
$ ~/inst-qemu/2.9.0/bin/qemu-ppc64le testsigsegv-ppc64le
$ echo $?
3

For s390x:
$ s390x-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -o testsigsegv-s390x
$ ~/inst-qemu/2.9.0/bin/qemu-s390x testsigsegv-s390x
$ echo $?
3
$ s390x-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -DAVOID_LINUX_S390X_COMPAT -o testsigsegv-s390x-a
$ ~/inst-qemu/2.9.0/bin/qemu-s390x testsigsegv-s390x-a
$ echo $?
0
So, the test fails here because the Linux/s390x kernel omits the least
significant 12 bits of the fault address in the 'si_addr' field. But
qemu-s390x is not compatible with the Linux/s390x behaviour: it puts
the complete fault address in the 'si_addr' field.

For sparc64:
$ sparc64-linux-gnu-gcc-5 -O -Wall -static testsigsegv.c -o testsigsegv-sparc64
$ ~/inst-qemu/2.9.0/bin/qemu-sparc64 testsigsegv-sparc64
Segmentation fault (core dumped)

Tags: linux-user
Revision history for this message
Bruno Haible (bruno-clisp) wrote :
Revision history for this message
Bruno Haible (bruno-clisp) wrote :
Revision history for this message
Bruno Haible (bruno-clisp) wrote :
Revision history for this message
Bruno Haible (bruno-clisp) wrote :
Revision history for this message
Bruno Haible (bruno-clisp) wrote :
Revision history for this message
Bruno Haible (bruno-clisp) wrote :
Revision history for this message
Bruno Haible (bruno-clisp) wrote :

The behaviour in qemu-2.10 is the same as in qemu-2.9.

Peter Maydell (pmaydell)
tags: added: linux-user
Revision history for this message
Peter Maydell (pmaydell) wrote :

This is an interesting collection of different bugs:
 * s390x is missing masking operations, as you describe
 * ppc is passing the PC of the offending insn, not the data address, into si_addr
 * sparc fails to record the address of a data fault and so passes 0 into si_addr
 * sparc also isn't implementing rt_sigaction correctly and so the calls in your test program fail EINVAL (your test program doesn't check the return value from sigaction, so it ploughs ahead and makes the faulting data access with the SIG_DFL behaviour for SEGV, hence the uncaught SEGV).

I'm putting together some patches for these.

Changed in qemu:
status: New → Confirmed
Revision history for this message
Peter Maydell (pmaydell) wrote :

...and also
 * SPARC doesn't implement setup_rt_frame(), so it can't deliver RT signals at all.
That's a bigger missing feature than the rest.

Revision history for this message
Peter Maydell (pmaydell) wrote :

Patchset that fixes all the minor parts of this, leaving (probably) just sparc setup_rt_frame/rt_sigreturn:
https://lists.gnu.org/archive/html/qemu-devel/2017-11/msg00833.html

Revision history for this message
Bruno Haible (bruno-clisp) wrote :

I confirm that in qemu-2.11, the ppc and s390x cases are fixed, however the sparc64 case is still failing:

$ ~/inst-qemu/2.11.0/bin/qemu-ppc testsigsegv-ppc
$ echo $?
0

$ ~/inst-qemu/2.11.0/bin/qemu-ppc64 testsigsegv-ppc64
$ echo $?
0

$ ~/inst-qemu/2.11.0/bin/qemu-ppc64le testsigsegv-ppc64le
$ echo $?
0

$ ~/inst-qemu/2.11.0/bin/qemu-s390x testsigsegv-s390x
$ echo $?
0
$ ~/inst-qemu/2.11.0/bin/qemu-s390x testsigsegv-s390x-a
$ echo $?
3

$ ~/inst-qemu/2.11.0/bin/qemu-sparc64 testsigsegv-sparc64
setup_rt_frame: not implemented
Segmentation fault (core dumped)

Revision history for this message
Peter Maydell (pmaydell) wrote :

I don't suppose anybody's going to get round to implementing RT signals for SPARC any time soon, so let's retitle this bug to track the one remaining issue.

summary: - qemu user mode does not support catching SIGSEGV on some architectures
+ qemu user mode: rt signals not implemented for sparc guests
Revision history for this message
Thomas Huth (th-huth) wrote :

The QEMU project is currently moving its bug tracking to another system.
For this we need to know which bugs are still valid and which could be
closed already. Thus we are setting the bug state to "Incomplete" now.

If the bug has already been fixed in the latest upstream version of QEMU,
then please close this ticket as "Fix released".

If it is not fixed yet and you think that this bug report here is still
valid, then you have two options:

1) If you already have an account on gitlab.com, please open a new ticket
for this problem in our new tracker here:

    https://gitlab.com/qemu-project/qemu/-/issues

and then close this ticket here on Launchpad (or let it expire auto-
matically after 60 days). Please mention the URL of this bug ticket on
Launchpad in the new ticket on GitLab.

2) If you don't have an account on gitlab.com and don't intend to get
one, but still would like to keep this ticket opened, then please switch
the state back to "New" or "Confirmed" within the next 60 days (other-
wise it will get closed as "Expired"). We will then eventually migrate
the ticket automatically to the new system (but you won't be the reporter
of the bug in the new system and thus you won't get notified on changes
anymore).

Thank you and sorry for the inconvenience.

Changed in qemu:
status: Confirmed → Incomplete
Revision history for this message
Bruno Haible (bruno-clisp) wrote :

The situation in version 6.0.0 is the same as in version 2.11.0: The cases ppc, ppc64, ppc64le, s390x are fixed, but the sparc64 executable still crashes.

Changed in qemu:
status: Incomplete → New
Revision history for this message
Thomas Huth (th-huth) wrote : Moved bug report

This is an automated cleanup. This bug report has been moved to QEMU's
new bug tracker on gitlab.com and thus gets marked as 'expired' now.
Please continue with the discussion here:

 https://gitlab.com/qemu-project/qemu/-/issues/311

Changed in qemu:
status: New → Expired
Richard Henderson (rth)
Changed in qemu:
status: Expired → Fix Committed
Thomas Huth (th-huth)
Changed in qemu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.