Commit 4515e58d authored by Paolo Bonzini's avatar Paolo Bonzini
Browse files

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: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent a42cf3f3
Loading
Loading
Loading
Loading
+27 −31
Original line number Diff line number Diff line
@@ -624,25 +624,8 @@ int cpu_exec(CPUState *cpu)
     */
    init_delay_params(&sc, cpu);

    for(;;) {
    /* prepare setjmp context for exception handling */
        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 (sigsetjmp(cpu->jmp_env, 0) != 0) {
#if defined(__clang__) || !QEMU_GNUC_PREREQ(4, 6)
        /* Some compilers wrongly smash all local variables after
         * siglongjmp. There were bug reports for gcc 4.5.0 and clang.
@@ -658,7 +641,20 @@ int cpu_exec(CPUState *cpu)
        cpu->can_do_io = 1;
        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);
    rcu_read_unlock();