@@ -832,8 +832,14 @@ int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3)Shouldn't matter since it's legacy shadow paging, but @mmu should be used instead
if (memcmp(mmu->pdptrs, pdpte, sizeof(mmu->pdptrs))) {
memcpy(mmu->pdptrs, pdpte, sizeof(mmu->pdptrs));
kvm_register_mark_dirty(vcpu, VCPU_EXREG_PDPTR);
- /* Ensure the dirty PDPTEs to be loaded. */
- kvm_make_request(KVM_REQ_LOAD_MMU_PGD, vcpu);
+ /*
+ * Ensure the dirty PDPTEs to be loaded for VMX with EPT
+ * enabled or pae_root to be reconstructed for shadow paging.
+ */
+ if (tdp_enabled)
+ kvm_make_request(KVM_REQ_LOAD_MMU_PGD, vcpu);
+ else
+ kvm_mmu_free_roots(vcpu, vcpu->arch.mmu, KVM_MMU_ROOT_CURRENT);
of vcpu->arch.mmuvcpu->arch.mmu.
To avoid a dependency on the previous patch, I think it makes sense to have this be:
if (!tdp_enabled && memcmp(mmu->pdptrs, pdpte, sizeof(mmu->pdptrs)))
kvm_mmu_free_roots(vcpu, mmu, KVM_MMU_ROOT_CURRENT);
before the memcpy().
Then we can decide independently if skipping the KVM_REQ_LOAD_MMU_PGD if the
PDPTRs are unchanged with respect to the MMU is safe.