[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <11219bdb-669c-cf6f-2a70-f4e5f909a2ad@redhat.com>
Date: Thu, 9 Dec 2021 23:46:03 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Sean Christopherson <seanjc@...gle.com>,
Lai Jiangshan <jiangshanlai@...il.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
Lai Jiangshan <laijs@...ux.alibaba.com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
x86@...nel.org, "H. Peter Anvin" <hpa@...or.com>,
Xiao Guangrong <guangrong.xiao@...ux.intel.com>
Subject: Re: [PATCH 17/15] KVM: X86: Ensure pae_root to be reconstructed for
shadow paging if the guest PDPTEs is changed
On 12/8/21 01:15, Sean Christopherson wrote:
>> @@ -832,8 +832,14 @@ int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3)
>> 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);
> Shouldn't matter since it's legacy shadow paging, but @mmu should be used instead
> of vcpu->arch.mmuvcpu->arch.mmu.
In kvm/next actually there's no mmu parameter to load_pdptrs, so it's
okay to keep vcpu->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.
Do you disagree that there's already an invariant that the PDPTRs can
only be dirty if KVM_REQ_LOAD_MMU_PGD---and therefore a previous change
to the PDPTRs would have triggered KVM_REQ_LOAD_MMU_PGD? This is
opposed to the guest TLB flush due to MOV CR3; that one has to be done
unconditionally for PAE paging, and it is handled separately within
kvm_set_cr3.
Paolo
Powered by blists - more mailing lists