qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org, Richard Henderson <richard.henderson@linaro.org>
Cc: "Laurent Vivier" <laurent@vivier.eu>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Fabiano Rosas" <farosas@suse.de>,
	qemu-arm@nongnu.org, "Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PATCH v2 1/7] target/arm/sme: Reorg SME access handling in handle_msr_i()
Date: Thu, 12 Jan 2023 11:24:30 +0100	[thread overview]
Message-ID: <20230112102436.1913-2-philmd@linaro.org> (raw)
In-Reply-To: <20230112102436.1913-1-philmd@linaro.org>

From: Richard Henderson <richard.henderson@linaro.org>

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20230112004322.161330-1-richard.henderson@linaro.org>
[PMD: Split patch in multiple tiny steps]
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/arm/translate-a64.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
index 2ee171f249..35cc851246 100644
--- a/target/arm/translate-a64.c
+++ b/target/arm/translate-a64.c
@@ -1841,18 +1841,20 @@ static void handle_msr_i(DisasContext *s, uint32_t insn,
             goto do_unallocated;
         }
         if (sme_access_check(s)) {
-            bool i = crm & 1;
-            bool changed = false;
+            int old = s->pstate_sm | (s->pstate_za << 1);
+            int new = (crm & 1) * 3;
+            int msk = (crm >> 1) & 3;
 
-            if ((crm & 2) && i != s->pstate_sm) {
-                gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i));
-                changed = true;
-            }
-            if ((crm & 4) && i != s->pstate_za) {
-                gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i));
-                changed = true;
-            }
-            if (changed) {
+            if ((old ^ new) & msk) {
+                /* At least one bit changes. */
+                bool i = crm & 1;
+
+                if ((crm & 2) && i != s->pstate_sm) {
+                    gen_helper_set_pstate_sm(cpu_env, tcg_constant_i32(i));
+                }
+                if ((crm & 4) && i != s->pstate_za) {
+                    gen_helper_set_pstate_za(cpu_env, tcg_constant_i32(i));
+                }
                 gen_rebuild_hflags(s);
             } else {
                 s->base.is_jmp = DISAS_NEXT;
-- 
2.38.1



  reply	other threads:[~2023-01-12 10:39 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-12 10:24 [PATCH v2 0/7] target/arm: Introduce aarch64_set_svcr Philippe Mathieu-Daudé
2023-01-12 10:24 ` Philippe Mathieu-Daudé [this message]
2023-01-12 10:24 ` [PATCH v2 2/7] target/arm/sme: Rebuild hflags in set_pstate() helpers Philippe Mathieu-Daudé
2023-01-12 10:24 ` [PATCH v2 3/7] target/arm/sme: Introduce aarch64_set_svcr() Philippe Mathieu-Daudé
2023-01-12 10:24 ` [PATCH v2 4/7] target/arm/sme: Reset SVE state in aarch64_set_svcr() Philippe Mathieu-Daudé
2023-01-12 10:24 ` [PATCH v2 5/7] target/arm/sme: Reset ZA " Philippe Mathieu-Daudé
2023-01-12 10:24 ` [PATCH v2 6/7] target/arm/sme: Rebuild hflags " Philippe Mathieu-Daudé
2023-01-12 10:24 ` [PATCH v2 7/7] target/arm/sme: Unify set_pstate() SM/ZA helpers as set_svcr() Philippe Mathieu-Daudé
2023-01-12 14:20 ` [PATCH v2 0/7] target/arm: Introduce aarch64_set_svcr Fabiano Rosas
2023-01-17 16:33 ` 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=20230112102436.1913-2-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=farosas@suse.de \
    --cc=laurent@vivier.eu \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --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).