From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@qumranet.com>, Chris Lalancette <clalance@redhat.com>
Cc: kvm-devel <kvm-devel@lists.sourceforge.net>
Subject: [PATCH] account for start offset on largepage aligned-sized memslots
Date: Fri, 4 Apr 2008 17:21:22 -0300 [thread overview]
Message-ID: <20080404202121.GA1763@dmt> (raw)
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
next reply other threads:[~2008-04-04 20:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-04 20:21 Marcelo Tosatti [this message]
2008-04-04 21:24 ` [PATCH] account for start offset on largepage aligned-sized memslots Avi Kivity
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080404202121.GA1763@dmt \
--to=mtosatti@redhat.com \
--cc=avi@qumranet.com \
--cc=clalance@redhat.com \
--cc=kvm-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox