KVM: MMU: Disable write access on clean large pages
authorAvi Kivity <avi@qumranet.com>
Thu, 11 Oct 2007 13:12:24 +0000 (15:12 +0200)
committerAvi Kivity <avi@qumranet.com>
Wed, 30 Jan 2008 15:52:52 +0000 (17:52 +0200)
By forcing clean huge pages to be read-only, we have separate roles
for the shadow of a clean large page and the shadow of a dirty large
page.  This is necessary because different ptes will be instantiated
for the two cases, even for read faults.

Signed-off-by: Avi Kivity <avi@qumranet.com>
drivers/kvm/paging_tmpl.h

index e07cb2e006c2b8cfd339e118bfff0ae194160d25..4538b1533d5ba9569ce65d6aef231a3d348f32bb 100644 (file)
@@ -382,6 +382,8 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
                        metaphysical = 1;
                        hugepage_access = walker->pte;
                        hugepage_access &= PT_USER_MASK | PT_WRITABLE_MASK;
+                       if (!is_dirty_pte(walker->pte))
+                               hugepage_access &= ~PT_WRITABLE_MASK;
                        hugepage_access >>= PT_WRITABLE_SHIFT;
                        if (walker->pte & PT64_NX_MASK)
                                hugepage_access |= (1 << 2);