In cpu_exec(), check CPUState::halted field early before calling cpu_handle_halt(). The logic is the same but allow to simplify the async event processing hooks that will be added in the next commit.
Signed-off-by: Philippe Mathieu-Daudé <[email protected]> --- accel/tcg/cpu-exec.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 69207301d1d..46b723cb734 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -656,17 +656,15 @@ static inline void tb_add_jump(TranslationBlock *tb, int n, #ifndef CONFIG_USER_ONLY static inline bool cpu_handle_halt(CPUState *cpu) { - if (cpu->halted) { - const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; - bool leave_halt = tcg_ops->cpu_exec_halt(cpu); + const TCGCPUOps *tcg_ops = cpu->cc->tcg_ops; + bool leave_halt = tcg_ops->cpu_exec_halt(cpu); - if (!leave_halt) { - return true; - } - - cpu->halted = 0; + if (!leave_halt) { + return true; } + cpu->halted = 0; /* allow execution */ + return false; } #endif /* !CONFIG_USER_ONLY */ @@ -1028,8 +1026,11 @@ int cpu_exec(CPUState *cpu) current_cpu = cpu; #ifndef CONFIG_USER_ONLY - if (cpu_handle_halt(cpu)) { - return EXCP_HALTED; + if (cpu->halted) { + if (cpu_handle_halt(cpu)) { + return EXCP_HALTED; + } + assert(!cpu->halted); } #endif -- 2.53.0
