kvm: Separate TCG from KVM cpu execution

Mixing up TCG bits with KVM already led to problems around eflags
emulation on x86. Moreover, quite some code that TCG requires on cpu
enty/exit is useless for KVM. So dispatch between tcg_cpu_exec and
kvm_cpu_exec as early as possible.

The core logic of cpu_halted from cpu_exec is added to
kvm_arch_process_irqchip_events. Moving away from cpu_exec makes
exception_index meaningless for KVM, we can simply pass the exit reason
directly (only "EXCP_DEBUG vs. rest" is relevant).

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
This commit is contained in:
Jan Kiszka 2011-02-07 12:19:18 +01:00 committed by Marcelo Tosatti
parent 83f338f73e
commit 6792a57bf1
4 changed files with 23 additions and 31 deletions

10
cpus.c
View file

@ -800,8 +800,6 @@ static void qemu_kvm_wait_io_event(CPUState *env)
qemu_wait_io_event_common(env);
}
static int qemu_cpu_exec(CPUState *env);
static void *qemu_kvm_cpu_thread_fn(void *arg)
{
CPUState *env = arg;
@ -829,7 +827,7 @@ static void *qemu_kvm_cpu_thread_fn(void *arg)
while (1) {
if (cpu_can_run(env)) {
r = qemu_cpu_exec(env);
r = kvm_cpu_exec(env);
if (r == EXCP_DEBUG) {
cpu_handle_debug_exception(env);
}
@ -1040,7 +1038,7 @@ void vm_stop(int reason)
#endif
static int qemu_cpu_exec(CPUState *env)
static int tcg_cpu_exec(CPUState *env)
{
int ret;
#ifdef CONFIG_PROFILER
@ -1095,9 +1093,11 @@ bool cpu_exec_all(void)
break;
}
if (cpu_can_run(env)) {
r = qemu_cpu_exec(env);
if (kvm_enabled()) {
r = kvm_cpu_exec(env);
qemu_kvm_eat_signals(env);
} else {
r = tcg_cpu_exec(env);
}
if (r == EXCP_DEBUG) {
cpu_handle_debug_exception(env);