From: Avi Kivity Date: Tue, 5 Jun 2007 11:36:10 +0000 (+0300) Subject: KVM: Fix adding an smp virtual machine to the vm list X-Git-Tag: MMI-PSA29.97-13-9~41709^2~31 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=120e9a453b5e7d9a708caff7d97b71fc4ccd59e8;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git KVM: Fix adding an smp virtual machine to the vm list If we add the vm once per vcpu, we corrupt the list if the guest has multiple vcpus. Signed-off-by: Avi Kivity --- diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index 3ff8ee56279c..230b25aa469c 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -319,6 +319,9 @@ static struct kvm *kvm_create_vm(void) spin_lock_init(&kvm->lock); INIT_LIST_HEAD(&kvm->active_mmu_pages); + spin_lock(&kvm_lock); + list_add(&kvm->vm_list, &vm_list); + spin_unlock(&kvm_lock); for (i = 0; i < KVM_MAX_VCPUS; ++i) { struct kvm_vcpu *vcpu = &kvm->vcpus[i]; @@ -326,9 +329,6 @@ static struct kvm *kvm_create_vm(void) vcpu->cpu = -1; vcpu->kvm = kvm; vcpu->mmu.root_hpa = INVALID_PAGE; - spin_lock(&kvm_lock); - list_add(&kvm->vm_list, &vm_list); - spin_unlock(&kvm_lock); } return kvm; }