aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm/mmu.c
diff options
context:
space:
mode:
authorIzik Eidus <izike@qumranet.com>2008-01-12 16:49:09 -0500
committerAvi Kivity <avi@qumranet.com>2008-01-30 11:01:22 -0500
commit75e68e607896c84310dee37c783c45220e56ce8c (patch)
treed211007d0d2923d5f831f0d9d90f48f3298e559d /arch/x86/kvm/mmu.c
parent6f723c7911e7827091586ae63f4040874eeb75e5 (diff)
KVM: MMU: Fix dirty page setting for pages removed from rmap
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>
Diffstat (limited to 'arch/x86/kvm/mmu.c')
-rw-r--r--arch/x86/kvm/mmu.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index c478ee25de66..8efdcdbebb03 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -890,6 +890,7 @@ static void mmu_set_spte(struct kvm_vcpu *vcpu, u64 *shadow_pte,
890{ 890{
891 u64 spte; 891 u64 spte;
892 int was_rmapped = is_rmap_pte(*shadow_pte); 892 int was_rmapped = is_rmap_pte(*shadow_pte);
893 int was_writeble = is_writeble_pte(*shadow_pte);
893 894
894 pgprintk("%s: spte %llx access %x write_fault %d" 895 pgprintk("%s: spte %llx access %x write_fault %d"
895 " user_fault %d gfn %lx\n", 896 " user_fault %d gfn %lx\n",
@@ -956,9 +957,12 @@ unshadowed:
956 rmap_add(vcpu, shadow_pte, gfn); 957 rmap_add(vcpu, shadow_pte, gfn);
957 if (!is_rmap_pte(*shadow_pte)) 958 if (!is_rmap_pte(*shadow_pte))
958 kvm_release_page_clean(page); 959 kvm_release_page_clean(page);
960 } else {
961 if (was_writeble)
962 kvm_release_page_dirty(page);
963 else
964 kvm_release_page_clean(page);
959 } 965 }
960 else
961 kvm_release_page_clean(page);
962 if (!ptwrite || !*ptwrite) 966 if (!ptwrite || !*ptwrite)
963 vcpu->arch.last_pte_updated = shadow_pte; 967 vcpu->arch.last_pte_updated = shadow_pte;
964} 968}