The cpu->exit_request check in cpu_loop_exec_tb is unnecessary, because cpu->tcg_exit_req is always set after cpu->exit_request. So let the TB exit and we will pick up the exit request later in cpu_handle_interrupt.
Likewise, use cpu->exit_request to set EXCP_INTERRUPT when the instruction counter expires. Because cpu_loop_exec_tb is followed immediately by align_clocks, this lets us remove the SyncClocks *sc argument to cpu_loop_exec_tb. Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- cpu-exec.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 903a834..3838eb8 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -517,6 +517,8 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, *last_tb = NULL; } } + + /* Finally, check if we need to exit to the main loop. */ if (unlikely(atomic_read(&cpu->exit_request) || replay_has_interrupt())) { atomic_set(&cpu->exit_request, 0); cpu->exception_index = EXCP_INTERRUPT; @@ -527,16 +529,11 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, - TranslationBlock **last_tb, int *tb_exit, - SyncClocks *sc) + TranslationBlock **last_tb, int *tb_exit) { uintptr_t ret; int32_t insns_left; - if (unlikely(atomic_read(&cpu->exit_request))) { - return; - } - trace_exec_tb(tb, tb->pc); ret = cpu_tb_exec(cpu, tb); tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK); @@ -578,10 +575,8 @@ static inline void cpu_loop_exec_tb(CPUState *cpu, TranslationBlock *tb, */ if (insns_left > 0) { cpu_exec_nocache(cpu, insns_left, tb, false); - align_clocks(sc, cpu); } - cpu->exception_index = EXCP_INTERRUPT; - cpu_loop_exit(cpu); + atomic_set(&cpu->exit_request, 1); } } @@ -641,7 +636,7 @@ int cpu_exec(CPUState *cpu) while (!cpu_handle_interrupt(cpu, &last_tb)) { TranslationBlock *tb = tb_find(cpu, last_tb, tb_exit); - cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit, &sc); + cpu_loop_exec_tb(cpu, tb, &last_tb, &tb_exit); /* Try to align the host and virtual clocks if the guest is in advance */ align_clocks(&sc, cpu); -- 2.9.3