KVM: MMU: account for start offset on largepage aligned-sized memslots

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>
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index 3396a5f..93ed78b 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -347,6 +347,9 @@
 		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)