From: Marcelo Tosatti <mtosatti@redhat.com>
To: Avi Kivity <avi@qumranet.com>
Cc: kvm-devel <kvm@vger.kernel.org>
Subject: KVM: MMU: rmap_write_protect() hugepage iteration bug
Date: Sat, 7 Jun 2008 21:27:36 -0300 [thread overview]
Message-ID: <20080608002736.GA25582@dmt.cnet> (raw)
rmap_next() expects the "spte" argument to be NULL whenever there's only
one remaining entry in the descriptor. That is, it was not designed to
handle changes in the chain while iterating.
This bug cripples rmap_write_protect() so that it won't nuke all
writable large mappings to a particular gfn.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index aaccc40..e11ff17 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -632,17 +632,19 @@ static void rmap_write_protect(struct kvm *kvm, u64 gfn)
rmapp = gfn_to_rmap(kvm, gfn, 1);
spte = rmap_next(kvm, rmapp, NULL);
while (spte) {
+ u64 *next_spte;
BUG_ON(!spte);
BUG_ON(!(*spte & PT_PRESENT_MASK));
BUG_ON((*spte & (PT_PAGE_SIZE_MASK|PT_PRESENT_MASK)) != (PT_PAGE_SIZE_MASK|PT_PRESENT_MASK));
pgprintk("rmap_write_protect(large): spte %p %llx %lld\n", spte, *spte, gfn);
+ next_spte = rmap_next(kvm, rmapp, spte);
if (is_writeble_pte(*spte)) {
rmap_remove(kvm, spte);
--kvm->stat.lpages;
set_shadow_pte(spte, shadow_trap_nonpresent_pte);
write_protected = 1;
}
- spte = rmap_next(kvm, rmapp, spte);
+ spte = next_spte;
}
if (write_protected)
next reply other threads:[~2008-06-08 0:28 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-06-08 0:27 Marcelo Tosatti [this message]
2008-06-08 1:54 ` KVM: MMU: rmap_write_protect() hugepage iteration bug Andrea Arcangeli
2008-06-08 4:48 ` Marcelo Tosatti
2008-06-08 7:30 ` Avi Kivity
2008-06-08 8:03 ` Avi Kivity
2008-06-08 8:04 ` Avi Kivity
2008-06-08 18:31 ` Andrea Arcangeli
2008-06-08 19:52 ` Marcelo Tosatti
2008-06-08 20:30 ` Andrea Arcangeli
2008-06-09 0:20 ` Marcelo Tosatti
2008-06-09 0:55 ` Andrea Arcangeli
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=20080608002736.GA25582@dmt.cnet \
--to=mtosatti@redhat.com \
--cc=avi@qumranet.com \
--cc=kvm@vger.kernel.org \
/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