• Ladi Prosek's avatar
    KVM: nVMX: fix HOST_CR3/HOST_CR4 cache · 44889942
    Ladi Prosek authored
    For nested virt we maintain multiple VMCS that can run on a vCPU. So it is
    incorrect to keep vmcs_host_cr3 and vmcs_host_cr4, whose purpose is caching
    the value of the rarely changing HOST_CR3 and HOST_CR4 VMCS fields, in
    vCPU-wide data structures.
    
    Hyper-V nested on KVM runs into this consistently for me with PCID enabled.
    CR3 is updated with a new value, unlikely(cr3 != vmx->host_state.vmcs_host_cr3)
    fires, and the currently loaded VMCS is updated. Then we switch from L2 to
    L1 and the next exit reverts CR3 to its old value.
    
    Fixes: d6e41f11 ("x86/mm, KVM: Teach KVM's VMX code that CR3 isn't a constant")
    Signed-off-by: default avatarLadi Prosek <lprosek@redhat.com>
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    44889942
vmx.c 343 KB