aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r--virt/kvm/kvm_main.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 3caf8162eb6b..e4d358195e54 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -784,13 +784,19 @@ int __kvm_set_memory_region(struct kvm *kvm,
784 784
785 r = -ENOMEM; 785 r = -ENOMEM;
786 786
787 /* Allocate if a slot is being created */ 787 /*
788 * Allocate if a slot is being created. If modifying a slot,
789 * the userspace_addr cannot change.
790 */
788 if (!old.npages) { 791 if (!old.npages) {
789 new.user_alloc = user_alloc; 792 new.user_alloc = user_alloc;
790 new.userspace_addr = mem->userspace_addr; 793 new.userspace_addr = mem->userspace_addr;
791 794
792 if (kvm_arch_create_memslot(&new, npages)) 795 if (kvm_arch_create_memslot(&new, npages))
793 goto out_free; 796 goto out_free;
797 } else if (npages && mem->userspace_addr != old.userspace_addr) {
798 r = -EINVAL;
799 goto out_free;
794 } 800 }
795 801
796 /* Allocate page dirty bitmap if needed */ 802 /* Allocate page dirty bitmap if needed */