KVM: nVMX: fix HOST_CR3/HOST_CR4 cache
authorLadi Prosek <lprosek@redhat.com>
Fri, 22 Sep 2017 05:53:15 +0000 (07:53 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 22 Sep 2017 08:41:32 +0000 (10:41 +0200)
commit44889942b6eb356eab27ce25fe10701adfec7776
treeb2d5d75ddc6633a2f189da17b4b2da1de2ef4c01
parent5753743fa5108b8f98bd61e40dc63f641b26c768
KVM: nVMX: fix HOST_CR3/HOST_CR4 cache

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: d6e41f1151fe ("x86/mm, KVM: Teach KVM's VMX code that CR3 isn't a constant")
Signed-off-by: Ladi Prosek <lprosek@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx.c