public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] account for start offset on largepage aligned-sized memslots
@ 2008-04-04 20:21 Marcelo Tosatti
  2008-04-04 21:24 ` Avi Kivity
  0 siblings, 1 reply; 2+ messages in thread
From: Marcelo Tosatti @ 2008-04-04 20:21 UTC (permalink / raw)
  To: Avi Kivity, Chris Lalancette; +Cc: kvm-devel


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>


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 __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)

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] account for start offset on largepage aligned-sized memslots
  2008-04-04 20:21 [PATCH] account for start offset on largepage aligned-sized memslots Marcelo Tosatti
@ 2008-04-04 21:24 ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2008-04-04 21:24 UTC (permalink / raw)
  To: Marcelo Tosatti; +Cc: kvm-devel, Chris Lalancette

Marcelo Tosatti wrote:
> 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.
>   

Applied, thanks.

-- 
Any sufficiently difficult bug is indistinguishable from a feature.


-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-04-04 21:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-04 20:21 [PATCH] account for start offset on largepage aligned-sized memslots Marcelo Tosatti
2008-04-04 21:24 ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox