From: Avi Kivity <avi@redhat.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: kvm@vger.kernel.org
Subject: [PATCH v2 2/4] KVM: MMU: Move accessed/dirty bit checks from rmap_remove() to drop_spte()
Date: Mon, 7 Jun 2010 10:10:57 +0300 [thread overview]
Message-ID: <1275894659-17656-3-git-send-email-avi@redhat.com> (raw)
In-Reply-To: <1275894659-17656-1-git-send-email-avi@redhat.com>
Since we need to make the check atomic, move it to the place that will
set the new spte.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
arch/x86/kvm/mmu.c | 17 +++++++++--------
1 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 16cedc9..b5a2d3d 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -620,19 +620,11 @@ static void rmap_remove(struct kvm *kvm, u64 *spte)
struct kvm_rmap_desc *desc;
struct kvm_rmap_desc *prev_desc;
struct kvm_mmu_page *sp;
- pfn_t pfn;
gfn_t gfn;
unsigned long *rmapp;
int i;
- if (!is_rmap_spte(*spte))
- return;
sp = page_header(__pa(spte));
- pfn = spte_to_pfn(*spte);
- if (*spte & shadow_accessed_mask)
- kvm_set_pfn_accessed(pfn);
- if (is_writable_pte(*spte))
- kvm_set_pfn_dirty(pfn);
gfn = kvm_mmu_page_get_gfn(sp, spte - sp->spt);
rmapp = gfn_to_rmap(kvm, gfn, sp->role.level);
if (!*rmapp) {
@@ -668,6 +660,15 @@ static void rmap_remove(struct kvm *kvm, u64 *spte)
static void drop_spte(struct kvm *kvm, u64 *sptep, u64 new_spte)
{
+ pfn_t pfn;
+
+ if (!is_rmap_spte(*sptep))
+ return;
+ pfn = spte_to_pfn(*sptep);
+ if (*sptep & shadow_accessed_mask)
+ kvm_set_pfn_accessed(pfn);
+ if (is_writable_pte(*sptep))
+ kvm_set_pfn_dirty(pfn);
rmap_remove(kvm, sptep);
__set_spte(sptep, new_spte);
}
--
1.7.1
next prev parent reply other threads:[~2010-06-07 7:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-07 7:10 [PATCH v2 0/4] Fix accessed bit tracking Avi Kivity
2010-06-07 7:10 ` [PATCH v2 1/4] KVM: MMU: Introduce drop_spte() Avi Kivity
2010-06-07 7:10 ` Avi Kivity [this message]
2010-06-07 8:16 ` [PATCH v2 2/4] KVM: MMU: Move accessed/dirty bit checks from rmap_remove() to drop_spte() Lai Jiangshan
2010-06-07 9:01 ` Avi Kivity
2010-06-07 7:10 ` [PATCH v2 3/4] KVM: MMU: Atomically check for accessed bit when dropping an spte Avi Kivity
2010-06-08 2:07 ` Xiao Guangrong
2010-06-08 5:51 ` Avi Kivity
2010-06-07 7:10 ` [PATCH v2 4/4] KVM: MMU: Don't drop accessed bit while updating " Avi Kivity
2010-06-07 8:43 ` [PATCH v2 0/4] Fix accessed bit tracking Lai Jiangshan
2010-06-07 9:00 ` Avi Kivity
2010-06-08 2:35 ` Xiao Guangrong
2010-06-08 5:24 ` Avi Kivity
2010-06-08 6:53 ` Xiao Guangrong
2010-06-08 7:54 ` Avi Kivity
2010-06-08 8:30 ` 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=1275894659-17656-3-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=kvm@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