aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm
diff options
context:
space:
mode:
authorRusty Russell <rusty@rustcorp.com.au>2007-07-23 03:08:21 -0400
committerAvi Kivity <avi@qumranet.com>2007-07-25 07:29:34 -0400
commit5e58cfe41c7e5902c32bb7f62993d43fb4c48ccf (patch)
tree5836d843b325dcea7ba9243f4c9ccb4664ecd255 /drivers/kvm
parentb0fcd903e6f3f47189baddf3fe085bdf78c9644c (diff)
KVM: Fix unlikely kvm_create vs decache_vcpus_on_cpu race
We add the kvm to the vm_list before initializing the vcpu mutexes, which can be mutex_trylock()'ed by decache_vcpus_on_cpu(). Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/kvm_main.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index a0a3fddba815..46efbe70801c 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -297,9 +297,6 @@ static struct kvm *kvm_create_vm(void)
297 kvm_io_bus_init(&kvm->pio_bus); 297 kvm_io_bus_init(&kvm->pio_bus);
298 spin_lock_init(&kvm->lock); 298 spin_lock_init(&kvm->lock);
299 INIT_LIST_HEAD(&kvm->active_mmu_pages); 299 INIT_LIST_HEAD(&kvm->active_mmu_pages);
300 spin_lock(&kvm_lock);
301 list_add(&kvm->vm_list, &vm_list);
302 spin_unlock(&kvm_lock);
303 kvm_io_bus_init(&kvm->mmio_bus); 300 kvm_io_bus_init(&kvm->mmio_bus);
304 for (i = 0; i < KVM_MAX_VCPUS; ++i) { 301 for (i = 0; i < KVM_MAX_VCPUS; ++i) {
305 struct kvm_vcpu *vcpu = &kvm->vcpus[i]; 302 struct kvm_vcpu *vcpu = &kvm->vcpus[i];
@@ -309,6 +306,9 @@ static struct kvm *kvm_create_vm(void)
309 vcpu->kvm = kvm; 306 vcpu->kvm = kvm;
310 vcpu->mmu.root_hpa = INVALID_PAGE; 307 vcpu->mmu.root_hpa = INVALID_PAGE;
311 } 308 }
309 spin_lock(&kvm_lock);
310 list_add(&kvm->vm_list, &vm_list);
311 spin_unlock(&kvm_lock);
312 return kvm; 312 return kvm;
313} 313}
314 314