diff options
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r-- | virt/kvm/kvm_main.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 1cd693a76a51..3caf8162eb6b 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -758,10 +758,15 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
758 | new.npages = npages; | 758 | new.npages = npages; |
759 | new.flags = mem->flags; | 759 | new.flags = mem->flags; |
760 | 760 | ||
761 | /* Disallow changing a memory slot's size. */ | 761 | /* |
762 | * Disallow changing a memory slot's size or changing anything about | ||
763 | * zero sized slots that doesn't involve making them non-zero. | ||
764 | */ | ||
762 | r = -EINVAL; | 765 | r = -EINVAL; |
763 | if (npages && old.npages && npages != old.npages) | 766 | if (npages && old.npages && npages != old.npages) |
764 | goto out_free; | 767 | goto out_free; |
768 | if (!npages && !old.npages) | ||
769 | goto out_free; | ||
765 | 770 | ||
766 | /* Check for overlaps */ | 771 | /* Check for overlaps */ |
767 | r = -EEXIST; | 772 | r = -EEXIST; |
@@ -780,7 +785,7 @@ int __kvm_set_memory_region(struct kvm *kvm, | |||
780 | r = -ENOMEM; | 785 | r = -ENOMEM; |
781 | 786 | ||
782 | /* Allocate if a slot is being created */ | 787 | /* Allocate if a slot is being created */ |
783 | if (npages && !old.npages) { | 788 | if (!old.npages) { |
784 | new.user_alloc = user_alloc; | 789 | new.user_alloc = user_alloc; |
785 | new.userspace_addr = mem->userspace_addr; | 790 | new.userspace_addr = mem->userspace_addr; |
786 | 791 | ||