Skip to contentSkip to conversation

account for start offset on largepage aligned-sized memslots

PATCH Applied Marcelo Tosatti 2 participants 2 messages Apr 4, 2008 KVM

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

virt/kvm/kvm_main.c +3 -0
index 3396a5f..93ed78b 100644
@@ -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

Applied
#1 lore raw
Quoted 6 lines · Marcelo Tosatti

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.

Signature · 8 lines
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