]> git.karo-electronics.de Git - linux-beck.git/commitdiff
KVM: MMU: Add link_shadow_page() helper
authorAvi Kivity <avi@redhat.com>
Tue, 13 Jul 2010 11:27:04 +0000 (14:27 +0300)
committerAvi Kivity <avi@redhat.com>
Mon, 2 Aug 2010 03:40:40 +0000 (06:40 +0300)
To simplify the process of fetching an spte, add a helper that links
a shadow page to an spte.

Reviewed-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/mmu.c
arch/x86/kvm/paging_tmpl.h

index 89d7a2cae53bf0da45b887e33d6423cd4c1a6eb0..df3a7a79cce37af1d9507f858cc0062c1a01e0da 100644 (file)
@@ -1482,6 +1482,16 @@ static void shadow_walk_next(struct kvm_shadow_walk_iterator *iterator)
        --iterator->level;
 }
 
+static void link_shadow_page(u64 *sptep, struct kvm_mmu_page *sp)
+{
+       u64 spte;
+
+       spte = __pa(sp->spt)
+               | PT_PRESENT_MASK | PT_ACCESSED_MASK
+               | PT_WRITABLE_MASK | PT_USER_MASK;
+       *sptep = spte;
+}
+
 static void kvm_mmu_page_unlink_children(struct kvm *kvm,
                                         struct kvm_mmu_page *sp)
 {
index 1cea41cad06949991a7e86f7272d4bd196acd232..36dc0749c878c0d13c48bc10c0f89e5b9ee42fbe 100644 (file)
@@ -309,7 +309,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
 {
        unsigned access = gw->pt_access;
        struct kvm_mmu_page *sp;
-       u64 spte, *sptep = NULL;
+       u64 *sptep = NULL;
        int direct;
        gfn_t table_gfn;
        int r;
@@ -395,10 +395,7 @@ static u64 *FNAME(fetch)(struct kvm_vcpu *vcpu, gva_t addr,
                        }
                }
 
-               spte = __pa(sp->spt)
-                       | PT_PRESENT_MASK | PT_ACCESSED_MASK
-                       | PT_WRITABLE_MASK | PT_USER_MASK;
-               *sptep = spte;
+               link_shadow_page(sptep, sp);
        }
 
        return sptep;