From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH RFC v2 1/4] Introduce kvm_vcpu_is_bsp() function. Date: Mon, 25 May 2009 17:46:22 -0300 Message-ID: <20090525204622.GA7890@amt.cnet> References: <1243266636-16914-1-git-send-email-gleb@redhat.com> <1243266636-16914-2-git-send-email-gleb@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Gleb Natapov Return-path: Received: from mx2.redhat.com ([66.187.237.31]:34036 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752607AbZEYUqd (ORCPT ); Mon, 25 May 2009 16:46:33 -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 n4PKkaAD029954 for ; Mon, 25 May 2009 16:46:36 -0400 Content-Disposition: inline In-Reply-To: <1243266636-16914-2-git-send-email-gleb@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Mon, May 25, 2009 at 06:50:33PM +0300, Gleb Natapov wrote: > Use it instead of open code "vcpu_id zero is BSP" assumption. > > Signed-off-by: Gleb Natapov > --- > arch/ia64/kvm/kvm-ia64.c | 2 +- > arch/ia64/kvm/vcpu.c | 2 +- > arch/x86/kvm/i8254.c | 4 ++-- > arch/x86/kvm/i8259.c | 6 +++--- > arch/x86/kvm/lapic.c | 7 ++++--- > arch/x86/kvm/svm.c | 4 ++-- > arch/x86/kvm/vmx.c | 6 +++--- > arch/x86/kvm/x86.c | 4 ++-- > include/linux/kvm_host.h | 5 +++++ > virt/kvm/ioapic.c | 4 +++- > virt/kvm/kvm_main.c | 2 ++ > 11 files changed, 28 insertions(+), 18 deletions(-) > > #endif > diff --git a/virt/kvm/ioapic.c b/virt/kvm/ioapic.c > index 1eddae9..a8a8252 100644 > --- a/virt/kvm/ioapic.c > +++ b/virt/kvm/ioapic.c > @@ -165,7 +165,9 @@ static int ioapic_deliver(struct kvm_ioapic *ioapic, int irq) > /* Always delivery PIT interrupt to vcpu 0 */ > if (irq == 0) { > irqe.dest_mode = 0; /* Physical mode. */ > - irqe.dest_id = ioapic->kvm->vcpus[0]->vcpu_id; > + /* need to read apic_id from apic regiest since > + * it can be rewritten */ > + irqe.dest_id = ioapic->kvm->bsp_vcpu->vcpu_id; > } Won't this oops if userspace creates only vcpu 3 and attempts to deliver to IRQ0 ? (not directly related to the patchset though). Also you said "The code still assumes that boot cpu is created first." Where is that? Otherwise, neat! > #endif > return kvm_irq_delivery_to_apic(ioapic->kvm, NULL, &irqe); > diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c > index de042cb..5a55fe0 100644 > --- a/virt/kvm/kvm_main.c > +++ b/virt/kvm/kvm_main.c > @@ -1737,6 +1737,8 @@ static int kvm_vm_ioctl_create_vcpu(struct kvm *kvm, int n) > goto vcpu_destroy; > } > kvm->vcpus[n] = vcpu; > + if (n == 0) > + kvm->bsp_vcpu = vcpu; > mutex_unlock(&kvm->lock); > > /* Now it's all set up, let userspace reach it */ > -- > 1.6.2.1 > > -- > 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