@samitouri / QOSamiQemu / commits / c2804566f6

target/arm: do not clear halting reason in has_work helper

The helper will be called multiple times as we exit a loop and until we actually restart (via arm_cpu_exec_halt) we should leave the condition the same. Fixes: 6fd2fcdc61b (target/arm: teach arm_cpu_has_work about halting reasons) Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-id: 20260624103049.884930-4-alex.bennee@linaro.org Signed-off-by: Peter Maydell <peter.maydell@linaro.org>

Alex Bennée committed Jun 24, 2026 at 11:30 UTC c2804566f65493f83003798d063a20f34681a5c4
2 files changed +5 -2
include/hw/core/sysemu-cpu-ops.h
+3
@@ -18,6 +18,9 @@
18 typedef struct SysemuCPUOps {
19 /**
20 * @has_work: Callback for checking if there is work to do.
21 + *
22 + * This function should be idempotent (i.e. not change state) as
23 + * it will likely be queried multiple times before a CPU resumes.
24 */
25 bool (*has_work)(CPUState *cpu); /* MANDATORY NON-NULL */
26 /**
target/arm/cpu.c
+2 -2
@@ -158,7 +158,6 @@ static bool arm_cpu_has_work(CPUState *cs)
158 * A wake-up event should only wake us if we are halted on a WFE
159 */
160 if (cpu->env.halt_reason == HALT_WFE && cpu->env.event_register) {
161 - cpu->env.halt_reason = NOT_HALTED;
161 return true;
162 }
163
@@ -170,7 +169,6 @@ static bool arm_cpu_has_work(CPUState *cs)
169 | CPU_INTERRUPT_NMI | CPU_INTERRUPT_VINMI | CPU_INTERRUPT_VFNMI
170 | CPU_INTERRUPT_VFIQ | CPU_INTERRUPT_VIRQ | CPU_INTERRUPT_VSERR
171 | CPU_INTERRUPT_EXITTB)) {
173 - cpu->env.halt_reason = NOT_HALTED;
172 return true;
173 }
174
@@ -882,6 +880,8 @@ bool arm_cpu_exec_halt(CPUState *cs)
880 if (cpu->wfxt_timer) {
881 timer_del(cpu->wfxt_timer);
882 }
883 + /* clear the halt reason */
884 + cpu->env.halt_reason = NOT_HALTED;
885 }
886 return leave_halt;
887 }