Skip to content

Commit

Permalink
KVM: MMU: Move accessed/dirty bit checks from rmap_remove() to drop_s…
Browse files Browse the repository at this point in the history
…pte()

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>
  • Loading branch information
Avi Kivity committed Aug 2, 2010
1 parent be38d27 commit ce06186
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions arch/x86/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,19 +612,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) {
Expand Down Expand Up @@ -660,6 +652,17 @@ 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)) {
__set_spte(sptep, new_spte);
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);
}
Expand Down

0 comments on commit ce06186

Please sign in to comment.