KVM: X86: Skip allocating pae_root for vcpu->arch.guest_mmu when !tdp_enabled
authorLai Jiangshan <laijs@linux.alibaba.com>
Thu, 18 Nov 2021 11:08:09 +0000 (19:08 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Dec 2021 09:25:08 +0000 (04:25 -0500)
It is never used.

Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
Message-Id: <20211118110814.2568-11-jiangshanlai@gmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/mmu/mmu.c

index ede6391..644a5cb 100644 (file)
@@ -5514,6 +5514,10 @@ static int __kvm_mmu_create(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu)
        for (i = 0; i < KVM_MMU_NUM_PREV_ROOTS; i++)
                mmu->prev_roots[i] = KVM_MMU_ROOT_INFO_INVALID;
 
+       /* vcpu->arch.guest_mmu isn't used when !tdp_enabled. */
+       if (!tdp_enabled && mmu == &vcpu->arch.guest_mmu)
+               return 0;
+
        /*
         * When using PAE paging, the four PDPTEs are treated as 'root' pages,
         * while the PDP table is a per-vCPU construct that's allocated at MMU