aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@redhat.com>2008-12-21 12:20:09 -0500
committerAvi Kivity <avi@redhat.com>2009-03-24 05:02:51 -0400
commita770f6f28b1a9287189f3dc8333eb694d9a2f0ab (patch)
treeed88e3dc411630780acfae24fc917750df6561d2 /arch/x86/kvm
parent22ccb14203d59a8bcf6f3fea76b3594d710569fa (diff)
KVM: MMU: Inherit a shadow page's guest level count from vcpu setup
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>
Diffstat (limited to 'arch/x86/kvm')
-rw-r--r--arch/x86/kvm/mmu.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
index 2d4477c71473..f15023c11fea 100644
--- a/arch/x86/kvm/mmu.c
+++ b/arch/x86/kvm/mmu.c
@@ -1204,8 +1204,7 @@ static struct kvm_mmu_page *kvm_mmu_get_page(struct kvm_vcpu *vcpu,
1204 struct kvm_mmu_page *sp; 1204 struct kvm_mmu_page *sp;
1205 struct hlist_node *node, *tmp; 1205 struct hlist_node *node, *tmp;
1206 1206
1207 role.word = 0; 1207 role = vcpu->arch.mmu.base_role;
1208 role.glevels = vcpu->arch.mmu.root_level;
1209 role.level = level; 1208 role.level = level;
1210 role.metaphysical = metaphysical; 1209 role.metaphysical = metaphysical;
1211 role.access = access; 1210 role.access = access;
@@ -2251,17 +2250,23 @@ static int init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
2251 2250
2252static int init_kvm_softmmu(struct kvm_vcpu *vcpu) 2251static int init_kvm_softmmu(struct kvm_vcpu *vcpu)
2253{ 2252{
2253 int r;
2254
2254 ASSERT(vcpu); 2255 ASSERT(vcpu);
2255 ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa)); 2256 ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa));
2256 2257
2257 if (!is_paging(vcpu)) 2258 if (!is_paging(vcpu))
2258 return nonpaging_init_context(vcpu); 2259 r = nonpaging_init_context(vcpu);
2259 else if (is_long_mode(vcpu)) 2260 else if (is_long_mode(vcpu))
2260 return paging64_init_context(vcpu); 2261 r = paging64_init_context(vcpu);
2261 else if (is_pae(vcpu)) 2262 else if (is_pae(vcpu))
2262 return paging32E_init_context(vcpu); 2263 r = paging32E_init_context(vcpu);
2263 else 2264 else
2264 return paging32_init_context(vcpu); 2265 r = paging32_init_context(vcpu);
2266
2267 vcpu->arch.mmu.base_role.glevels = vcpu->arch.mmu.root_level;
2268
2269 return r;
2265} 2270}
2266 2271
2267static int init_kvm_mmu(struct kvm_vcpu *vcpu) 2272static int init_kvm_mmu(struct kvm_vcpu *vcpu)