[PATCH v2 0/3] KVM: x86: CET vs. nVMX fix and hardening

Sean Christopherson posted 3 patches 1 week, 3 days ago
arch/x86/kvm/cpuid.c   | 10 ++++++++--
arch/x86/kvm/cpuid.h   | 12 +++++++++++-
arch/x86/kvm/svm/svm.c |  6 +++++-
arch/x86/kvm/vmx/vmx.c | 23 +++++++++++++++++++++--
arch/x86/kvm/x86.c     | 30 +++++++++++++++++-------------
arch/x86/kvm/x86.h     |  2 ++
6 files changed, 64 insertions(+), 19 deletions(-)
[PATCH v2 0/3] KVM: x86: CET vs. nVMX fix and hardening
Posted by Sean Christopherson 1 week, 3 days ago
Fix a bug where KVM will clear IBT and SHSTK bits after nested VMX MSRs
have been configured, e.g. if the kernel is built with CONFIG_X86_CET=y
but CONFIG_X86_KERNEL_IBT=n.  The late clearing results in kvm-intel.ko
refusing to load as the CPU compatible checks generate their VMCS configs
with IBT=n and SHSTK=n, ultimately causing a mismatch on the CET entry
and exit controls.

Patch 2 hardens against similar bugs in the future by adding a flag and
WARNs to yell if KVM sets or clear feature flags outside of the dedicated
flow.

Patch 3 adds (very, very) long overdue printing of the mistmatching offsets
in the VMCS configs.

Chao, I didn't include any of your Reviewed-by's, as every patch changed
quite a bit from v1.

v2:
 - Isolate kvm_setup_xss_caps() from kvm_finalize_cpu_caps(). [Xiaoyao]
 - Fix the pr_cont() printing. [Chao]

v1: https://lore.kernel.org/all/20260123221542.2498217-1-seanjc@google.com

Sean Christopherson (3):
  KVM: x86: Explicitly configure supported XSS from
    {svm,vmx}_set_cpu_caps()
  KVM: x86: Harden against unexpected adjustments to kvm_cpu_caps
  KVM: VMX: Print out "bad" offsets+value on VMCS config mismatch

 arch/x86/kvm/cpuid.c   | 10 ++++++++--
 arch/x86/kvm/cpuid.h   | 12 +++++++++++-
 arch/x86/kvm/svm/svm.c |  6 +++++-
 arch/x86/kvm/vmx/vmx.c | 23 +++++++++++++++++++++--
 arch/x86/kvm/x86.c     | 30 +++++++++++++++++-------------
 arch/x86/kvm/x86.h     |  2 ++
 6 files changed, 64 insertions(+), 19 deletions(-)


base-commit: e81f7c908e1664233974b9f20beead78cde6343a
-- 
2.52.0.457.g6b5491de43-goog
Re: [PATCH v2 0/3] KVM: x86: CET vs. nVMX fix and hardening
Posted by Sean Christopherson 3 days, 2 hours ago
On Tue, 27 Jan 2026 17:43:07 -0800, Sean Christopherson wrote:
> Fix a bug where KVM will clear IBT and SHSTK bits after nested VMX MSRs
> have been configured, e.g. if the kernel is built with CONFIG_X86_CET=y
> but CONFIG_X86_KERNEL_IBT=n.  The late clearing results in kvm-intel.ko
> refusing to load as the CPU compatible checks generate their VMCS configs
> with IBT=n and SHSTK=n, ultimately causing a mismatch on the CET entry
> and exit controls.
> 
> [...]

This got a bit messy, as I want to get the immediate fix into 6.19 (hopefully
I wasn't too late), and at that point there was no reason to shove the VMCS
patch in with the kvm_cpu_caps hardening.

Applied patch 1 to "fixes", patch 2 to "misc", and patch 3 to "vmx.

[1/3] KVM: x86: Explicitly configure supported XSS from {svm,vmx}_set_cpu_caps()
      https://github.com/kvm-x86/linux/commit/f8ade833b733
[2/3] KVM: x86: Harden against unexpected adjustments to kvm_cpu_caps
      https://github.com/kvm-x86/linux/commit/3f2757dbf32a
[3/3] KVM: VMX: Print out "bad" offsets+value on VMCS config mismatch
      https://github.com/kvm-x86/linux/commit/c0d6b8bbbced

--
https://github.com/kvm-x86/linux/tree/next