Skip to content

Commit

Permalink
cpu-exec: reset exception_index correctly
Browse files Browse the repository at this point in the history
Exception index is reset at every entry at every entry into cpu_exec()
function. This may cause missing the exceptions while replaying them.
This patch moves exception_index reset to the locations where they are
processed.

Signed-off-by: Pavel Dovgalyuk <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
Dovgalyuk authored and bonzini committed Dec 15, 2014
1 parent b4ac20b commit e511b4d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion cpu-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ int cpu_exec(CPUArchState *env)
}

cc->cpu_exec_enter(cpu);
cpu->exception_index = -1;

/* Calculate difference between guest clock and host clock.
* This delay includes the delay of the last cycle, so
Expand All @@ -378,6 +377,7 @@ int cpu_exec(CPUArchState *env)
if (ret == EXCP_DEBUG) {
cpu_handle_debug_exception(env);
}
cpu->exception_index = -1;
break;
} else {
#if defined(CONFIG_USER_ONLY)
Expand All @@ -388,6 +388,7 @@ int cpu_exec(CPUArchState *env)
cc->do_interrupt(cpu);
#endif
ret = cpu->exception_index;
cpu->exception_index = -1;
break;
#else
cc->do_interrupt(cpu);
Expand Down
3 changes: 3 additions & 0 deletions cpus.c
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
qemu_mutex_lock(&qemu_global_mutex);
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
cpu->exception_index = -1;
current_cpu = cpu;

r = kvm_init_vcpu(cpu);
Expand Down Expand Up @@ -974,6 +975,7 @@ static void *qemu_dummy_cpu_thread_fn(void *arg)
qemu_mutex_lock_iothread();
qemu_thread_get_self(cpu->thread);
cpu->thread_id = qemu_get_thread_id();
cpu->exception_index = -1;

sigemptyset(&waitset);
sigaddset(&waitset, SIG_IPI);
Expand Down Expand Up @@ -1016,6 +1018,7 @@ static void *qemu_tcg_cpu_thread_fn(void *arg)
CPU_FOREACH(cpu) {
cpu->thread_id = qemu_get_thread_id();
cpu->created = true;
cpu->exception_index = -1;
}
qemu_cond_signal(&qemu_cpu_cond);

Expand Down

0 comments on commit e511b4d

Please sign in to comment.