KVM: VMX: Sanitize VM-Entry/VM-Exit control pairs at kvm_intel load time
authorSean Christopherson <seanjc@google.com>
Fri, 27 May 2022 17:06:57 +0000 (17:06 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Jun 2022 17:06:18 +0000 (13:06 -0400)
commitf5a81d0eb01e0dfebd175edffa7d0a1bdb74d026
tree89384f4b5b8065e7408760635ba07277d9dec797
parent8e6a58e28b34e8d247e772159b8fa8f6bae39192
KVM: VMX: Sanitize VM-Entry/VM-Exit control pairs at kvm_intel load time

Sanitize the VM-Entry/VM-Exit control pairs (load+load or load+clear)
during setup instead of checking both controls in a pair at runtime.  If
only one control is supported, KVM will report the associated feature as
not available, but will leave the supported control bit set in the VMCS
config, which could lead to corruption of host state.  E.g. if only the
VM-Entry control is supported and the feature is not dynamically toggled,
KVM will set the control in all VMCSes and load zeros without restoring
host state.

Note, while this is technically a bug fix, practically speaking no sane
CPU or VMM would support only one control.  KVM's behavior of checking
both controls is mostly pedantry.

Cc: Chenyi Qiang <chenyi.qiang@intel.com>
Cc: Lei Wang <lei4.wang@intel.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220527170658.3571367-2-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/vmx/capabilities.h
arch/x86/kvm/vmx/vmx.c