From: Richard Henderson <richard.hender...@linaro.org> Signed-off-by: Richard Henderson <richard.hender...@linaro.org> Reviewed-by: Fabiano Rosas <faro...@suse.de> Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> Message-id: 20230112102436.1913-2-phi...@linaro.org Message-Id: <20230112004322.161330-1-richard.hender...@linaro.org> [PMD: Split patch in multiple tiny steps] Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> Signed-off-by: Peter Maydell <peter.mayd...@linaro.org> (cherry picked from commit 535ca76425fc1ffa4311b3a47518b06c596a55c6) Signed-off-by: Michael Tokarev <m...@tls.msk.ru>
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.47.2