From: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
To: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>,
Gleb Natapov <gleb@redhat.com>,
LKML <linux-kernel@vger.kernel.org>, KVM <kvm@vger.kernel.org>
Subject: [PATCH v3 4/5] KVM: MMU: fix spte assertion
Date: Tue, 05 Feb 2013 16:54:59 +0800 [thread overview]
Message-ID: <5110C8E3.1080009@linux.vnet.ibm.com> (raw)
In-Reply-To: <5110C853.4080705@linux.vnet.ibm.com>
PT_PRESENT_MASK bit is not enough to see the spte has already been mapped
into pte-list for mmio spte also set this bit. Use is_shadow_present_pte
instead to fix it
Also, this patch move many assertions to the common place to clean up the
code
Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>
---
arch/x86/kvm/mmu.c | 20 ++++++--------------
1 files changed, 6 insertions(+), 14 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 2291ea3..58f813a 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1009,7 +1009,9 @@ static u64 *pte_list_get_next(struct pte_list_iterator *iter)
#define for_each_spte_in_pte_list(pte_list, iter, spte) \
for (spte = pte_list_get_first(pte_list, &(iter)); \
- spte != NULL; spte = pte_list_get_next(&(iter)))
+ spte != NULL && \
+ ({WARN_ON(!is_shadow_present_pte(*(spte))); 1; });\
+ spte = pte_list_get_next(&iter))
#define for_each_spte_in_rmap(rmap, iter, spte) \
for_each_spte_in_pte_list(rmap, iter, spte)
@@ -1128,11 +1130,8 @@ static bool __rmap_write_protect(struct kvm *kvm, unsigned long *rmapp,
struct pte_list_iterator iter;
bool flush = false;
- for_each_spte_in_rmap(*rmapp, iter, sptep) {
- BUG_ON(!(*sptep & PT_PRESENT_MASK));
-
+ for_each_spte_in_rmap(*rmapp, iter, sptep)
flush |= spte_write_protect(kvm, sptep, pt_protect);
- }
return flush;
}
@@ -1215,7 +1214,6 @@ static int kvm_set_pte_rmapp(struct kvm *kvm, unsigned long *rmapp,
need_flush = kvm_unmap_rmapp(kvm, rmapp, slot, data);
else
for_each_spte_in_rmap(*rmapp, iter, sptep) {
- BUG_ON(!is_shadow_present_pte(*sptep));
rmap_printk("kvm_set_pte_rmapp: spte %p %llx\n",
sptep, *sptep);
@@ -1336,15 +1334,12 @@ static int kvm_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
goto out;
}
- for_each_spte_in_rmap(*rmapp, iter, sptep) {
- BUG_ON(!is_shadow_present_pte(*sptep));
-
+ for_each_spte_in_rmap(*rmapp, iter, sptep)
if (*sptep & shadow_accessed_mask) {
young = 1;
clear_bit((ffs(shadow_accessed_mask) - 1),
(unsigned long *)sptep);
}
- }
out:
/* @data has hva passed to kvm_age_hva(). */
trace_kvm_age_page(data, slot, young);
@@ -1366,14 +1361,11 @@ static int kvm_test_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
if (!shadow_accessed_mask)
goto out;
- for_each_spte_in_rmap(*rmapp, iter, sptep) {
- BUG_ON(!is_shadow_present_pte(*sptep));
-
+ for_each_spte_in_rmap(*rmapp, iter, sptep)
if (*sptep & shadow_accessed_mask) {
young = 1;
break;
}
- }
out:
return young;
}
--
1.7.7.6
next prev parent reply other threads:[~2013-02-05 8:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-05 8:52 [PATCH v3 0/5] KVM: MMU: unify and cleanup the code of walking pte list Xiao Guangrong
2013-02-05 8:53 ` [PATCH v3 1/5] KVM: MMU: introduce mmu_spte_establish Xiao Guangrong
2013-02-08 21:35 ` Marcelo Tosatti
2013-02-05 8:53 ` [PATCH v3 2/5] KVM: MMU: clarify the logic in kvm_set_pte_rmapp Xiao Guangrong
2013-02-05 8:54 ` [PATCH v3 3/5] KVM: MMU: unify the code of walking pte list Xiao Guangrong
2013-02-05 8:54 ` Xiao Guangrong [this message]
2013-02-05 8:55 ` [PATCH v3 5/5] KVM: MMU: fast drop all spte on the pte_list Xiao Guangrong
2013-02-08 21:48 ` Marcelo Tosatti
2013-02-05 13:04 ` [PATCH v3 0/5] KVM: MMU: unify and cleanup the code of walking pte list Gleb Natapov
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=5110C8E3.1080009@linux.vnet.ibm.com \
--to=xiaoguangrong@linux.vnet.ibm.com \
--cc=gleb@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
/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;
as well as URLs for NNTP newsgroup(s).