From 515bcb06e63a0e9a6f9b85a2943ed0a9c3f68e23 Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Tue, 15 Apr 2008 16:35:58 +0300 Subject: Fix reset with iothread Reset processing moved to the iothread, which can take too long to process. Move it back to whatever vcpu is executing. Signed-off-by: Avi Kivity --- qemu-kvm.c | 21 ++++++++++++++++----- qemu-kvm.h | 2 ++ vl.c | 5 +++++ 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 89e267cba..7a88cddf4 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -52,6 +52,7 @@ struct vcpu_info { int signalled; int stop; int stopped; + int reload_regs; } vcpu_info[256]; pthread_t io_thread; @@ -307,6 +308,17 @@ static void setup_kernel_sigmask(CPUState *env) kvm_set_signal_mask(kvm_context, env->cpu_index, &set); } +void qemu_kvm_system_reset_request(void) +{ + int i; + + for (i = 0; i < smp_cpus; ++i) { + vcpu_info[i].reload_regs = 1; + pthread_kill(vcpu_info[i].thread, SIG_IPI); + } + qemu_system_reset(); +} + static int kvm_main_loop_cpu(CPUState *env) { struct vcpu_info *info = &vcpu_info[env->cpu_index]; @@ -334,11 +346,10 @@ static int kvm_main_loop_cpu(CPUState *env) kvm_cpu_exec(env); env->interrupt_request &= ~CPU_INTERRUPT_EXIT; kvm_main_loop_wait(env, 0); - if (qemu_kvm_reset_requested && env->cpu_index == 0) { - qemu_kvm_reset_requested = 0; - env->interrupt_request = 0; - qemu_system_reset(); - kvm_arch_load_regs(env); + if (info->reload_regs) { + info->reload_regs = 0; + if (env->cpu_index == 0) /* ap needs to be placed in INIT */ + kvm_arch_load_regs(env); } } pthread_mutex_unlock(&qemu_mutex); diff --git a/qemu-kvm.h b/qemu-kvm.h index cae20bcd4..024a6533f 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -72,6 +72,8 @@ void kvm_tpr_vcpu_start(CPUState *env); int qemu_kvm_get_dirty_pages(unsigned long phys_addr, void *buf); +void qemu_kvm_system_reset_request(void); + #ifdef TARGET_PPC int handle_powerpc_dcr_read(int vcpu, uint32_t dcrn, uint32_t *data); int handle_powerpc_dcr_write(int vcpu,uint32_t dcrn, uint32_t data); diff --git a/vl.c b/vl.c index e544f7cdd..b425ab57e 100644 --- a/vl.c +++ b/vl.c @@ -7804,6 +7804,11 @@ void qemu_system_reset_request(void) } if (cpu_single_env) cpu_interrupt(cpu_single_env, CPU_INTERRUPT_EXIT); +#ifdef USE_KVM + if (kvm_allowed) + if (!no_reboot) + qemu_kvm_system_reset_request(); +#endif } void qemu_system_shutdown_request(void) -- cgit v1.2.3