aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcelo Tosatti <mtosatti@redhat.com>2008-04-04 17:21:22 -0300
committerAvi Kivity <avi@qumranet.com>2008-04-05 00:23:49 +0300
commit3743888cafbada95d9907a1b5fb001993b1ee03e (patch)
tree247791ceee68be9f534c86e0ba81012f7ab8f7d6
parentfafac27bad9f4d8fd9f0b50e41c5591eb0805cd7 (diff)
KVM: MMU: account for start offset on largepage aligned-sized memslotskvm-65rc1kvm-65
Account for the case where memslot size is largepage aligned, but does not start on largepage aligned offset. Otherwise it allocates one lpage_info struct less than what the memslot spans, possibly resulting in memory corruption. Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
-rw-r--r--virt/kvm/kvm_main.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 3396a5f9be5d..93ed78b015c0 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -347,6 +347,9 @@ int __kvm_set_memory_region(struct kvm *kvm,
int largepages = npages / KVM_PAGES_PER_HPAGE;
if (npages % KVM_PAGES_PER_HPAGE)
largepages++;
+ if (base_gfn % KVM_PAGES_PER_HPAGE)
+ largepages++;
+
new.lpage_info = vmalloc(largepages * sizeof(*new.lpage_info));
if (!new.lpage_info)