On Mon, May 25, 2009 at 05:46:22PM -0300, Marcelo Tosatti wrote: > 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 <gleb@xxxxxxxxxx> > > --- > > 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). I doesn't oops since if BSP is not created this code is not reached (nothing runs eventually). But see below. > > Also you said "The code still assumes that boot cpu is created first." > Where is that? > Oops. It should be like this, but this patch series has a bug. In kvm_vm_ioctl_create_vcpu: if (id == 0) kvm->bsp_vcpu = vcpu; should be: if (!kvm->bsp_vcpu) kvm->bsp_vcpu = vcpu; I really don't want to make acpi_id zero to be special. > 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@xxxxxxxxxxxxxxx > > More majordomo info at http://vger.kernel.org/majordomo-info.html -- Gleb. -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html