]> git.karo-electronics.de Git - linux-beck.git/commitdiff
KVM: MMU: don't mark pte notrap if it's just sync transient
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Fri, 11 Jun 2010 13:31:38 +0000 (21:31 +0800)
committerAvi Kivity <avi@redhat.com>
Sun, 1 Aug 2010 07:46:42 +0000 (10:46 +0300)
If the sync-sp just sync transient, don't mark its pte notrap

Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu.c
arch/x86/kvm/paging_tmpl.h

index c2813d658f3e865f77d02b04d0da1ce2008f6a2d..2ec2e27a403e9b2b9d04f422d9b73d8333901796 100644 (file)
@@ -241,7 +241,7 @@ struct kvm_mmu {
        void (*prefetch_page)(struct kvm_vcpu *vcpu,
                              struct kvm_mmu_page *page);
        int (*sync_page)(struct kvm_vcpu *vcpu,
-                        struct kvm_mmu_page *sp);
+                        struct kvm_mmu_page *sp, bool clear_unsync);
        void (*invlpg)(struct kvm_vcpu *vcpu, gva_t gva);
        hpa_t root_hpa;
        int root_level;
index ff333572be75e920f54b57d6694b5db47ac36b04..d1e09f3c5614e057bafb7e0451c4f331b2b143b4 100644 (file)
@@ -1103,7 +1103,7 @@ static void nonpaging_prefetch_page(struct kvm_vcpu *vcpu,
 }
 
 static int nonpaging_sync_page(struct kvm_vcpu *vcpu,
-                              struct kvm_mmu_page *sp)
+                              struct kvm_mmu_page *sp, bool clear_unsync)
 {
        return 1;
 }
@@ -1228,7 +1228,7 @@ static int __kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
        if (clear_unsync)
                kvm_unlink_unsync_page(vcpu->kvm, sp);
 
-       if (vcpu->arch.mmu.sync_page(vcpu, sp)) {
+       if (vcpu->arch.mmu.sync_page(vcpu, sp, clear_unsync)) {
                kvm_mmu_prepare_zap_page(vcpu->kvm, sp, invalid_list);
                return 1;
        }
@@ -1237,7 +1237,6 @@ static int __kvm_sync_page(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
        return 0;
 }
 
-static void mmu_convert_notrap(struct kvm_mmu_page *sp);
 static int kvm_sync_page_transient(struct kvm_vcpu *vcpu,
                                   struct kvm_mmu_page *sp)
 {
@@ -1245,9 +1244,7 @@ static int kvm_sync_page_transient(struct kvm_vcpu *vcpu,
        int ret;
 
        ret = __kvm_sync_page(vcpu, sp, &invalid_list, false);
-       if (!ret)
-               mmu_convert_notrap(sp);
-       else
+       if (ret)
                kvm_mmu_commit_zap_page(vcpu->kvm, &invalid_list);
 
        return ret;
@@ -1273,7 +1270,7 @@ static void kvm_sync_pages(struct kvm_vcpu *vcpu,  gfn_t gfn)
 
                WARN_ON(s->role.level != PT_PAGE_TABLE_LEVEL);
                if ((s->role.cr4_pae != !!is_pae(vcpu)) ||
-                       (vcpu->arch.mmu.sync_page(vcpu, s))) {
+                       (vcpu->arch.mmu.sync_page(vcpu, s, true))) {
                        kvm_mmu_prepare_zap_page(vcpu->kvm, s, &invalid_list);
                        continue;
                }
index efba353369e787376a53c7ae1cd6be48738695b9..863920f649fbeb4ed2f15b5c8ddcf707e04a6c63 100644 (file)
@@ -578,7 +578,8 @@ static void FNAME(prefetch_page)(struct kvm_vcpu *vcpu,
  *   can't change unless all sptes pointing to it are nuked first.
  * - Alias changes zap the entire shadow cache.
  */
-static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
+static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp,
+                           bool clear_unsync)
 {
        int i, offset, nr_present;
        bool reset_host_protection;
@@ -615,7 +616,7 @@ static int FNAME(sync_page)(struct kvm_vcpu *vcpu, struct kvm_mmu_page *sp)
                        u64 nonpresent;
 
                        rmap_remove(vcpu->kvm, &sp->spt[i]);
-                       if (is_present_gpte(gpte))
+                       if (is_present_gpte(gpte) || !clear_unsync)
                                nonpresent = shadow_trap_nonpresent_pte;
                        else
                                nonpresent = shadow_notrap_nonpresent_pte;