KVM: take mmu_lock when updating a deleted slot
authorMarcelo Tosatti <mtosatti@redhat.com>
Tue, 12 May 2009 21:55:44 +0000 (18:55 -0300)
committerAvi Kivity <avi@redhat.com>
Wed, 10 Jun 2009 08:48:54 +0000 (11:48 +0300)
kvm_handle_hva relies on mmu_lock protection to safely access
the memslot structures.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
virt/kvm/kvm_main.c

index 687d113a3e5e8186dd2325a1d4d418055f56290e..5fed9bfc3cf5b8b64e5449625be6ba017a04e167 100644 (file)
@@ -1210,8 +1210,10 @@ int __kvm_set_memory_region(struct kvm *kvm,
 
        kvm_free_physmem_slot(&old, npages ? &new : NULL);
        /* Slot deletion case: we have to update the current slot */
+       spin_lock(&kvm->mmu_lock);
        if (!npages)
                *memslot = old;
+       spin_unlock(&kvm->mmu_lock);
 #ifdef CONFIG_DMAR
        /* map the pages in iommu page table */
        r = kvm_iommu_map_pages(kvm, base_gfn, npages);