All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: qemu-devel@nongnu.org
Cc: patches@linaro.org, Riku Voipio <riku.voipio@iki.fi>,
	Laurent Vivier <laurent@vivier.eu>
Subject: [Qemu-devel] [PATCH 1/4] linux-user/s390x: Mask si_addr for SIGSEGV
Date: Mon,  6 Nov 2017 18:33:23 +0000	[thread overview]
Message-ID: <1509993206-26637-2-git-send-email-peter.maydell@linaro.org> (raw)
In-Reply-To: <1509993206-26637-1-git-send-email-peter.maydell@linaro.org>

For s390x, the address passed to a signal handler in the
siginfo_t si_addr field is masked (in the kernel this is done in
do_sigbus() and do_sigsegv() in arch/s390/mm/fault.c). Implement
this architecture-specific oddity in linux-user.

This is one of the issues described in
https://bugs.launchpad.net/qemu/+bug/1705118

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 linux-user/main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/linux-user/main.c b/linux-user/main.c
index aa02f25..b6dd9ef 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3238,6 +3238,10 @@ void cpu_loop(CPUAlphaState *env)
 #endif /* TARGET_ALPHA */
 
 #ifdef TARGET_S390X
+
+/* s390x masks the fault address it reports in si_addr for SIGSEGV and SIGBUS */
+#define S390X_FAIL_ADDR_MASK -4096LL
+
 void cpu_loop(CPUS390XState *env)
 {
     CPUState *cs = CPU(s390_env_get_cpu(env));
@@ -3294,7 +3298,7 @@ void cpu_loop(CPUS390XState *env)
                 sig = TARGET_SIGSEGV;
                 /* XXX: check env->error_code */
                 n = TARGET_SEGV_MAPERR;
-                addr = env->__excp_addr;
+                addr = env->__excp_addr & S390X_FAIL_ADDR_MASK;
                 goto do_signal;
             case PGM_EXECUTE:
             case PGM_SPECIFICATION:
-- 
2.7.4

  reply	other threads:[~2017-11-06 18:33 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-06 18:33 [Qemu-devel] [PATCH 0/4] linux-user: fix various SIGSEGV delivery bugs Peter Maydell
2017-11-06 18:33 ` Peter Maydell [this message]
2017-11-07  8:06   ` [Qemu-devel] [PATCH 1/4] linux-user/s390x: Mask si_addr for SIGSEGV Laurent Vivier
2017-11-07 15:34   ` Philippe Mathieu-Daudé
2017-11-08 21:18   ` Richard Henderson
2017-11-09 11:12     ` Peter Maydell
2017-11-06 18:33 ` [Qemu-devel] [PATCH 2/4] linux-user/ppc: Report correct fault address for data faults Peter Maydell
2017-11-07  8:17   ` Laurent Vivier
2017-11-08 21:19   ` Richard Henderson
2017-11-06 18:33 ` [Qemu-devel] [PATCH 3/4] linux-user/sparc: Put address for data faults where linux-user expects it Peter Maydell
2017-11-07  8:28   ` Laurent Vivier
2017-11-07  9:20     ` Peter Maydell
2017-11-07  9:25   ` Laurent Vivier
2017-11-07 15:26   ` Philippe Mathieu-Daudé
2017-11-08 21:21   ` Richard Henderson
2017-11-06 18:33 ` [Qemu-devel] [PATCH 4/4] linux-user: Handle rt_sigaction correctly for SPARC Peter Maydell
2017-11-07 14:11   ` Laurent Vivier
2017-11-07 15:44   ` Philippe Mathieu-Daudé
2017-11-07 20:02 ` [Qemu-devel] [PATCH 0/4] linux-user: fix various SIGSEGV delivery bugs Riku Voipio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1509993206-26637-2-git-send-email-peter.maydell@linaro.org \
    --to=peter.maydell@linaro.org \
    --cc=laurent@vivier.eu \
    --cc=patches@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=riku.voipio@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.