]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
KVM: MMU: Fix dirty page setting for pages removed from rmap
authorIzik Eidus <izike@qumranet.com>
Sat, 12 Jan 2008 21:49:09 +0000 (23:49 +0200)
committerAvi Kivity <avi@qumranet.com>
Wed, 30 Jan 2008 16:01:22 +0000 (18:01 +0200)
Right now rmap_remove won't set the page as dirty if the shadow pte
pointed to this page had write access and then it became readonly.
This patches fixes that, by setting the page as dirty for spte changes from
write to readonly access.

Signed-off-by: Izik Eidus <izike@qumranet.com>
Signed-off-by: Avi Kivity <avi@qumranet.com>
arch/x86/kvm/mmu.c

index c478ee25de6606ddee52e11c88dd612cfc47b484..8efdcdbebb0356483816de769856fd57c20944ea 100644 (file)
@@ -890,6 +890,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
 {
        u64 spte;
        int was_rmapped = is_rmap_pte(*shadow_pte);
+       int was_writeble = is_writeble_pte(*shadow_pte);
 
        pgprintk("%s: spte %llx access %x write_fault %d"
                 " user_fault %d gfn %lx\n",
@@ -956,9 +957,12 @@ unshadowed:
                rmap_add(vcpu, shadow_pte, gfn);
                if (!is_rmap_pte(*shadow_pte))
                        kvm_release_page_clean(page);
+       } else {
+               if (was_writeble)
+                       kvm_release_page_dirty(page);
+               else
+                       kvm_release_page_clean(page);
        }
-       else
-               kvm_release_page_clean(page);
        if (!ptwrite || !*ptwrite)
                vcpu->arch.last_pte_updated = shadow_pte;
 }