]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
KVM: MMU: Inherit a shadow page's guest level count from vcpu setup
authorAvi Kivity <avi@redhat.com>
Sun, 21 Dec 2008 17:20:09 +0000 (19:20 +0200)
committerAvi Kivity <avi@redhat.com>
Sun, 21 Dec 2008 17:20:09 +0000 (19:20 +0200)
Instead of "calculating" it on every shadow page allocation, set it once
when switching modes, and copy it when allocating pages.

This doesn't buy us much, but sets up the stage for inheriting more
information related to the mmu setup.

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/mmu.c

index da65439588a81b2feac1844e4dc4f0fa150ff336..f49bfd04b91d6cfab96c8cc97778feb88235d000 100644 (file)
@@ -244,6 +244,7 @@ struct kvm_mmu {
        hpa_t root_hpa;
        int root_level;
        int shadow_root_level;
+       union kvm_mmu_page_role base_role;
 
        u64 *pae_root;
 };
index d50ebac6a07faf174b7680365b859994c5996dff..03dc21f7fda1c96c03527bec75073353890cc866 100644 (file)
@@ -1204,8 +1204,7 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
        struct kvm_mmu_page *sp;
        struct hlist_node *node, *tmp;
 
-       role.word = 0;
-       role.glevels = vcpu->arch.mmu.root_level;
+       role = vcpu->arch.mmu.base_role;
        role.level = level;
        role.metaphysical = metaphysical;
        role.access = access;
@@ -2246,17 +2245,23 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
 
 static int init_kvm_softmmu(struct kvm_vcpu *vcpu)
 {
+       int r;
+
        ASSERT(vcpu);
        ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa));
 
        if (!is_paging(vcpu))
-               return nonpaging_init_context(vcpu);
+               r = nonpaging_init_context(vcpu);
        else if (is_long_mode(vcpu))
-               return paging64_init_context(vcpu);
+               r = paging64_init_context(vcpu);
        else if (is_pae(vcpu))
-               return paging32E_init_context(vcpu);
+               r = paging32E_init_context(vcpu);
        else
-               return paging32_init_context(vcpu);
+               r = paging32_init_context(vcpu);
+
+       vcpu->arch.mmu.base_role.glevels = vcpu->arch.mmu.root_level;
+
+       return r;
 }
 
 static int init_kvm_mmu(struct kvm_vcpu *vcpu)