aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
authorIzik Eidus <izike@qumranet.com>2007-09-27 08:11:22 -0400
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:52:50 -0500
commit290fc38da8187b53b78dd4d5ab27a20b88ef8b61 (patch)
tree983b2b4cecbe489f7b84391c5eed34aa9f073da0 /drivers/kvm/kvm_main.c
parentf566e09fc2c9f4164e1f0017c8c1c7a18bad7d72 (diff)
KVM: Remove the usage of page->private field by rmap
When kvm uses user-allocated pages in the future for the guest, we won't be able to use page->private for rmap, since page->rmap is reserved for the filesystem. So we move the rmap base pointers to the memory slot. A side effect of this is that we need to store the gfn of each gpte in the shadow pages, since the memory slot is addressed by gfn, instead of hfn like struct page. Signed-off-by: Izik Eidus <izik@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
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;