From: guangrong.xiao@gmail.com
To: pbonzini@redhat.com, mtosatti@redhat.com, avi.kivity@gmail.com,
rkrcmar@redhat.com
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
qemu-devel@nongnu.org, Xiao Guangrong <xiaoguangrong@tencent.com>
Subject: [Qemu-devel] [PATCH 1/7] KVM: MMU: correct the behavior of mmu_spte_update_no_track
Date: Wed, 3 May 2017 18:52:18 +0800 [thread overview]
Message-ID: <20170503105224.19049-2-xiaoguangrong@tencent.com> (raw)
In-Reply-To: <20170503105224.19049-1-xiaoguangrong@tencent.com>
From: Xiao Guangrong <xiaoguangrong@tencent.com>
Current behavior of mmu_spte_update_no_track() does not match
the name of _no_track() as actually the A/D bits are tracked
and returned to the caller
This patch introduces the real _no_track() function to update
the spte regardless of A/D bits and rename the original function
to _track()
The _no_track() function will be used by later patches to update
upper spte which need not care of A/D bits indeed
Signed-off-by: Xiao Guangrong <xiaoguangrong@tencent.com>
---
arch/x86/kvm/mmu.c | 25 ++++++++++++++++++++++---
1 file changed, 22 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 5586765..ba8e7af 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -583,10 +583,29 @@ static void mmu_spte_set(u64 *sptep, u64 new_spte)
}
/*
- * Update the SPTE (excluding the PFN), but do not track changes in its
+ * Update the SPTE (excluding the PFN) regardless of accessed/dirty
+ * status which is used to update the upper level spte.
+ */
+static void mmu_spte_update_no_track(u64 *sptep, u64 new_spte)
+{
+ u64 old_spte = *sptep;
+
+ WARN_ON(!is_shadow_present_pte(new_spte));
+
+ if (!is_shadow_present_pte(old_spte)) {
+ mmu_spte_set(sptep, new_spte);
+ return;
+ }
+
+ __update_clear_spte_fast(sptep, new_spte);
+}
+
+/*
+ * Update the SPTE (excluding the PFN), the original value is
+ * returned, based on it, the caller can track changes of its
* accessed/dirty status.
*/
-static u64 mmu_spte_update_no_track(u64 *sptep, u64 new_spte)
+static u64 mmu_spte_update_track(u64 *sptep, u64 new_spte)
{
u64 old_spte = *sptep;
@@ -621,7 +640,7 @@ static u64 mmu_spte_update_no_track(u64 *sptep, u64 new_spte)
static bool mmu_spte_update(u64 *sptep, u64 new_spte)
{
bool flush = false;
- u64 old_spte = mmu_spte_update_no_track(sptep, new_spte);
+ u64 old_spte = mmu_spte_update_track(sptep, new_spte);
if (!is_shadow_present_pte(old_spte))
return false;
--
2.9.3
next prev parent reply other threads:[~2017-05-03 10:53 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-03 10:52 [Qemu-devel] [PATCH 0/7] KVM: MMU: fast write protect guangrong.xiao
2017-05-03 10:52 ` guangrong.xiao [this message]
2017-05-03 10:52 ` [Qemu-devel] [PATCH 2/7] KVM: MMU: introduce possible_writable_spte_bitmap guangrong.xiao
2017-05-03 10:52 ` [Qemu-devel] [PATCH 3/7] KVM: MMU: introduce kvm_mmu_write_protect_all_pages guangrong.xiao
2017-05-03 10:52 ` [Qemu-devel] [PATCH 4/7] KVM: MMU: enable KVM_WRITE_PROTECT_ALL_MEM guangrong.xiao
2017-05-03 10:52 ` [Qemu-devel] [PATCH 5/7] KVM: MMU: allow dirty log without write protect guangrong.xiao
2017-05-03 10:52 ` [Qemu-devel] [PATCH 6/7] KVM: MMU: clarify fast_pf_fix_direct_spte guangrong.xiao
2017-05-03 10:52 ` [Qemu-devel] [PATCH 7/7] KVM: MMU: stop using mmu_spte_get_lockless under mmu-lock guangrong.xiao
2017-05-03 12:28 ` [Qemu-devel] [PATCH 0/7] KVM: MMU: fast write protect Paolo Bonzini
2017-05-03 14:50 ` Xiao Guangrong
2017-05-03 14:57 ` Paolo Bonzini
2017-05-04 3:36 ` Xiao Guangrong
2017-05-04 7:06 ` Paolo Bonzini
2017-05-23 2:23 ` Xiao Guangrong
2017-05-29 16:48 ` Paolo Bonzini
2017-06-09 3:19 ` Xiao Guangrong
2017-06-05 7:36 ` Jay Zhou
2017-06-06 2:56 ` Xiao Guangrong
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=20170503105224.19049-2-xiaoguangrong@tencent.com \
--to=guangrong.xiao@gmail.com \
--cc=avi.kivity@gmail.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rkrcmar@redhat.com \
--cc=xiaoguangrong@tencent.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).