KVM: x86: Reject disabling of MWAIT/HLT interception when not allowed
authorSean Christopherson <seanjc@google.com>
Thu, 28 Nov 2024 01:33:41 +0000 (17:33 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 18 Dec 2024 22:19:36 +0000 (14:19 -0800)
commitc829ccd4d9dc4a892e7c9ae032b87ac90ace2252
treec4943982fe263a2694235c739f557071dcda4396
parent04cd8f8628d88da7839b1643db0bef8522c39254
KVM: x86: Reject disabling of MWAIT/HLT interception when not allowed

Reject KVM_CAP_X86_DISABLE_EXITS if userspace attempts to disable MWAIT or
HLT exits and KVM previously reported (via KVM_CHECK_EXTENSION) that
disabling the exit(s) is not allowed.  E.g. because MWAIT isn't supported
or the CPU doesn't have an always-running APIC timer, or because KVM is
configured to mitigate cross-thread vulnerabilities.

Cc: Kechen Lu <kechenl@nvidia.com>
Fixes: 4d5422cea3b6 ("KVM: X86: Provide a capability to disable MWAIT intercepts")
Fixes: 6f0f2d5ef895 ("KVM: x86: Mitigate the cross-thread return address predictions bug")
Reviewed-by: Maxim Levitsky <mlevitsk@redhat.com>
Reviewed-by: Xiaoyao Li <xiaoyao.li@intel.com>
Link: https://lore.kernel.org/r/20241128013424.4096668-15-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/x86.c