From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: mjt@tls.msk.ru, "Fabiano Rosas" <farosas@suse.de>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>
Subject: [PATCH 6/9] target/arm/sme: Rebuild hflags in aarch64_set_svcr()
Date: Mon, 28 Jul 2025 08:16:47 -1000 [thread overview]
Message-ID: <20250728181650.165114-7-richard.henderson@linaro.org> (raw)
In-Reply-To: <20250728181650.165114-1-richard.henderson@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Fabiano Rosas <farosas@suse.de>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-id: 20230112102436.1913-7-philmd@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>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
(cherry picked from commit f4318557149184d6dac99e561acabcb602a84ee1)
---
linux-user/aarch64/cpu_loop.c | 8 +-------
linux-user/aarch64/signal.c | 3 ---
target/arm/helper.c | 6 +++++-
target/arm/sme_helper.c | 8 --------
4 files changed, 6 insertions(+), 19 deletions(-)
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
index 5e93d27d8f..2e2f7cf218 100644
--- a/linux-user/aarch64/cpu_loop.c
+++ b/linux-user/aarch64/cpu_loop.c
@@ -89,14 +89,8 @@ void cpu_loop(CPUARMState *env)
switch (trapnr) {
case EXCP_SWI:
- /*
- * On syscall, PSTATE.ZA is preserved, along with the ZA matrix.
- * PSTATE.SM is cleared, per SMSTOP, which does ResetSVEState.
- */
+ /* On syscall, PSTATE.ZA is preserved, PSTATE.SM is cleared. */
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
- if (FIELD_EX64(env->svcr, SVCR, SM)) {
- arm_rebuild_hflags(env);
- }
ret = do_syscall(env,
env->xregs[8],
env->xregs[0],
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
index a326a6def5..b265cfd470 100644
--- a/linux-user/aarch64/signal.c
+++ b/linux-user/aarch64/signal.c
@@ -667,9 +667,6 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
/* Invoke the signal handler with both SM and ZA disabled. */
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
- if (env->svcr) {
- arm_rebuild_hflags(env);
- }
if (info) {
tswap_siginfo(&frame->info, info);
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 37e018e765..bc1c5a1f17 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -6442,6 +6442,9 @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
{
uint64_t change = (env->svcr ^ new) & mask;
+ if (change == 0) {
+ return;
+ }
env->svcr ^= change;
if (change & R_SVCR_SM_MASK) {
@@ -6459,6 +6462,8 @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
if (change & new & R_SVCR_ZA_MASK) {
memset(env->zarray, 0, sizeof(env->zarray));
}
+
+ arm_rebuild_hflags(env);
}
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
@@ -6467,7 +6472,6 @@ static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
helper_set_pstate_sm(env, FIELD_EX64(value, SVCR, SM));
helper_set_pstate_za(env, FIELD_EX64(value, SVCR, ZA));
aarch64_set_svcr(env, value, -1);
- arm_rebuild_hflags(env);
}
static void smcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
index 247c2823ac..bbda651974 100644
--- a/target/arm/sme_helper.c
+++ b/target/arm/sme_helper.c
@@ -31,20 +31,12 @@
void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
{
- if (i == FIELD_EX64(env->svcr, SVCR, SM)) {
- return;
- }
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
- arm_rebuild_hflags(env);
}
void helper_set_pstate_za(CPUARMState *env, uint32_t i)
{
- if (i == FIELD_EX64(env->svcr, SVCR, ZA)) {
- return;
- }
aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK);
- arm_rebuild_hflags(env);
}
void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl)
--
2.43.0
next prev parent reply other threads:[~2025-07-28 18:22 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-28 18:16 [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes Richard Henderson
2025-07-28 18:16 ` [PATCH 1/9] target/arm/sme: Reorg SME access handling in handle_msr_i() Richard Henderson
2025-07-28 18:16 ` [PATCH 2/9] target/arm/sme: Rebuild hflags in set_pstate() helpers Richard Henderson
2025-07-28 18:16 ` [PATCH 3/9] target/arm/sme: Introduce aarch64_set_svcr() Richard Henderson
2025-07-28 18:16 ` [PATCH 4/9] target/arm/sme: Reset SVE state in aarch64_set_svcr() Richard Henderson
2025-07-28 19:43 ` Michael Tokarev
2025-07-28 21:08 ` Richard Henderson
2025-07-28 18:16 ` [PATCH 5/9] target/arm/sme: Reset ZA " Richard Henderson
2025-07-28 18:16 ` Richard Henderson [this message]
2025-07-28 18:16 ` [PATCH 7/9] target/arm/sme: Unify set_pstate() SM/ZA helpers as set_svcr() Richard Henderson
2025-07-28 18:16 ` [PATCH 8/9] linux-user/aarch64: Clear TPIDR2_EL0 when delivering signals Richard Henderson
2025-07-28 18:16 ` [PATCH 9/9] linux-user/aarch64: Support TPIDR2_MAGIC signal frame record Richard Henderson
2025-07-28 20:50 ` [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes Michael Tokarev
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=20250728181650.165114-7-richard.henderson@linaro.org \
--to=richard.henderson@linaro.org \
--cc=farosas@suse.de \
--cc=mjt@tls.msk.ru \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.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).