aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/kvm_main.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 86dd8f3d29c9..c9f6cfe83120 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -663,6 +663,10 @@ skip_lpage:
663 if (!npages) 663 if (!npages)
664 kvm_arch_flush_shadow(kvm); 664 kvm_arch_flush_shadow(kvm);
665 665
666 r = kvm_arch_prepare_memory_region(kvm, &new, old, mem, user_alloc);
667 if (r)
668 goto out_free;
669
666 spin_lock(&kvm->mmu_lock); 670 spin_lock(&kvm->mmu_lock);
667 if (mem->slot >= kvm->memslots->nmemslots) 671 if (mem->slot >= kvm->memslots->nmemslots)
668 kvm->memslots->nmemslots = mem->slot + 1; 672 kvm->memslots->nmemslots = mem->slot + 1;
@@ -670,13 +674,7 @@ skip_lpage:
670 *memslot = new; 674 *memslot = new;
671 spin_unlock(&kvm->mmu_lock); 675 spin_unlock(&kvm->mmu_lock);
672 676
673 r = kvm_arch_set_memory_region(kvm, mem, old, user_alloc); 677 kvm_arch_commit_memory_region(kvm, mem, old, user_alloc);
674 if (r) {
675 spin_lock(&kvm->mmu_lock);
676 *memslot = old;
677 spin_unlock(&kvm->mmu_lock);
678 goto out_free;
679 }
680 678
681 kvm_free_physmem_slot(&old, npages ? &new : NULL); 679 kvm_free_physmem_slot(&old, npages ? &new : NULL);
682 /* Slot deletion case: we have to update the current slot */ 680 /* Slot deletion case: we have to update the current slot */