diff mbox

[2/4] KVM: take mmu_lock when updating a deleted slot

Message ID 20090507210534.015670838@amt.cnet (mailing list archive)
State New, archived
Headers show

Commit Message

Marcelo Tosatti May 7, 2009, 9:03 p.m. UTC
kvm_handle_hva relies on mmu_lock protection to safely access 
the memslot structures.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

Index: kvm-pending/virt/kvm/kvm_main.c
===================================================================
--- kvm-pending.orig/virt/kvm/kvm_main.c
+++ kvm-pending/virt/kvm/kvm_main.c
@@ -1199,8 +1199,10 @@  int __kvm_set_memory_region(struct 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);