aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 888b0924c17b..9510e2276ca3 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -309,6 +309,8 @@ static void kvm_free_physmem_slot(struct kvm_memory_slot *free,
309 __free_page(free->phys_mem[i]); 309 __free_page(free->phys_mem[i]);
310 vfree(free->phys_mem); 310 vfree(free->phys_mem);
311 } 311 }
312 if (!dont || free->rmap != dont->rmap)
313 vfree(free->rmap);
312 314
313 if (!dont || free->dirty_bitmap != dont->dirty_bitmap) 315 if (!dont || free->dirty_bitmap != dont->dirty_bitmap)
314 vfree(free->dirty_bitmap); 316 vfree(free->dirty_bitmap);
@@ -719,13 +721,18 @@ static int kvm_vm_ioctl_set_memory_region(struct kvm *kvm,
719 if (!new.phys_mem) 721 if (!new.phys_mem)
720 goto out_unlock; 722 goto out_unlock;
721 723
724 new.rmap = vmalloc(npages * sizeof(struct page*));
725
726 if (!new.rmap)
727 goto out_unlock;
728
722 memset(new.phys_mem, 0, npages * sizeof(struct page *)); 729 memset(new.phys_mem, 0, npages * sizeof(struct page *));
730 memset(new.rmap, 0, npages * sizeof(*new.rmap));
723 for (i = 0; i < npages; ++i) { 731 for (i = 0; i < npages; ++i) {
724 new.phys_mem[i] = alloc_page(GFP_HIGHUSER 732 new.phys_mem[i] = alloc_page(GFP_HIGHUSER
725 | __GFP_ZERO); 733 | __GFP_ZERO);
726 if (!new.phys_mem[i]) 734 if (!new.phys_mem[i])
727 goto out_unlock; 735 goto out_unlock;
728 set_page_private(new.phys_mem[i],0);
729 } 736 }
730 } 737 }
731 738
@@ -909,7 +916,7 @@ static int kvm_vm_ioctl_set_irqchip(struct kvm *kvm, struct kvm_irqchip *chip)
909 return r; 916 return r;
910} 917}
911 918
912static gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) 919gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
913{ 920{
914 int i; 921 int i;
915 struct kvm_mem_alias *alias; 922 struct kvm_mem_alias *alias;