Re: [PATCH RFC v2 1/4] Introduce kvm_vcpu_is_bsp() function.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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).

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@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
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

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux