From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "Giuseppe Musacchio" <thatlemon@gmail.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Riku Voipio" <riku.voipio@iki.fi>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Laurent Vivier" <laurent@vivier.eu>,
"Artyom Tarasenko" <atar4qemu@gmail.com>
Subject: [PATCH v2 2/2] linux-user/sparc64: Fix the handling of window spill trap
Date: Thu, 25 Jun 2020 11:12:04 +0200 [thread overview]
Message-ID: <20200625091204.3186186-3-laurent@vivier.eu> (raw)
In-Reply-To: <20200625091204.3186186-1-laurent@vivier.eu>
From: LemonBoy <thatlemon@gmail.com>
Fix the handling of window spill traps by keeping cansave into account
when calculating the new CWP.
Signed-off-by: Giuseppe Musacchio <thatlemon@gmail.com>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
bsd-user/main.c | 6 +++++-
linux-user/sparc/cpu_loop.c | 6 +++++-
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/bsd-user/main.c b/bsd-user/main.c
index 0bfe46cff93e..ac40d79bfaac 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -413,7 +413,11 @@ static void save_window(CPUSPARCState *env)
save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
env->wim = new_wim;
#else
- save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
+ /*
+ * cansave is zero if the spill trap handler is triggered by `save` and
+ * nonzero if triggered by a `flushw`
+ */
+ save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2));
env->cansave++;
env->canrestore--;
#endif
diff --git a/linux-user/sparc/cpu_loop.c b/linux-user/sparc/cpu_loop.c
index 7645cc04ca73..02532f198df8 100644
--- a/linux-user/sparc/cpu_loop.c
+++ b/linux-user/sparc/cpu_loop.c
@@ -69,7 +69,11 @@ static void save_window(CPUSPARCState *env)
save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
env->wim = new_wim;
#else
- save_window_offset(env, cpu_cwp_dec(env, env->cwp - 2));
+ /*
+ * cansave is zero if the spill trap handler is triggered by `save` and
+ * nonzero if triggered by a `flushw`
+ */
+ save_window_offset(env, cpu_cwp_dec(env, env->cwp - env->cansave - 2));
env->cansave++;
env->canrestore--;
#endif
--
2.26.2
next prev parent reply other threads:[~2020-06-25 9:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-25 9:12 [PATCH v2 0/2] linux-user/sparc64: Translate flushw opcode Laurent Vivier
2020-06-25 9:12 ` [PATCH v2 1/2] target/sparc: " Laurent Vivier
2020-06-25 9:12 ` Laurent Vivier [this message]
2020-06-26 21:23 ` [PATCH v2 0/2] linux-user/sparc64: " Richard Henderson
2020-06-29 11:01 ` Laurent Vivier
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=20200625091204.3186186-3-laurent@vivier.eu \
--to=laurent@vivier.eu \
--cc=atar4qemu@gmail.com \
--cc=f4bug@amsat.org \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=riku.voipio@iki.fi \
--cc=thatlemon@gmail.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).