From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [patch 1/2] KVM: x86: do not entry guest mode if vcpu is not runnable Date: Mon, 21 Jul 2008 13:09:02 -0300 Message-ID: <20080721160902.GA3119@dmt.cnet> References: <20080721143855.032449406@localhost.localdomain> <20080721144037.226624791@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([66.187.233.31]:57107 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750778AbYGUQJi (ORCPT ); Mon, 21 Jul 2008 12:09:38 -0400 Content-Disposition: inline In-Reply-To: <20080721144037.226624791@localhost.localdomain> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, Jul 21, 2008 at 11:38:56AM -0300, Marcelo Tosatti wrote: > If a vcpu has been offlined, or not initialized at all, signals > requesting userspace work to be performed will result in KVM attempting > to re-entry guest mode. > > Problem is that the in-kernel irqchip emulation happily executes HALTED > state vcpu's. This breaks "savevm" on Windows SMP installation (that > only boots up a single vcpu), for example. > > Fix it by blocking halted vcpu's at kvm_arch_vcpu_ioctl_run(). > > Change the promotion from halted to running to happen in the vcpu > context. Use the information available in kvm_vcpu_block(), and the > current mpstate to make the decision: > > - If there's an in-kernel timer or irq event the halted->running > promotion evaluation can be performed, no need for userspace assistance. > > - If there's a signal, there's either userspace work to be performed > in the vcpu's context or irqchip emulation is in userspace. > > This has the nice side effect of avoiding userspace exit in case > of irq injection to a halted vcpu from the iothread. > > Signed-off-by: Marcelo Tosatti Thinko: reset the vcpu if SIPI received. BTW, "INIT"/"SIPI" states are x86/IA64 specific MP protocol information, aren't they? What are they doing in include/linux/ ? Index: kvm/arch/x86/kvm/x86.c =================================================================== --- kvm.orig/arch/x86/kvm/x86.c +++ kvm/arch/x86/kvm/x86.c @@ -2521,7 +2521,7 @@ int kvm_emulate_halt(struct kvm_vcpu *vc up_read(&vcpu->kvm->slots_lock); ret = kvm_vcpu_block(vcpu); down_read(&vcpu->kvm->slots_lock); - if (ret) + if (ret || vcpu->arch.mp_state == KVM_MP_STATE_SIPI_RECEIVED) return -EINTR; kvm_vcpu_promote_runnable(vcpu); return 1;