]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
KVM: take mmu_lock when updating a deleted slot
authorMarcelo Tosatti <mtosatti@redhat.com>
Mon, 3 Aug 2009 17:57:48 +0000 (14:57 -0300)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 9 Sep 2009 03:33:27 +0000 (20:33 -0700)
(cherry picked from commit b43b1901ad282aeb74161837fb403927102687a1)

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
virt/kvm/kvm_main.c

index 148982913805d052704b01d9e196d5aaae7c64a3..fe0b1eee0898dca253029403d9f2c04af96895b9 100644 (file)
@@ -1055,8 +1055,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);