Skip to content

Commit 7f2a01e

Browse files
rth7680pm215
authored andcommitted
target/arm/sme: Reset SVE state in aarch64_set_svcr()
Move arm_reset_sve_state() calls to aarch64_set_svcr(). Signed-off-by: Richard Henderson <[email protected]> Reviewed-by: Fabiano Rosas <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-id: [email protected] Message-Id: <[email protected]> [PMD: Split patch in multiple tiny steps] Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: Peter Maydell <[email protected]>
1 parent 2a8af38 commit 7f2a01e

File tree

5 files changed

+14
-19
lines changed

5 files changed

+14
-19
lines changed

linux-user/aarch64/cpu_loop.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ void cpu_loop(CPUARMState *env)
9696
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
9797
if (FIELD_EX64(env->svcr, SVCR, SM)) {
9898
arm_rebuild_hflags(env);
99-
arm_reset_sve_state(env);
10099
}
101100
ret = do_syscall(env,
102101
env->xregs[8],

linux-user/aarch64/signal.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -665,14 +665,8 @@ static void target_setup_frame(int usig, struct target_sigaction *ka,
665665
env->btype = 2;
666666
}
667667

668-
/*
669-
* Invoke the signal handler with both SM and ZA disabled.
670-
* When clearing SM, ResetSVEState, per SMSTOP.
671-
*/
668+
/* Invoke the signal handler with both SM and ZA disabled. */
672669
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK | R_SVCR_ZA_MASK);
673-
if (FIELD_EX64(env->svcr, SVCR, SM)) {
674-
arm_reset_sve_state(env);
675-
}
676670
if (env->svcr) {
677671
arm_rebuild_hflags(env);
678672
}

target/arm/cpu.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,7 +1124,6 @@ void aarch64_sve_narrow_vq(CPUARMState *env, unsigned vq);
11241124
void aarch64_sve_change_el(CPUARMState *env, int old_el,
11251125
int new_el, bool el0_a64);
11261126
void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask);
1127-
void arm_reset_sve_state(CPUARMState *env);
11281127

11291128
/*
11301129
* SVE registers are encoded in KVM's memory in an endianness-invariant format.

target/arm/helper.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6725,11 +6725,24 @@ static CPAccessResult access_esm(CPUARMState *env, const ARMCPRegInfo *ri,
67256725
return CP_ACCESS_OK;
67266726
}
67276727

6728+
/* ResetSVEState */
6729+
static void arm_reset_sve_state(CPUARMState *env)
6730+
{
6731+
memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs));
6732+
/* Recall that FFR is stored as pregs[16]. */
6733+
memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs));
6734+
vfp_set_fpcr(env, 0x0800009f);
6735+
}
6736+
67286737
void aarch64_set_svcr(CPUARMState *env, uint64_t new, uint64_t mask)
67296738
{
67306739
uint64_t change = (env->svcr ^ new) & mask;
67316740

67326741
env->svcr ^= change;
6742+
6743+
if (change & R_SVCR_SM_MASK) {
6744+
arm_reset_sve_state(env);
6745+
}
67336746
}
67346747

67356748
static void svcr_write(CPUARMState *env, const ARMCPRegInfo *ri,

target/arm/sme_helper.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,12 @@
2929
#include "vec_internal.h"
3030
#include "sve_ldst_internal.h"
3131

32-
/* ResetSVEState */
33-
void arm_reset_sve_state(CPUARMState *env)
34-
{
35-
memset(env->vfp.zregs, 0, sizeof(env->vfp.zregs));
36-
/* Recall that FFR is stored as pregs[16]. */
37-
memset(env->vfp.pregs, 0, sizeof(env->vfp.pregs));
38-
vfp_set_fpcr(env, 0x0800009f);
39-
}
40-
4132
void helper_set_pstate_sm(CPUARMState *env, uint32_t i)
4233
{
4334
if (i == FIELD_EX64(env->svcr, SVCR, SM)) {
4435
return;
4536
}
4637
aarch64_set_svcr(env, 0, R_SVCR_SM_MASK);
47-
arm_reset_sve_state(env);
4838
arm_rebuild_hflags(env);
4939
}
5040

0 commit comments

Comments
 (0)