KVM: x86: Treat MONTIOR/MWAIT as a "partially emulated" feature
authorSean Christopherson <seanjc@google.com>
Thu, 28 Nov 2024 01:34:10 +0000 (17:34 -0800)
committerSean Christopherson <seanjc@google.com>
Wed, 18 Dec 2024 22:20:08 +0000 (14:20 -0800)
commitd4b9ff3d55dede868f43c4541ba999c109dbadcb
treec7454332fd8f3b09a4f531f3b7efe6c84841c3ca
parentff402f56e8eb21d65c73e559fb5db5a00cedb14a
KVM: x86: Treat MONTIOR/MWAIT as a "partially emulated" feature

Enumerate MWAIT in cpuid_func_emulated(), but only if the caller wants to
include "partially emulated" features, i.e. features that KVM kinda sorta
emulates, but with major caveats.  This will allow initializing the guest
cpu_caps based on the set of features that KVM virtualizes and/or emulates,
without needing to handle things like MONITOR/MWAIT as one-off exceptions.

Adding one-off handling for individual features is quite painful,
especially when considering future hardening.  It's very doable to verify,
at compile time, that every CPUID-based feature that KVM queries when
emulating guest behavior is actually known to KVM, e.g. to prevent KVM
bugs where KVM emulates some feature but fails to advertise support to
userspace.  In other words, any features that are special cased, i.e. not
handled generically in the CPUID framework, would also need to be special
cased for any hardening efforts that build on said framework.

Link: https://lore.kernel.org/r/20241128013424.4096668-44-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/cpuid.c