From patchwork Wed Jun 17 13:07:59 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 30867 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n5HD9A2f031014 for ; Wed, 17 Jun 2009 13:09:10 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933141AbZFQNIa (ORCPT ); Wed, 17 Jun 2009 09:08:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756549AbZFQNIa (ORCPT ); Wed, 17 Jun 2009 09:08:30 -0400 Received: from mx2.redhat.com ([66.187.237.31]:46543 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756700AbZFQNI3 (ORCPT ); Wed, 17 Jun 2009 09:08:29 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n5HD8Wdw017033 for ; Wed, 17 Jun 2009 09:08:32 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n5HD8Vnj031953; Wed, 17 Jun 2009 09:08:31 -0400 Received: from amt.cnet (vpn-51-11.sfbay.redhat.com [10.14.51.11]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5HD8TZ9009533; Wed, 17 Jun 2009 09:08:30 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 6EB46680138; Wed, 17 Jun 2009 10:08:00 -0300 (BRT) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n5HD7xpN014470; Wed, 17 Jun 2009 10:07:59 -0300 Date: Wed, 17 Jun 2009 10:07:59 -0300 From: Marcelo Tosatti To: Gleb Natapov Cc: kvm Subject: Re: KVM: init bsp_vcpu before kvm_arch_vcpu_init Message-ID: <20090617130759.GA14234@amt.cnet> References: <20090616143316.GA2765@amt.cnet> <20090617122905.GB19508@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20090617122905.GB19508@redhat.com> User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Wed, Jun 17, 2009 at 03:29:05PM +0300, Gleb Natapov wrote: > On Tue, Jun 16, 2009 at 11:33:16AM -0300, Marcelo Tosatti wrote: > > > > On x86 mp_state is initialized by kvm_arch_vcpu_init. Right > > now kvm_vcpu_is_bsp returns false because kvm->bsp_vcpu has > > not been initialized, so vcpu_id == 0 ends up with mp_state == > > KVM_MP_STATE_UNINITIALIZED. > > > > Gleb do you see a better way to fix this? > > > I have two, not necessary better ways. The first one is to change > kvm_vcpu_is_bsp() to do kvm->bsp_vcpu_id == vcpu->vcpu_id. Thats much better. > Another one is to understand why mp_state is set to runnable for bsp > here at all. May be we can drop this use of kvm_vcpu_is_bsp() since > mp_state will be set to RUNNABLE in kvm_arch_vcpu_ioctl_set_sregs() > anyway? Testcase is kvmctl without -p, which does not do kvm_arch_vcpu_ioctl_set_sregs. I suppose that is valid? (in practice its no big deal since kvmctl can be updated, and qemu-kvm does set_sregs, but..). KVM: use vcpu_id instead of bsp_vcpu pointer in kvm_vcpu_is_bsp Change kvm_vcpu_is_bsp to use vcpu_id instead of bsp_vcpu pointer, which is only initialized at the end of kvm_vm_ioctl_create_vcpu. Signed-off-by: Marcelo Tosatti --- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 1b48092..026ed0a 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -569,7 +569,7 @@ static inline void kvm_irqfd_release(struct kvm *kvm) {} #ifdef CONFIG_KVM_APIC_ARCHITECTURE static inline bool kvm_vcpu_is_bsp(struct kvm_vcpu *vcpu) { - return vcpu->kvm->bsp_vcpu == vcpu; + return vcpu->kvm->bsp_vcpu_id == vcpu->vcpu_id; } #endif #endif