KVM: MMU: fix dirty bit setting when removing write permissions
authorIzik Eidus <izike@qumranet.com>
Thu, 20 Mar 2008 16:17:24 +0000 (18:17 +0200)
committerAvi Kivity <avi@qumranet.com>
Sun, 27 Apr 2008 09:00:34 +0000 (12:00 +0300)
When mmu_set_spte() checks if a page related to spte should be release as
dirty or clean, it check if the shadow pte was writeble, but in case
rmap_write_protect() is called called it is possible for shadow ptes that were
writeble to become readonly and therefor mmu_set_spte will release the pages
as clean.

This patch fix this issue by marking the page as dirty inside
rmap_write_protect().

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

index a5872b3c466db333a2e439b47ee178a9bbee1d4c..dd4b95b3896b8f5cf8f3548958919bf5d1d0520a 100644 (file)
@@ -626,6 +626,14 @@ static void rmap_write_protect(struct kvm *kvm, u64 gfn)
                }
                spte = rmap_next(kvm, rmapp, spte);
        }
+       if (write_protected) {
+               struct page *page;
+
+               spte = rmap_next(kvm, rmapp, NULL);
+               page = pfn_to_page((*spte & PT64_BASE_ADDR_MASK) >> PAGE_SHIFT);
+               SetPageDirty(page);
+       }
+
        /* check for huge page mappings */
        rmapp = gfn_to_rmap(kvm, gfn, 1);
        spte = rmap_next(kvm, rmapp, NULL);