From: Peng Hao <peng.hao2@zte.com.cn>
To: pbonzini@redhat.com, rkrcmar@redhat.com
Cc: x86@kernel.org, kvm@vger.kernel.org,
linux-kernel@vger.kernel.org, Peng Hao <peng.hao2@zte.com.cn>
Subject: [PATCH] KVM: X86: fix a bad_page bug_on path
Date: Sat, 14 Oct 2017 05:48:14 +0800 [thread overview]
Message-ID: <1507931294-58108-1-git-send-email-peng.hao2@zte.com.cn> (raw)
When poweroff L1 Guest with L2 guset on L1, it exists a path to
trigger a bad_page bug_on.
!page_count(pfn_to_page(pfn)) Warning in mmu_spte_clear_track_bits will
appear before,then it may set A/D bit for the freed page and trigger a
bad_page bug_on.
Signed-off-by: Peng Hao <peng.hao2@zte.com.cn>
---
arch/x86/kvm/mmu.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index eca30c1..398de96 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -711,12 +711,8 @@ static int mmu_spte_clear_track_bits(u64 *sptep)
pfn = spte_to_pfn(old_spte);
- /*
- * KVM does not hold the refcount of the page used by
- * kvm mmu, before reclaiming the page, we should
- * unmap it from mmu first.
- */
- WARN_ON(!kvm_is_reserved_pfn(pfn) && !page_count(pfn_to_page(pfn)));
+ if (!page_count(pfn_to_page(pfn)))
+ return 1;
if (is_accessed_spte(old_spte))
kvm_set_pfn_accessed(pfn);
--
1.8.3.1
next reply other threads:[~2017-10-13 13:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-13 21:48 Peng Hao [this message]
2017-10-13 15:04 ` Paolo Bonzini
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=1507931294-58108-1-git-send-email-peng.hao2@zte.com.cn \
--to=peng.hao2@zte.com.cn \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=rkrcmar@redhat.com \
--cc=x86@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
all inboxes | Powered by JetHome®