qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: LemonBoy <thatlemon@gmail.com>
To: qemu-devel@nongnu.org, laurent@vivier.eu, richard.henderson@linaro.org
Subject: [PATCH] linux-user/sparc64: Translate flushw opcode
Date: Fri, 10 Apr 2020 23:14:20 +0200	[thread overview]
Message-ID: <894ec93e-05dd-2110-a0c2-e0afa2fa6fd5@gmail.com> (raw)

From 11d0cfe58d12e0f191b435ade88622cfceb2098a Mon Sep 17 00:00:00 2001
From: LemonBoy <thatlemon@gmail.com>
Date: Fri, 10 Apr 2020 22:55:26 +0200
Subject: [PATCH] linux-user/sparc64: Translate flushw opcode

The ifdef logic should unconditionally compile in the `xop == 0x2b` case
when targeting sparc64.

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>
---
 bsd-user/main.c             | 4 +++-
 linux-user/sparc/cpu_loop.c | 4 +++-
 target/sparc/translate.c    | 2 ++
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/bsd-user/main.c b/bsd-user/main.c
index 770c2b267a..d6b1c997e3 100644
--- a/bsd-user/main.c
+++ b/bsd-user/main.c
@@ -413,7 +413,9 @@ 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 7645cc04ca..20a7401126 100644
--- a/linux-user/sparc/cpu_loop.c
+++ b/linux-user/sparc/cpu_loop.c
@@ -69,7 +69,9 @@ 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/target/sparc/translate.c b/target/sparc/translate.c
index 9416a551cf..1a4efd4ed6 100644
--- a/target/sparc/translate.c
+++ b/target/sparc/translate.c
@@ -3663,6 +3663,8 @@ static void disas_sparc_insn(DisasContext * dc, unsigned int insn)
 #endif
                 gen_store_gpr(dc, rd, cpu_tmp0);
                 break;
+#endif
+#if defined(TARGET_SPARC64) || !defined(CONFIG_USER_ONLY)
             } else if (xop == 0x2b) { /* rdtbr / V9 flushw */
 #ifdef TARGET_SPARC64
                 gen_helper_flushw(cpu_env);
-- 
2.20.1



             reply	other threads:[~2020-04-10 21:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-10 21:14 LemonBoy [this message]
2020-04-17 11:06 ` [PATCH] linux-user/sparc64: Translate flushw opcode LemonBoy
2020-05-07 14:17   ` Laurent Vivier
2020-05-07 15:29     ` Artyom Tarasenko
2020-05-07 18:33 ` Richard Henderson
2020-05-28 17:13 ` Laurent Vivier
2020-06-08 17:29 ` Philippe Mathieu-Daudé

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=894ec93e-05dd-2110-a0c2-e0afa2fa6fd5@gmail.com \
    --to=thatlemon@gmail.com \
    --cc=laurent@vivier.eu \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /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).