lkml.org 
[lkml]   [2022]   [Jan]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.16 0791/1039] KVM: X86: Ensure that dirty PDPTRs are loaded
    Date
    From: Lai Jiangshan <laijs@linux.alibaba.com>

    [ Upstream commit 2c5653caecc4807b8abfe9c41880ac38417be7bf ]

    For VMX with EPT, dirty PDPTRs need to be loaded before the next vmentry
    via vmx_load_mmu_pgd()

    But not all paths that call load_pdptrs() will cause vmx_load_mmu_pgd()
    to be invoked. Normally, kvm_mmu_reset_context() is used to cause
    KVM_REQ_LOAD_MMU_PGD, but sometimes it is skipped:

    * commit d81135a57aa6("KVM: x86: do not reset mmu if CR0.CD and
    CR0.NW are changed") skips kvm_mmu_reset_context() after load_pdptrs()
    when changing CR0.CD and CR0.NW.

    * commit 21823fbda552("KVM: x86: Invalidate all PGDs for the current
    PCID on MOV CR3 w/ flush") skips KVM_REQ_LOAD_MMU_PGD after
    load_pdptrs() when rewriting the CR3 with the same value.

    * commit a91a7c709600("KVM: X86: Don't reset mmu context when
    toggling X86_CR4_PGE") skips kvm_mmu_reset_context() after
    load_pdptrs() when changing CR4.PGE.

    Fixes: d81135a57aa6 ("KVM: x86: do not reset mmu if CR0.CD and CR0.NW are changed")
    Fixes: 21823fbda552 ("KVM: x86: Invalidate all PGDs for the current PCID on MOV CR3 w/ flush")
    Fixes: a91a7c709600 ("KVM: X86: Don't reset mmu context when toggling X86_CR4_PGE")
    Signed-off-by: Lai Jiangshan <laijs@linux.alibaba.com>
    Message-Id: <20211108124407.12187-2-jiangshanlai@gmail.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    arch/x86/kvm/x86.c | 1 +
    1 file changed, 1 insertion(+)

    diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
    index 0b5c61bb24a17..bb87f43cdc78c 100644
    --- a/arch/x86/kvm/x86.c
    +++ b/arch/x86/kvm/x86.c
    @@ -830,6 +830,7 @@ int load_pdptrs(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, unsigned long cr3)

    memcpy(mmu->pdptrs, pdpte, sizeof(mmu->pdptrs));
    kvm_register_mark_dirty(vcpu, VCPU_EXREG_PDPTR);
    + kvm_make_request(KVM_REQ_LOAD_MMU_PGD, vcpu);
    vcpu->arch.pdptrs_from_userspace = false;

    return 1;
    --
    2.34.1


    \
     
     \ /
      Last update: 2022-01-25 00:11    [W:2.409 / U:1.860 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site