]> asedeno.scripts.mit.edu Git - linux.git/commit
kvm: x86: nVMX: maintain internal copy of current VMCS
authorDavid Matlack <dmatlack@google.com>
Thu, 14 Jul 2016 00:16:37 +0000 (17:16 -0700)
committerRadim Krčmář <rkrcmar@redhat.com>
Mon, 1 Aug 2016 12:49:05 +0000 (14:49 +0200)
commit4f2777bc97974b0df9276ee9a85155a9e27a5282
tree44b8579722765e29f3a69ff09d2950165f94cfb4
parent601045bff74569374b3d5b34dbb9bad71adf3aa5
kvm: x86: nVMX: maintain internal copy of current VMCS

KVM maintains L1's current VMCS in guest memory, at the guest physical
page identified by the argument to VMPTRLD. This makes hairy
time-of-check to time-of-use bugs possible,as VCPUs can be writing
the the VMCS page in memory while KVM is emulating VMLAUNCH and
VMRESUME.

The spec documents that writing to the VMCS page while it is loaded is
"undefined". Therefore it is reasonable to load the entire VMCS into
an internal cache during VMPTRLD and ignore writes to the VMCS page
-- the guest should be using VMREAD and VMWRITE to access the current
VMCS.

To adhere to the spec, KVM should flush the current VMCS during VMPTRLD,
and the target VMCS during VMCLEAR (as given by the operand to VMCLEAR).
Since this implementation of VMCS caching only maintains the the current
VMCS, VMCLEAR will only do a flush if the operand to VMCLEAR is the
current VMCS pointer.

KVM will also flush during VMXOFF, which is not mandated by the spec,
but also not in conflict with the spec.

Signed-off-by: David Matlack <dmatlack@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx.c