Skip to content

Commit

Permalink
target/arm/sme: Rebuild hflags in aarch64_set_svcr()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rth7680 authored and pm215 committed Jan 23, 2023
1 parent fccb491 commit f431855
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 19 deletions.
8 changes: 1 addition & 7 deletions linux-user/aarch64/cpu_loop.c
Expand Up @@ -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],
Expand Down
3 changes: 0 additions & 3 deletions linux-user/aarch64/signal.c
Expand Up @@ -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);
Expand Down
6 changes: 5 additions & 1 deletion target/arm/helper.c
Expand Up @@ -6738,6 +6738,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) {
Expand All @@ -6755,6 +6758,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,
Expand All @@ -6763,7 +6768,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,
Expand Down
8 changes: 0 additions & 8 deletions target/arm/sme_helper.c
Expand Up @@ -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)
Expand Down

0 comments on commit f431855

Please sign in to comment.