KVM: x86: mmu: remove argument to kvm_init_shadow_mmu and kvm_init_shadow_ept_mmu
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 2 Oct 2013 14:56:14 +0000 (16:56 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 8 Jan 2015 21:48:02 +0000 (22:48 +0100)
The initialization function in mmu.c can always use walk_mmu, which
is known to be vcpu->arch.mmu.  Only init_kvm_nested_mmu is used to
initialize vcpu->arch.nested_mmu.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu.c
arch/x86/kvm/mmu.h
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c

index 8ddbcb570fce3e1dc98fa8e8c81615e0c5fc4859..d6d3d6f0ff1b8d001c0a1f31b5e2c3a248caeac7 100644 (file)
@@ -3763,7 +3763,7 @@ static void paging32E_init_context(struct kvm_vcpu *vcpu,
 
 static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
 {
-       struct kvm_mmu *context = vcpu->arch.walk_mmu;
+       struct kvm_mmu *context = &vcpu->arch.mmu;
 
        context->base_role.word = 0;
        context->page_fault = tdp_page_fault;
@@ -3803,11 +3803,13 @@ static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu)
        update_last_pte_bitmap(vcpu, context);
 }
 
-void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context)
+void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu)
 {
        bool smep = kvm_read_cr4_bits(vcpu, X86_CR4_SMEP);
+       struct kvm_mmu *context = &vcpu->arch.mmu;
+
        ASSERT(vcpu);
-       ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa));
+       ASSERT(!VALID_PAGE(context->root_hpa));
 
        if (!is_paging(vcpu))
                nonpaging_init_context(vcpu, context);
@@ -3818,19 +3820,20 @@ void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context)
        else
                paging32_init_context(vcpu, context);
 
-       vcpu->arch.mmu.base_role.nxe = is_nx(vcpu);
-       vcpu->arch.mmu.base_role.cr4_pae = !!is_pae(vcpu);
-       vcpu->arch.mmu.base_role.cr0_wp  = is_write_protection(vcpu);
-       vcpu->arch.mmu.base_role.smep_andnot_wp
+       context->base_role.nxe = is_nx(vcpu);
+       context->base_role.cr4_pae = !!is_pae(vcpu);
+       context->base_role.cr0_wp  = is_write_protection(vcpu);
+       context->base_role.smep_andnot_wp
                = smep && !is_write_protection(vcpu);
 }
 EXPORT_SYMBOL_GPL(kvm_init_shadow_mmu);
 
-void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context,
-               bool execonly)
+void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, bool execonly)
 {
+       struct kvm_mmu *context = &vcpu->arch.mmu;
+
        ASSERT(vcpu);
-       ASSERT(!VALID_PAGE(vcpu->arch.mmu.root_hpa));
+       ASSERT(!VALID_PAGE(context->root_hpa));
 
        context->shadow_root_level = kvm_x86_ops->get_tdp_level();
 
@@ -3851,11 +3854,13 @@ EXPORT_SYMBOL_GPL(kvm_init_shadow_ept_mmu);
 
 static void init_kvm_softmmu(struct kvm_vcpu *vcpu)
 {
-       kvm_init_shadow_mmu(vcpu, vcpu->arch.walk_mmu);
-       vcpu->arch.walk_mmu->set_cr3           = kvm_x86_ops->set_cr3;
-       vcpu->arch.walk_mmu->get_cr3           = get_cr3;
-       vcpu->arch.walk_mmu->get_pdptr         = kvm_pdptr_read;
-       vcpu->arch.walk_mmu->inject_page_fault = kvm_inject_page_fault;
+       struct kvm_mmu *context = &vcpu->arch.mmu;
+
+       kvm_init_shadow_mmu(vcpu);
+       context->set_cr3           = kvm_x86_ops->set_cr3;
+       context->get_cr3           = get_cr3;
+       context->get_pdptr         = kvm_pdptr_read;
+       context->inject_page_fault = kvm_inject_page_fault;
 }
 
 static void init_kvm_nested_mmu(struct kvm_vcpu *vcpu)
index bde8ee7257546ec74400162387fbd5073c6aa7ca..a7f9a121690ddfb85259fe2b85065bfe7e50332d 100644 (file)
@@ -81,9 +81,8 @@ enum {
 };
 
 int handle_mmio_page_fault_common(struct kvm_vcpu *vcpu, u64 addr, bool direct);
-void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context);
-void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, struct kvm_mmu *context,
-               bool execonly);
+void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu);
+void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, bool execonly);
 void update_permission_bitmask(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu,
                bool ept);
 
index 41dd0387cccb639b49fcb99c99035d3691f2464a..a17d848c6d42d0d9ba292b06ec9df7dd857fe790 100644 (file)
@@ -2003,8 +2003,8 @@ static void nested_svm_inject_npf_exit(struct kvm_vcpu *vcpu,
 
 static void nested_svm_init_mmu_context(struct kvm_vcpu *vcpu)
 {
-       kvm_init_shadow_mmu(vcpu, &vcpu->arch.mmu);
-
+       WARN_ON(mmu_is_nested(vcpu));
+       kvm_init_shadow_mmu(vcpu);
        vcpu->arch.mmu.set_cr3           = nested_svm_set_tdp_cr3;
        vcpu->arch.mmu.get_cr3           = nested_svm_get_tdp_cr3;
        vcpu->arch.mmu.get_pdptr         = nested_svm_get_tdp_pdptr;
index 3b97f8b3065ee564e0f7ae28ec4fd65d413a203f..ce350718eb8857c41b59cc84897ea60c5a7f5220 100644 (file)
@@ -8202,9 +8202,9 @@ static unsigned long nested_ept_get_cr3(struct kvm_vcpu *vcpu)
 
 static void nested_ept_init_mmu_context(struct kvm_vcpu *vcpu)
 {
-       kvm_init_shadow_ept_mmu(vcpu, &vcpu->arch.mmu,
+       WARN_ON(mmu_is_nested(vcpu));
+       kvm_init_shadow_ept_mmu(vcpu,
                        nested_vmx_ept_caps & VMX_EPT_EXECUTE_ONLY_BIT);
-
        vcpu->arch.mmu.set_cr3           = vmx_set_cr3;
        vcpu->arch.mmu.get_cr3           = nested_ept_get_cr3;
        vcpu->arch.mmu.inject_page_fault = nested_ept_inject_page_fault;