提交 4515e58d 编写于 作者: P Paolo Bonzini

cpu-exec: remove outermost infinite loop

Reorganize the sigsetjmp so that the restart case falls through
to cpu_handle_exception and the execution loop.
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 a42cf3f3
...@@ -624,25 +624,8 @@ int cpu_exec(CPUState *cpu) ...@@ -624,25 +624,8 @@ int cpu_exec(CPUState *cpu)
*/ */
init_delay_params(&sc, cpu); init_delay_params(&sc, cpu);
for(;;) {
/* prepare setjmp context for exception handling */ /* prepare setjmp context for exception handling */
if (sigsetjmp(cpu->jmp_env, 0) == 0) { if (sigsetjmp(cpu->jmp_env, 0) != 0) {
/* if an exception is pending, we execute it here */
while (!cpu_handle_exception(cpu, &ret)) {
TranslationBlock *last_tb = NULL;
int tb_exit = 0;
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);
/* Try to align the host and virtual clocks
if the guest is in advance */
align_clocks(&sc, cpu);
}
}
break;
} else {
#if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6) #if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6)
/* Some compilers wrongly smash all local variables after /* Some compilers wrongly smash all local variables after
* siglongjmp. There were bug reports for gcc 4.5.0 and clang. * siglongjmp. There were bug reports for gcc 4.5.0 and clang.
...@@ -658,7 +641,20 @@ int cpu_exec(CPUState *cpu) ...@@ -658,7 +641,20 @@ int cpu_exec(CPUState *cpu)
cpu->can_do_io = 1; cpu->can_do_io = 1;
tb_lock_reset(); tb_lock_reset();
} }
} /* for(;;) */
/* if an exception is pending, we execute it here */
while (!cpu_handle_exception(cpu, &ret)) {
TranslationBlock *last_tb = NULL;
int tb_exit = 0;
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);
/* Try to align the host and virtual clocks
if the guest is in advance */
align_clocks(&sc, cpu);
}
}
cc->cpu_exec_exit(cpu); cc->cpu_exec_exit(cpu);
rcu_read_unlock(); rcu_read_unlock();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册