@samitouri / QOSamiQemu / commits / 39db8a2f79

target/arm: ensure aarch64 DISAS_WFE will exit

This mirrors the logic for DISAS_WFE in 32 bit world. As the WFE/WFI have similar behaviours shuffle the case statements around a little and update the commentary to cover both. Fixes: 252ec405768 (target-arm: implement WFE/YIELD as a yield for AArch64) Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-id: 20260529082948.363931-5-alex.bennee@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Alex Bennée committed May 29, 2026 at 09:29 UTC 39db8a2f793e5facb35bb97688c63666940b56c7
1 file changed +12 -12
target/arm/tcg/translate-a64.c
+12 -12
@@ -11042,25 +11042,25 @@ static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)
11042 case DISAS_NORETURN:
11043 case DISAS_SWI:
11044 break;
11045 - case DISAS_WFE:
11046 - gen_a64_update_pc(dc, 4);
11047 - gen_helper_wfe(tcg_env);
11048 - break;
11045 case DISAS_YIELD:
11046 gen_a64_update_pc(dc, 4);
11047 gen_helper_yield(tcg_env);
11048 break;
11049 + /*
11050 + * Both WFE/WFI can cause exceptions or exit the loop to
11051 + * halt so we have to make sure we have rectified the PC.
11052 + * However they can also return directly if they don't
11053 + * enter a wait state so we must add an exit block so we exit
11054 + * the loop and check for interrupts.
11055 + */
11056 + case DISAS_WFE:
11057 + gen_a64_update_pc(dc, 4);
11058 + gen_helper_wfe(tcg_env);
11059 + tcg_gen_exit_tb(NULL, 0);
11060 + break;
11061 case DISAS_WFI:
11054 - /*
11055 - * This is a special case because we don't want to just halt
11056 - * the CPU if trying to debug across a WFI.
11057 - */
11062 gen_a64_update_pc(dc, 4);
11063 gen_helper_wfi(tcg_env, tcg_constant_i32(4));
11060 - /*
11061 - * The helper doesn't necessarily throw an exception, but we
11062 - * must go back to the main loop to check for interrupts anyway.
11063 - */
11064 tcg_gen_exit_tb(NULL, 0);
11065 break;
11066 }