Ver código fonte

KVM: take mmu_lock when updating a deleted slot

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>
Marcelo Tosatti 16 anos atrás
pai
commit
b43b1901ad
1 arquivos alterados com 2 adições e 0 exclusões
  1. 2 0
      virt/kvm/kvm_main.c

+ 2 - 0
virt/kvm/kvm_main.c

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