* [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes
@ 2025-07-28 18:16 Richard Henderson
2025-07-28 18:16 ` [PATCH 1/9] target/arm/sme: Reorg SME access handling in handle_msr_i() Richard Henderson
` (9 more replies)
0 siblings, 10 replies; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 18:16 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt
Hi Michael,
Here's the aarch64-linux-user TPIDR2_EL0 fixes backported to the
stable-7.2 branch. Including all of the aarch64_set_svcr cleanups
is probably overkill, but I think it was clearer that way.
r~
Peter Maydell (2):
linux-user/aarch64: Clear TPIDR2_EL0 when delivering signals
linux-user/aarch64: Support TPIDR2_MAGIC signal frame record
Richard Henderson (7):
target/arm/sme: Reorg SME access handling in handle_msr_i()
target/arm/sme: Rebuild hflags in set_pstate() helpers
target/arm/sme: Introduce aarch64_set_svcr()
target/arm/sme: Reset SVE state in aarch64_set_svcr()
target/arm/sme: Reset ZA state in aarch64_set_svcr()
target/arm/sme: Rebuild hflags in aarch64_set_svcr()
target/arm/sme: Unify set_pstate() SM/ZA helpers as set_svcr()
target/arm/cpu.h | 2 +-
target/arm/helper-sme.h | 3 +-
linux-user/aarch64/cpu_loop.c | 11 ++-----
linux-user/aarch64/signal.c | 55 ++++++++++++++++++++++++++++-------
target/arm/helper.c | 41 ++++++++++++++++++++++++--
target/arm/sme_helper.c | 37 ++---------------------
target/arm/translate-a64.c | 19 +++++-------
7 files changed, 95 insertions(+), 73 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH 1/9] target/arm/sme: Reorg SME access handling in handle_msr_i()
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 ` Richard Henderson
2025-07-28 18:16 ` [PATCH 2/9] target/arm/sme: Rebuild hflags in set_pstate() helpers Richard Henderson
` (8 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 18:16 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt, Fabiano Rosas, Philippe Mathieu-Daudé, Peter Maydell
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-2-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 535ca76425fc1ffa4311b3a47518b06c596a55c6)
---
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 7210a9cc4d..b66561a5cf 100644
--- a/target/arm/translate-a64.c
+++ b/target/arm/translate-a64.c
@@ -1855,18 +1855,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.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 2/9] target/arm/sme: Rebuild hflags in set_pstate() helpers
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 ` Richard Henderson
2025-07-28 18:16 ` [PATCH 3/9] target/arm/sme: Introduce aarch64_set_svcr() Richard Henderson
` (7 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 18:16 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt, Fabiano Rosas, Philippe Mathieu-Daudé, Peter Maydell
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-3-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 3c9ee548948870c14235e3fa8fb235c0c1c20822)
---
target/arm/sme_helper.c | 2 ++
target/arm/translate-a64.c | 1 -
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
index e8b4ca38ff..8ba3f3a247 100644
--- a/target/arm/sme_helper.c
+++ b/target/arm/sme_helper.c
@@ -45,6 +45,7 @@ void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
}
env->svcr ^= R_SVCR_SM_MASK;
arm_reset_sve_state(env);
+ arm_rebuild_hflags(env);
}
void helper_set_pstate_za(CPUARMState *env, uint32_t i)
@@ -65,6 +66,7 @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i)
if (i) {
memset(env->zarray, 0, sizeof(env->zarray));
}
+ arm_rebuild_hflags(env);
}
void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl)
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
index b66561a5cf..fa568aa647 100644
--- a/target/arm/translate-a64.c
+++ b/target/arm/translate-a64.c
@@ -1869,7 +1869,6 @@ static void handle_msr_i(DisasContext *s, uint32_t insn,
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.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 3/9] target/arm/sme: Introduce aarch64_set_svcr()
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 ` Richard Henderson
2025-07-28 18:16 ` [PATCH 4/9] target/arm/sme: Reset SVE state in aarch64_set_svcr() Richard Henderson
` (6 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 18:16 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt, Fabiano Rosas, Philippe Mathieu-Daudé, Peter Maydell
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-4-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 2a8af3825958e5d8c98b3ca92ac42a10e25db9e1)
---
target/arm/cpu.h | 1 +
linux-user/aarch64/cpu_loop.c | 2 +-
linux-user/aarch64/signal.c | 2 +-
target/arm/helper.c | 8 ++++++++
target/arm/sme_helper.c | 4 ++--
5 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 32b0bf8e2d..8acfd3af4c 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -1118,6 +1118,7 @@ int aarch64_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);
void aarch64_sve_change_el(CPUARMState *env, int old_el,
int new_el, bool el0_a64);
+void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask);
void arm_reset_sve_state(CPUARMState *env);
/*
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
index 9875d609a9..d53742e10b 100644
--- a/linux-user/aarch64/cpu_loop.c
+++ b/linux-user/aarch64/cpu_loop.c
@@ -93,8 +93,8 @@ void cpu_loop(CPUARMState *env)
* On syscall, PSTATE.ZA is preserved, along with the ZA matrix.
* PSTATE.SM is cleared, per SMSTOP, which does ResetSVEState.
*/
+ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
if (FIELD_EX64(env->svcr, SVCR, SM)) {
- env->svcr = FIELD_DP64(env->svcr, SVCR, SM, 0);
arm_rebuild_hflags(env);
arm_reset_sve_state(env);
}
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
index 6a2c6e06d2..b6e4dcb494 100644
--- a/linux-user/aarch64/signal.c
+++ b/linux-user/aarch64/signal.c
@@ -669,11 +669,11 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
* Invoke the signal handler with both SM and ZA disabled.
* When clearing SM, ResetSVEState, per SMSTOP.
*/
+ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
if (FIELD_EX64(env->svcr, SVCR, SM)) {
arm_reset_sve_state(env);
}
if (env->svcr) {
- env->svcr = 0;
arm_rebuild_hflags(env);
}
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 6cffbcb276..86b97daf7e 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -6429,11 +6429,19 @@ static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri,
return CP_ACCESS_OK;
}
+void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
+{
+ uint64_t change = (env->svcr ^ new) & mask;
+
+ env->svcr ^= change;
+}
+
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
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);
}
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
index 8ba3f3a247..7717dab64f 100644
--- a/target/arm/sme_helper.c
+++ b/target/arm/sme_helper.c
@@ -43,7 +43,7 @@ void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
if (i == FIELD_EX64(env->svcr, SVCR, SM)) {
return;
}
- env->svcr ^= R_SVCR_SM_MASK;
+ aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
arm_reset_sve_state(env);
arm_rebuild_hflags(env);
}
@@ -53,7 +53,7 @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i)
if (i == FIELD_EX64(env->svcr, SVCR, ZA)) {
return;
}
- env->svcr ^= R_SVCR_ZA_MASK;
+ aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK);
/*
* ResetSMEState.
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 4/9] target/arm/sme: Reset SVE state in aarch64_set_svcr()
2025-07-28 18:16 [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes Richard Henderson
` (2 preceding siblings ...)
2025-07-28 18:16 ` [PATCH 3/9] target/arm/sme: Introduce aarch64_set_svcr() Richard Henderson
@ 2025-07-28 18:16 ` Richard Henderson
2025-07-28 19:43 ` Michael Tokarev
2025-07-28 18:16 ` [PATCH 5/9] target/arm/sme: Reset ZA " Richard Henderson
` (5 subsequent siblings)
9 siblings, 1 reply; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 18:16 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt, Fabiano Rosas, Philippe Mathieu-Daudé, Peter Maydell
Move arm_reset_sve_state() calls to aarch64_set_svcr().
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-5-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 7f2a01e7368f960fadea38f437d0f6de7f249686)
---
target/arm/cpu.h | 1 -
linux-user/aarch64/cpu_loop.c | 1 -
linux-user/aarch64/signal.c | 8 +-------
target/arm/helper.c | 13 +++++++++++++
target/arm/sme_helper.c | 10 ----------
5 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index 8acfd3af4c..02a084c962 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -1119,7 +1119,6 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);
void aarch64_sve_change_el(CPUARMState *env, int old_el,
int new_el, bool el0_a64);
void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask);
-void arm_reset_sve_state(CPUARMState *env);
/*
* SVE registers are encoded in KVM's memory in an endianness-invariant format.
diff --git a/linux-user/aarch64/cpu_loop.c b/linux-user/aarch64/cpu_loop.c
index d53742e10b..5e93d27d8f 100644
--- a/linux-user/aarch64/cpu_loop.c
+++ b/linux-user/aarch64/cpu_loop.c
@@ -96,7 +96,6 @@ void cpu_loop(CPUARMState *env)
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
if (FIELD_EX64(env->svcr, SVCR, SM)) {
arm_rebuild_hflags(env);
- arm_reset_sve_state(env);
}
ret = do_syscall(env,
env->xregs[8],
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
index b6e4dcb494..a326a6def5 100644
--- a/linux-user/aarch64/signal.c
+++ b/linux-user/aarch64/signal.c
@@ -665,14 +665,8 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
env->btype = 2;
}
- /*
- * Invoke the signal handler with both SM and ZA disabled.
- * When clearing SM, ResetSVEState, per SMSTOP.
- */
+ /* Invoke the signal handler with both SM and ZA disabled. */
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
- if (FIELD_EX64(env->svcr, SVCR, SM)) {
- arm_reset_sve_state(env);
- }
if (env->svcr) {
arm_rebuild_hflags(env);
}
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 86b97daf7e..94a6f431a9 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -6429,11 +6429,24 @@ static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri,
return CP_ACCESS_OK;
}
+/* ResetSVEState */
+static void arm_reset_sve_state(CPUARMState *env)
+{
+ memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs));
+ /* Recall that FFR is stored as pregs[16]. */
+ memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs));
+ vfp_set_fpcr(env, 0x0800009f);
+}
+
void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
{
uint64_t change = (env->svcr ^ new) & mask;
env->svcr ^= change;
+
+ if (change & R_SVCR_SM_MASK) {
+ arm_reset_sve_state(env);
+ }
}
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
index 7717dab64f..56a8fbe691 100644
--- a/target/arm/sme_helper.c
+++ b/target/arm/sme_helper.c
@@ -29,22 +29,12 @@
#include "vec_internal.h"
#include "sve_ldst_internal.h"
-/* ResetSVEState */
-void arm_reset_sve_state(CPUARMState *env)
-{
- memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs));
- /* Recall that FFR is stored as pregs[16]. */
- memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs));
- vfp_set_fpsr(env, 0x0800009f);
-}
-
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_reset_sve_state(env);
arm_rebuild_hflags(env);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 5/9] target/arm/sme: Reset ZA state in aarch64_set_svcr()
2025-07-28 18:16 [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes Richard Henderson
` (3 preceding siblings ...)
2025-07-28 18:16 ` [PATCH 4/9] target/arm/sme: Reset SVE state in aarch64_set_svcr() Richard Henderson
@ 2025-07-28 18:16 ` Richard Henderson
2025-07-28 18:16 ` [PATCH 6/9] target/arm/sme: Rebuild hflags " Richard Henderson
` (4 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 18:16 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt, Fabiano Rosas, Philippe Mathieu-Daudé, Peter Maydell
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-6-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 fccb49182e23bd359092f7ab09bc7e60a0fff71a)
---
target/arm/helper.c | 12 ++++++++++++
target/arm/sme_helper.c | 12 ------------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 94a6f431a9..37e018e765 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -6447,6 +6447,18 @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
if (change & R_SVCR_SM_MASK) {
arm_reset_sve_state(env);
}
+
+ /*
+ * ResetSMEState.
+ *
+ * SetPSTATE_ZA zeros on enable and disable. We can zero this only
+ * on enable: while disabled, the storage is inaccessible and the
+ * value does not matter. We're not saving the storage in vmstate
+ * when disabled either.
+ */
+ if (change & new & R_SVCR_ZA_MASK) {
+ memset(env->zarray, 0, sizeof(env->zarray));
+ }
}
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
index 56a8fbe691..247c2823ac 100644
--- a/target/arm/sme_helper.c
+++ b/target/arm/sme_helper.c
@@ -44,18 +44,6 @@ void helper_set_pstate_za(CPUARMState *env, uint32_t i)
return;
}
aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK);
-
- /*
- * ResetSMEState.
- *
- * SetPSTATE_ZA zeros on enable and disable. We can zero this only
- * on enable: while disabled, the storage is inaccessible and the
- * value does not matter. We're not saving the storage in vmstate
- * when disabled either.
- */
- if (i) {
- memset(env->zarray, 0, sizeof(env->zarray));
- }
arm_rebuild_hflags(env);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 6/9] target/arm/sme: Rebuild hflags in aarch64_set_svcr()
2025-07-28 18:16 [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes Richard Henderson
` (4 preceding siblings ...)
2025-07-28 18:16 ` [PATCH 5/9] target/arm/sme: Reset ZA " Richard Henderson
@ 2025-07-28 18:16 ` Richard Henderson
2025-07-28 18:16 ` [PATCH 7/9] target/arm/sme: Unify set_pstate() SM/ZA helpers as set_svcr() Richard Henderson
` (3 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 18:16 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt, Fabiano Rosas, Philippe Mathieu-Daudé, Peter Maydell
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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 7/9] target/arm/sme: Unify set_pstate() SM/ZA helpers as set_svcr()
2025-07-28 18:16 [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes Richard Henderson
` (5 preceding siblings ...)
2025-07-28 18:16 ` [PATCH 6/9] target/arm/sme: Rebuild hflags " Richard Henderson
@ 2025-07-28 18:16 ` Richard Henderson
2025-07-28 18:16 ` [PATCH 8/9] linux-user/aarch64: Clear TPIDR2_EL0 when delivering signals Richard Henderson
` (2 subsequent siblings)
9 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 18:16 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt, Fabiano Rosas, Philippe Mathieu-Daudé, Peter Maydell
Unify the two helper_set_pstate_{sm,za} in this function.
Do not call helper_* functions from svcr_write.
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-8-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 5c922ec5b136b452fe9d21e7581c99554ce650ed)
---
target/arm/helper-sme.h | 3 +--
target/arm/helper.c | 2 --
target/arm/sme_helper.c | 9 ++-------
target/arm/translate-a64.c | 10 ++--------
4 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/target/arm/helper-sme.h b/target/arm/helper-sme.h
index d33fbcd8fd..d22bf9d21b 100644
--- a/target/arm/helper-sme.h
+++ b/target/arm/helper-sme.h
@@ -17,8 +17,7 @@
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
-DEF_HELPER_FLAGS_2(set_pstate_sm, TCG_CALL_NO_RWG, void, env, i32)
-DEF_HELPER_FLAGS_2(set_pstate_za, TCG_CALL_NO_RWG, void, env, i32)
+DEF_HELPER_FLAGS_3(set_svcr, TCG_CALL_NO_RWG, void, env, i32, i32)
DEF_HELPER_FLAGS_3(sme_zero, TCG_CALL_NO_RWG, void, env, i32, i32)
diff --git a/target/arm/helper.c b/target/arm/helper.c
index bc1c5a1f17..cd501929d7 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -6469,8 +6469,6 @@ void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value)
{
- 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);
}
diff --git a/target/arm/sme_helper.c b/target/arm/sme_helper.c
index bbda651974..3b7c6cd317 100644
--- a/target/arm/sme_helper.c
+++ b/target/arm/sme_helper.c
@@ -29,14 +29,9 @@
#include "vec_internal.h"
#include "sve_ldst_internal.h"
-void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
+void helper_set_svcr(CPUARMState *env, uint32_t val, uint32_t mask)
{
- aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
-}
-
-void helper_set_pstate_za(CPUARMState *env, uint32_t i)
-{
- aarch64_set_svcr(env, 0, R_SVCR_ZA_MASK);
+ aarch64_set_svcr(env, val, mask);
}
void helper_sme_zero(CPUARMState *env, uint32_t imm, uint32_t svl)
diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c
index fa568aa647..9830fe70cf 100644
--- a/target/arm/translate-a64.c
+++ b/target/arm/translate-a64.c
@@ -1861,14 +1861,8 @@ static void handle_msr_i(DisasContext *s, uint32_t insn,
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_helper_set_svcr(cpu_env, tcg_constant_i32(new),
+ tcg_constant_i32(msk));
} else {
s->base.is_jmp = DISAS_NEXT;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 8/9] linux-user/aarch64: Clear TPIDR2_EL0 when delivering signals
2025-07-28 18:16 [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes Richard Henderson
` (6 preceding siblings ...)
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 ` 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
9 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 18:16 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt, Peter Maydell, qemu-stable, Pierrick Bouvier
From: Peter Maydell <peter.maydell@linaro.org>
A recent change to the kernel (Linux commit b376108e1f88
"arm64/fpsimd: signal: Clear TPIDR2 when delivering signals") updated
the signal-handler entry code to always clear TPIDR2_EL0.
This is necessary for the userspace ZA lazy saving scheme to work
correctly when unwinding exceptions across a signal boundary.
(For the essay-length description of the incorrect behaviour and
why this is the correct fix, see the commit message for the
kernel commit.)
Make QEMU also clear TPIDR2_EL0 on signal entry, applying the
equivalent bugfix to our implementation.
Note that getting this unwinding to work correctly also requires
changes to the userspace code, e.g. as implemented in gcc in
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=b5ffc8e75a8
This change is technically an ABI change; from the kernel's
point of view SME was never enabled (it was hidden behind
CONFIG_BROKEN) before the change. From QEMU's point of view
our SME-related signal handling was broken anyway as we weren't
saving and restoring TPIDR2_EL0.
Cc: qemu-stable@nongnu.org
Fixes: 78011586b90d1 ("target/arm: Enable SME for user-only")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250725175510.3864231-2-peter.maydell@linaro.org>
(cherry picked from commit 3cdd990aa920ec8f2994b634f758dab4a86ac167)
---
linux-user/aarch64/signal.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
index b265cfd470..85cb25ae91 100644
--- a/linux-user/aarch64/signal.c
+++ b/linux-user/aarch64/signal.c
@@ -665,8 +665,12 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
env->btype = 2;
}
- /* Invoke the signal handler with both SM and ZA disabled. */
+ /*
+ * Invoke the signal handler with a clean SME state: both SM and ZA
+ * disabled and TPIDR2_EL0 cleared.
+ */
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
+ env->cp15.tpidr2_el0 = 0;
if (info) {
tswap_siginfo(&frame->info, info);
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH 9/9] linux-user/aarch64: Support TPIDR2_MAGIC signal frame record
2025-07-28 18:16 [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes Richard Henderson
` (7 preceding siblings ...)
2025-07-28 18:16 ` [PATCH 8/9] linux-user/aarch64: Clear TPIDR2_EL0 when delivering signals Richard Henderson
@ 2025-07-28 18:16 ` Richard Henderson
2025-07-28 20:50 ` [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes Michael Tokarev
9 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 18:16 UTC (permalink / raw)
To: qemu-devel; +Cc: mjt, Peter Maydell, qemu-stable, Pierrick Bouvier
From: Peter Maydell <peter.maydell@linaro.org>
FEAT_SME adds the TPIDR2 userspace-accessible system register, which
is used as part of the procedure calling standard's lazy saving
scheme for the ZA registers:
https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#66the-za-lazy-saving-scheme
The Linux kernel has a signal frame record for saving
and restoring this value when calling signal handlers, but
we forgot to implement this. The result is that code which
tries to unwind an exception out of a signal handler will
not work correctly.
Add support for the missing record.
Cc: qemu-stable@nongnu.org
Fixes: 78011586b90d1 ("target/arm: Enable SME for user-only")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250725175510.3864231-3-peter.maydell@linaro.org>
(cherry picked from commit 99870aff907b1c863cd32558b543f0ab0d0e74ba)
---
linux-user/aarch64/signal.c | 42 +++++++++++++++++++++++++++++++++++--
1 file changed, 40 insertions(+), 2 deletions(-)
diff --git a/linux-user/aarch64/signal.c b/linux-user/aarch64/signal.c
index 85cb25ae91..34168c967a 100644
--- a/linux-user/aarch64/signal.c
+++ b/linux-user/aarch64/signal.c
@@ -120,6 +120,13 @@ struct target_za_context {
#define TARGET_ZA_SIG_CONTEXT_SIZE(VQ) \
TARGET_ZA_SIG_ZAV_OFFSET(VQ, VQ * TARGET_SVE_VQ_BYTES)
+#define TARGET_TPIDR2_MAGIC 0x54504902
+
+struct target_tpidr2_context {
+ struct target_aarch64_ctx head;
+ uint64_t tpidr2;
+};
+
struct target_rt_sigframe {
struct target_siginfo info;
struct target_ucontext uc;
@@ -252,6 +259,14 @@ static void target_setup_za_record(struct target_za_context *za,
}
}
+static void target_setup_tpidr2_record(struct target_tpidr2_context *tpidr2,
+ CPUARMState *env)
+{
+ __put_user(TARGET_TPIDR2_MAGIC, &tpidr2->head.magic);
+ __put_user(sizeof(struct target_tpidr2_context), &tpidr2->head.size);
+ __put_user(env->cp15.tpidr2_el0, &tpidr2->tpidr2);
+}
+
static void target_restore_general_frame(CPUARMState *env,
struct target_rt_sigframe *sf)
{
@@ -402,6 +417,12 @@ static bool target_restore_za_record(CPUARMState *env,
return true;
}
+static void target_restore_tpidr2_record(CPUARMState *env,
+ struct target_tpidr2_context *tpidr2)
+{
+ __get_user(env->cp15.tpidr2_el0, &tpidr2->tpidr2);
+}
+
static int target_restore_sigframe(CPUARMState *env,
struct target_rt_sigframe *sf)
{
@@ -409,6 +430,7 @@ static int target_restore_sigframe(CPUARMState *env,
struct target_fpsimd_context *fpsimd = NULL;
struct target_sve_context *sve = NULL;
struct target_za_context *za = NULL;
+ struct target_tpidr2_context *tpidr2 = NULL;
uint64_t extra_datap = 0;
bool used_extra = false;
int sve_size = 0;
@@ -459,6 +481,14 @@ static int target_restore_sigframe(CPUARMState *env,
za_size = size;
break;
+ case TARGET_TPIDR2_MAGIC:
+ if (tpidr2 || size != sizeof(struct target_tpidr2_context) ||
+ !cpu_isar_feature(aa64_sme, env_archcpu(env))) {
+ goto err;
+ }
+ tpidr2 = (struct target_tpidr2_context *)ctx;
+ break;
+
case TARGET_EXTRA_MAGIC:
if (extra || size != sizeof(struct target_extra_context)) {
goto err;
@@ -496,6 +526,9 @@ static int target_restore_sigframe(CPUARMState *env,
if (za && !target_restore_za_record(env, za, za_size, &svcr)) {
goto err;
}
+ if (tpidr2) {
+ target_restore_tpidr2_record(env, tpidr2);
+ }
if (env->svcr != svcr) {
env->svcr = svcr;
arm_rebuild_hflags(env);
@@ -567,8 +600,8 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
.total_size = offsetof(struct target_rt_sigframe,
uc.tuc_mcontext.__reserved),
};
- int fpsimd_ofs, fr_ofs, sve_ofs = 0, za_ofs = 0;
- int sve_size = 0, za_size = 0;
+ int fpsimd_ofs, fr_ofs, sve_ofs = 0, za_ofs = 0, tpidr2_ofs = 0;
+ int sve_size = 0, za_size = 0, tpidr2_size = 0;
struct target_rt_sigframe *frame;
struct target_rt_frame_record *fr;
abi_ulong frame_addr, return_addr;
@@ -584,6 +617,8 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
sve_ofs = alloc_sigframe_space(sve_size, &layout);
}
if (cpu_isar_feature(aa64_sme, env_archcpu(env))) {
+ tpidr2_size = sizeof(struct target_tpidr2_context);
+ tpidr2_ofs = alloc_sigframe_space(tpidr2_size, &layout);
/* ZA state needs saving only if it is enabled. */
if (FIELD_EX64(env->svcr, SVCR, ZA)) {
za_size = TARGET_ZA_SIG_CONTEXT_SIZE(sme_vq(env));
@@ -643,6 +678,9 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
if (za_ofs) {
target_setup_za_record((void *)frame + za_ofs, env, za_size);
}
+ if (tpidr2_ofs) {
+ target_setup_tpidr2_record((void *)frame + tpidr2_ofs, env);
+ }
/* Set up the stack frame for unwinding. */
fr = (void *)frame + fr_ofs;
--
2.43.0
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH 4/9] target/arm/sme: Reset SVE state in aarch64_set_svcr()
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
0 siblings, 1 reply; 13+ messages in thread
From: Michael Tokarev @ 2025-07-28 19:43 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
Cc: Fabiano Rosas, Philippe Mathieu-Daudé, Peter Maydell
On 28.07.2025 21:16, Richard Henderson wrote:
> Move arm_reset_sve_state() calls to aarch64_set_svcr().
> (cherry picked from commit 7f2a01e7368f960fadea38f437d0f6de7f249686)
> +/* ResetSVEState */
> +static void arm_reset_sve_state(CPUARMState *env)
> +{
> + memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs));
> + /* Recall that FFR is stored as pregs[16]. */
> + memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs));
> + vfp_set_fpcr(env, 0x0800009f);
> +}
> -/* ResetSVEState */
> -void arm_reset_sve_state(CPUARMState *env)
> -{
> - memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs));
> - /* Recall that FFR is stored as pregs[16]. */
> - memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs));
> - vfp_set_fpsr(env, 0x0800009f);
> -}
It's a fun one. Please note vfp_set_fpsr vs vfp_set_fpcr.
cf. 1edc3d43f20df0d04f8d00b906ba19fed37512a5 which has been
back-ported to 7.2 already :)
Unfortunately the order of these commits is different than
the one on master.
/mjt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes
2025-07-28 18:16 [PATCH stable-7.2 0/9] linux-user/aarch64: Backport TPIDR2_EL0 fixes Richard Henderson
` (8 preceding siblings ...)
2025-07-28 18:16 ` [PATCH 9/9] linux-user/aarch64: Support TPIDR2_MAGIC signal frame record Richard Henderson
@ 2025-07-28 20:50 ` Michael Tokarev
9 siblings, 0 replies; 13+ messages in thread
From: Michael Tokarev @ 2025-07-28 20:50 UTC (permalink / raw)
To: Richard Henderson, qemu-devel
On 28.07.2025 21:16, Richard Henderson wrote:
> Hi Michael,
>
> Here's the aarch64-linux-user TPIDR2_EL0 fixes backported to the
> stable-7.2 branch. Including all of the aarch64_set_svcr cleanups
> is probably overkill, but I think it was clearer that way.
This is a good set. What was missing on my side was the list of
commits to pick up. I applied all of them (with the fix for
vfp_set_fpcr vs vfp_set_fpsr which was picked up before), -- all
it applies cleanly.
Let's see how it goes now..
Thank you very much Richard!
/mjt
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH 4/9] target/arm/sme: Reset SVE state in aarch64_set_svcr()
2025-07-28 19:43 ` Michael Tokarev
@ 2025-07-28 21:08 ` Richard Henderson
0 siblings, 0 replies; 13+ messages in thread
From: Richard Henderson @ 2025-07-28 21:08 UTC (permalink / raw)
To: Michael Tokarev, qemu-devel
Cc: Fabiano Rosas, Philippe Mathieu-Daudé, Peter Maydell
On 7/28/25 09:43, Michael Tokarev wrote:
> On 28.07.2025 21:16, Richard Henderson wrote:
>> Move arm_reset_sve_state() calls to aarch64_set_svcr().
>> (cherry picked from commit 7f2a01e7368f960fadea38f437d0f6de7f249686)
>
>> +/* ResetSVEState */
>> +static void arm_reset_sve_state(CPUARMState *env)
>> +{
>> + memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs));
>> + /* Recall that FFR is stored as pregs[16]. */
>> + memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs));
>> + vfp_set_fpcr(env, 0x0800009f);
>> +}
>
>> -/* ResetSVEState */
>> -void arm_reset_sve_state(CPUARMState *env)
>> -{
>> - memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs));
>> - /* Recall that FFR is stored as pregs[16]. */
>> - memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs));
>> - vfp_set_fpsr(env, 0x0800009f);
>> -}
>
> It's a fun one. Please note vfp_set_fpsr vs vfp_set_fpcr.
>
> cf. 1edc3d43f20df0d04f8d00b906ba19fed37512a5 which has been
> back-ported to 7.2 already :)
>
> Unfortunately the order of these commits is different than
> the one on master.
>
> /mjt
Oh, whoops! Thanks for the catch!
r~
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2025-07-28 21:12 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 6/9] target/arm/sme: Rebuild hflags " Richard Henderson
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
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).