]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: x86: avoid incorrect writes to host MSR_IA32_SPEC_CTRL
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 20 Jan 2020 15:33:06 +0000 (16:33 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 6 Jan 2021 13:48:36 +0000 (14:48 +0100)
commitd77c1ab54c9edf38a1723902c9eaba133b5ca6c8
treecca2140793555033eb51d71ed036c8b5746803ec
parent11459136a107bd45fdf786a922ee03b7dbb65c87
KVM: x86: avoid incorrect writes to host MSR_IA32_SPEC_CTRL

[ Upstream commit 6441fa6178f5456d1d4b512c08798888f99db185 ]

If the guest is configured to have SPEC_CTRL but the host does not
(which is a nonsensical configuration but these are not explicitly
forbidden) then a host-initiated MSR write can write vmx->spec_ctrl
(respectively svm->spec_ctrl) and trigger a #GP when KVM tries to
restore the host value of the MSR.  Add a more comprehensive check
for valid bits of SPEC_CTRL, covering host CPUID flags and,
since we are at it and it is more correct that way, guest CPUID
flags too.

For AMD, remove the unnecessary is_guest_mode check around setting
the MSR interception bitmap, so that the code looks the same as
for Intel.

Cc: Jim Mattson <jmattson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/x86/kvm/svm.c
arch/x86/kvm/vmx/vmx.c
arch/x86/kvm/x86.c
arch/x86/kvm/x86.h