From: Helge Deller <deller@kernel.org>
To: qemu-devel@nongnu.org
Cc: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>,
Max Filippov <jcmvbkbc@gmail.com>, Helge Deller <deller@gmx.de>,
Yoshinori Sato <yoshinori.sato@nifty.com>,
Laurent Vivier <laurent@vivier.eu>,
Matt Turner <mattst88@gmail.com>,
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Subject: [PULL 5/8] linux-user/sparc: restore L/I registers from RSA in sparc64_set_context
Date: Mon, 8 Jun 2026 21:42:53 +0200 [thread overview]
Message-ID: <20260608194256.13794-6-deller@kernel.org> (raw)
In-Reply-To: <20260608194256.13794-1-deller@kernel.org>
From: Matt Turner <mattst88@gmail.com>
The kernel's do_rt_sigreturn loads L and I registers from the register
save area (RSA) at the restored O6+STACK_BIAS. QEMU lacks the kernel's
window-fill path, so restore L0-L7 and I0-I5 explicitly from the RSA.
I6 and I7 are already restored from mc_fp/mc_i7.
Signed-off-by: Matt Turner <mattst88@gmail.com>
Cc: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: Helge Deller <deller@gmx.de>
---
linux-user/sparc/signal.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c
index d339f89928..fda5508c48 100644
--- a/linux-user/sparc/signal.c
+++ b/linux-user/sparc/signal.c
@@ -656,6 +656,24 @@ void sparc64_set_context(CPUSPARCState *env)
__get_user(env->regwptr[WREG_FP], &(ucp->tuc_mcontext.mc_fp));
__get_user(env->regwptr[WREG_I7], &(ucp->tuc_mcontext.mc_i7));
+ /*
+ * The kernel's do_rt_sigreturn loads L and I registers from the
+ * register save area (RSA) at the new O6+STACK_BIAS. Unlike the
+ * kernel, QEMU has no kernel-mode path that triggers a window fill,
+ * so we must do it explicitly here. I6 and I7 are already restored
+ * from mc_fp and mc_i7 above; restore L0-L7 and I0-I5 from the RSA.
+ */
+ {
+ abi_ulong sp_ptr = env->regwptr[WREG_O6];
+ /* LP64 O6 is biased (8-byte-aligned - 2047); low bit set. ILP32 O6 is 4-byte-aligned. */
+ if (sp_ptr & 3)
+ sp_ptr += TARGET_STACK_BIAS;
+ for (i = 0; i < 8; i++)
+ get_user_ual(env->regwptr[WREG_L0 + i], sp_ptr + i * 8);
+ for (i = 0; i < 6; i++) /* I0-I5; I6=FP and I7 already restored */
+ get_user_ual(env->regwptr[WREG_I0 + i], sp_ptr + 64 + i * 8);
+ }
+
fpup = &ucp->tuc_mcontext.mc_fpregs;
__get_user(fenab, &(fpup->mcfpu_enab));
--
2.54.0
next prev parent reply other threads:[~2026-06-08 19:43 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 19:42 [PULL 0/8] Linux user patches Helge Deller
2026-06-08 19:42 ` [PULL 1/8] linux-user: implement fsmount(2) series of syscalls Helge Deller
2026-06-08 19:42 ` [PULL 2/8] linux-user/strace: add fsmount " Helge Deller
2026-06-08 19:42 ` [PULL 3/8] linux-user/alpha: add coredump support Helge Deller
2026-06-08 19:42 ` [PULL 4/8] linux-user/sparc: " Helge Deller
2026-06-08 19:42 ` Helge Deller [this message]
2026-06-08 19:42 ` [PULL 6/8] linux-user/sparc: call block_signals() before set_sigmask() in setcontext Helge Deller
2026-06-08 19:42 ` [PULL 7/8] linux-user/sparc: flush register windows before core dump Helge Deller
2026-06-08 19:42 ` [PULL 8/8] target/sh4: decode_gusa: recognize add#imm with prior mov Rm, Rn Helge Deller
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=20260608194256.13794-6-deller@kernel.org \
--to=deller@kernel.org \
--cc=deller@gmx.de \
--cc=jcmvbkbc@gmail.com \
--cc=laurent@vivier.eu \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mattst88@gmail.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.org \
--cc=yoshinori.sato@nifty.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 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.