lkml.org 
[lkml]   [2020]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 07/28] KVM: nVMX: always update CR3 in VMCS
    Date
    vmx_load_mmu_pgd is delaying the write of GUEST_CR3 to prepare_vmcs02 as
    an optimization, but this is only correct before the nested vmentry.
    If userspace is modifying CR3 with KVM_SET_SREGS after the VM has
    already been put in guest mode, the value of CR3 will not be updated.
    Remove the optimization, which almost never triggers anyway.

    Fixes: 04f11ef45810 ("KVM: nVMX: Always write vmcs02.GUEST_CR3 during nested VM-Enter")
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    ---
    arch/x86/kvm/vmx/vmx.c | 5 +----
    1 file changed, 1 insertion(+), 4 deletions(-)

    diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c
    index aedc46407b1f..7efdc3c2f7f2 100644
    --- a/arch/x86/kvm/vmx/vmx.c
    +++ b/arch/x86/kvm/vmx/vmx.c
    @@ -3085,10 +3085,7 @@ void vmx_load_mmu_pgd(struct kvm_vcpu *vcpu, unsigned long pgd)
    spin_unlock(&to_kvm_vmx(kvm)->ept_pointer_lock);
    }

    - /* Loading vmcs02.GUEST_CR3 is handled by nested VM-Enter. */
    - if (is_guest_mode(vcpu))
    - update_guest_cr3 = false;
    - else if (!enable_unrestricted_guest && !is_paging(vcpu))
    + if (!enable_unrestricted_guest && !is_paging(vcpu))
    guest_cr3 = to_kvm_vmx(kvm)->ept_identity_map_addr;
    else if (test_bit(VCPU_EXREG_CR3, (ulong *)&vcpu->arch.regs_avail))
    guest_cr3 = vcpu->arch.cr3;
    --
    2.26.2

    \
     
     \ /
      Last update: 2020-05-26 19:26    [W:3.673 / U:0.016 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site