From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Robbin Ehn <rehn@rivosinc.com>, Palmer Dabbelt <palmer@rivosinc.com>
Subject: [PULL v2 3/8] linux-user: Fixed cpu restore with pc 0 on SIGBUS
Date: Tue, 23 Jan 2024 20:24:07 +1000 [thread overview]
Message-ID: <20240123102412.4569-4-richard.henderson@linaro.org> (raw)
In-Reply-To: <20240123102412.4569-1-richard.henderson@linaro.org>
From: Robbin Ehn <rehn@rivosinc.com>
Commit f4e1168198 (linux-user: Split out host_sig{segv,bus}_handler)
introduced a bug, when returning from host_sigbus_handler the PC is
never set. Thus cpu_loop_exit_restore is called with a zero PC and
we immediate get a SIGSEGV.
Signed-off-by: Robbin Ehn <rehn@rivosinc.com>
Fixes: f4e1168198 ("linux-user: Split out host_sig{segv,bus}_handler")
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
Message-Id: <33f27425878fb529b9e39ef22c303f6e0d90525f.camel@rivosinc.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
linux-user/signal.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/linux-user/signal.c b/linux-user/signal.c
index b35d1e512f..c9527adfa3 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -925,7 +925,7 @@ static void host_sigsegv_handler(CPUState *cpu, siginfo_t *info,
cpu_loop_exit_sigsegv(cpu, guest_addr, access_type, maperr, pc);
}
-static void host_sigbus_handler(CPUState *cpu, siginfo_t *info,
+static uintptr_t host_sigbus_handler(CPUState *cpu, siginfo_t *info,
host_sigcontext *uc)
{
uintptr_t pc = host_signal_pc(uc);
@@ -947,6 +947,7 @@ static void host_sigbus_handler(CPUState *cpu, siginfo_t *info,
sigprocmask(SIG_SETMASK, host_signal_mask(uc), NULL);
cpu_loop_exit_sigbus(cpu, guest_addr, access_type, pc);
}
+ return pc;
}
static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
@@ -974,7 +975,7 @@ static void host_signal_handler(int host_sig, siginfo_t *info, void *puc)
host_sigsegv_handler(cpu, info, uc);
return;
case SIGBUS:
- host_sigbus_handler(cpu, info, uc);
+ pc = host_sigbus_handler(cpu, info, uc);
sync_sig = true;
break;
case SIGILL:
--
2.34.1
next prev parent reply other threads:[~2024-01-23 10:24 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 10:24 [PULL v2 0/8] tcg pach queue Richard Henderson
2024-01-23 10:24 ` [PULL v2 1/8] tcg: Remove unreachable code Richard Henderson
2024-01-23 10:24 ` [PULL v2 2/8] tcg: Make the cleanup-on-error path unique Richard Henderson
2024-01-23 10:24 ` Richard Henderson [this message]
2024-01-23 10:24 ` [PULL v2 4/8] tcg/s390x: Fix encoding of VRIc, VRSa, VRSc insns Richard Henderson
2024-01-23 10:24 ` [PULL v2 5/8] linux-user/riscv: Adjust vdso signal frame cfa offsets Richard Henderson
2024-01-23 10:24 ` [PULL v2 6/8] linux-user/elfload: test return value of getrlimit Richard Henderson
2024-01-23 10:24 ` [PULL v2 7/8] linux-user/elfload: check PR_GET_DUMPABLE before creating coredump Richard Henderson
2024-01-23 10:24 ` [PULL v2 8/8] tcg/arm: Fix SIGILL in tcg_out_qemu_st_direct Richard Henderson
2024-01-25 15:11 ` [PULL v2 0/8] tcg pach queue Peter Maydell
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=20240123102412.4569-4-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=palmer@rivosinc.com \
--cc=qemu-devel@nongnu.org \
--cc=rehn@rivosinc.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).