mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 00/10] KVM: nVMX: Supervisor shadow-stack control for nested EPT and CET with eVMCS
@ 2026-12-03 23:49 Dennis Reußwig
  2026-12-03 23:49 ` [PATCH 01/10] KVM: nVMX: Allow CET entry/exit controls with enlightened VMCS Dennis Reußwig
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Dennis Reußwig @ 2026-12-03 23:49 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini, Thomas Gleixner, Ingo Molnar,
	Borislav Petkov, Dave Hansen, x86, H. Peter Anvin, Jon Kohler,
	Jonathan Corbet, Shuah Khan, Randy Dunlap, Shuah Khan
  Cc: kvm, linux-kernel, linux-doc, linux-kselftest, Chao Gao,
	Maxim Levitsky, Vitaly Kuznetsov, Panayotis Katsaloulis,
	Dennis Reußwig

Windows 11 guests with Hyper-V enabled (virtualization-based security,
HVCI, Credential Guard, WSL2) stopped booting on Intel hosts with 7.2;
they end in Automatic Repair [1][2].  Proxmox VE hides MBEC from L1
for older machine versions as a mitigation [4].

The trigger is commit 606ddbfb4c02 ("KVM: nVMX: advertise MBEC to
nested guests").  Hyper-V appears to enable CET for its guests only
when it is offered MBEC (or GMET): without the series, Windows boots
with vmx-mbec=off, and also with MBEC but without CET
(cet-ss=off,cet-ibt=off).  With CET, Hyper-V needs two things that KVM
does not provide to L1:

1. Supervisor shadow-stack control for EPT (IA32_VMX_EPT_VPID_CAP bit
   23, EPTP bit 7, EPT bit 60).  KVM never advertised it.

2. The VM-entry and VM-exit controls that load CET state.  KVM offers
   them, but with the enlightened VMCS nested_evmcs_filter_control_msr()
   removes them, and the CET fields of the eVMCS are not wired up.

This matches the report: vmx-mbec=off boots, hv-evmcs=off alone does
not.  AMD hosts are not affected: Windows with VBS and GMET boots on
7.2 and kvm-x86/next on a Zen 3 host.

Which patches a configuration needs:

- without enlightened VMCS: patches 2 to 6;
- with enlightened VMCS (hv-evmcs, or implicitly via hv-passthrough):
  patches 1 to 6.

Patch 1 is first because it is small and independent of the MMU work,
but on its own it does not make Windows boot; it carries a Fixes tag
because it is half of the fix for eVMCS users.

The series:

- Patch 1 lets L1 use the CET entry/exit controls and fields with
  eVMCS.
- Patch 2 moves the A/D tracking type of TDP SPTEs from bits 60-61 to
  bits 56-57, because the CPU interprets bit 60 as the supervisor
  shadow-stack permission when EPTP bit 7 is set.  This is the only
  layout change and is meant to have no functional effect.
- Patch 3 passes the shadow-stack bit of EPT violations to the MMU as
  PFERR_SS, as Paolo suggested in the report thread.
- Patch 4 makes the MMU treat bit 60 like the writable bit (write
  protection, unsync, dirty logging, TLB flushes), since it lets the
  guest write the page with shadow-stack accesses.
- Patch 5 implements supervisor shadow-stack control in the nested EPT
  walker, with a new role bit, and reports exit qualification bits 13
  and 14 to L1.
- Patch 6 advertises the capability and accepts EPTP bit 7.
- Patches 7 to 10 add selftests: the SSS rules of the walker, MBEC
  supervisor fetches, and the VMX capabilities that L1 needs for CET
  with MBEC, with and without eVMCS.  The last one fails without the
  series.

With CET, Hyper-V does not boot unless the capability is offered, but
it did not set EPTP bit 7 in any of my runs.  KVM cannot advertise the
capability without implementing it, hence patches 2 to 5; the Windows
boots exercise the capability and the eVMCS part, and the enforcement
in the walker is covered by the selftest of patch 8.

The VMM has to pass bit 23 of IA32_VMX_EPT_VPID_CAP to L1.  QEMU drops
EPT capability bits it does not know, so with QEMU 11.1.4 the series
alone is not enough; I will post a QEMU patch that adds the
"vmx-ept-sss" property (depending on cet-ss) to qemu-devel.

Testing, base kvm-x86/next cbe54fc3462b vs the series:

Intel Core i7-13700K, QEMU 11.1.4 with the property added, OVMF
2025.11 with Secure Boot, swtpm 0.10.1, -cpu host:
- Windows 11 Pro 25H2 (26200) with VBS, HVCI and WSL2: base fails,
  the series boots with eVMCS on and off; 5 of 5 in-guest reboots;
  Alpine runs in WSL2.  The series with an unmodified QEMU still
  fails, as expected.
- Windows 11 Enterprise evaluation (26300): Credential Guard and HVCI
  running.
- Linux L1 running an L2 and KVM selftests inside L1.
- KVM selftests and kvm-unit-tests vmx: same results with and without
  the series apart from the new tests, for all 91 x86 selftests with
  default parameters, and for the nested, MMU and Hyper-V subset also
  with kvm_intel ept=0, mbec=0 and enable_apicv=0.
- KASAN, PROVE_LOCKING and DEBUG_ATOMIC_SLEEP kernels: no reports.
- Negative tests: supervisor fetches from user-execute-only pages under
  MBEC fault the same way with and without the series.  Restricted
  supervisor shadow-stack accesses cause EPT violations as L1
  configured them; without the series L1 cannot enable supervisor
  shadow-stack control at all.  The bug over-restricted L2 and did not
  let it bypass L1's EPT permissions.

AMD Ryzen 5 5600G (regression check for the shared MMU code): Windows
with VBS and GMET boots with and without the series; KVM selftests the
same, also with kvm_amd npt=0, avic=0 and gmet=0.

Not tested: Windows Sandbox; the host lockup reported on a Xeon 6426Y
while testing the MBEC series [3] (not reproduced on my hardware); MBEC
user-mode instruction fetches (the selftest covers supervisor fetches
only).

There is no Cc: stable.  The series changes the SPTE layout and is
large for a backport; if a minimal fix for 7.2.y is preferred, I am
happy to prepare one, for example not offering MBEC to L1 when
supervisor shadow-stack control cannot be offered.

Thanks to Panayotis Katsaloulis for the report and to Paolo for the
PFERR_SS pointer.

[1] https://lore.kernel.org/kvm/58dcd595e3187d335e103a042d196cb7@panayotis.com/
[2] https://bugzilla.suse.com/show_bug.cgi?id=1277716
[3] Earlier report while testing the MBEC series (Xeon, host lockups,
    -cet-ss,-cet-ibt workaround): https://lkml.iu.edu/2605.2/05048.html
[4] Proxmox mitigation hiding MBEC from L1 for older machine versions:
    https://lore.proxmox.com/all/20260713124025.121154-4-f.ebner@proxmox.com/

---
Dennis Reußwig (10):
      KVM: nVMX: Allow CET entry/exit controls with enlightened VMCS
      KVM: x86/mmu: Move TDP A/D tracking type to SPTE bits 56-57
      KVM: VMX: Report shadow-stack accesses in EPT violations as PFERR_SS
      KVM: x86/mmu: Handle the EPT supervisor shadow-stack bit like a write bit
      KVM: nVMX: Shadow supervisor shadow-stack control of nested EPT
      KVM: nVMX: Advertise supervisor shadow-stack control for nested EPT
      KVM: selftests: Add helpers for nested EPT shadow-stack and MBEC tests
      KVM: selftests: Add nested EPT supervisor shadow-stack test
      KVM: selftests: Add nested EPT mode-based execute control test
      KVM: selftests: Check VMX capabilities for CET in L2 with MBEC

 Documentation/virt/kvm/x86/mmu.rst                 |   4 +
 arch/x86/include/asm/kvm_host.h                    |  18 +-
 arch/x86/include/asm/vmx.h                         |   5 +
 arch/x86/kvm/mmu.h                                 |   8 +-
 arch/x86/kvm/mmu/mmu.c                             |  35 +++-
 arch/x86/kvm/mmu/paging_tmpl.h                     |  90 ++++++++-
 arch/x86/kvm/mmu/spte.c                            |  34 +++-
 arch/x86/kvm/mmu/spte.h                            |  34 +++-
 arch/x86/kvm/vmx/common.h                          |   3 +
 arch/x86/kvm/vmx/hyperv_evmcs.c                    |  24 +--
 arch/x86/kvm/vmx/hyperv_evmcs.h                    |   6 +-
 arch/x86/kvm/vmx/nested.c                          |  52 +++--
 arch/x86/kvm/vmx/vmx.c                             |   4 +
 tools/testing/selftests/kvm/Makefile.kvm           |   3 +
 .../testing/selftests/kvm/include/x86/processor.h  |   5 +
 tools/testing/selftests/kvm/include/x86/vmx.h      |  11 ++
 tools/testing/selftests/kvm/lib/x86/processor.c    |   9 +-
 .../selftests/kvm/x86/vmx_nested_cet_caps_test.c   |  90 +++++++++
 .../selftests/kvm/x86/vmx_nested_mbec_test.c       | 189 ++++++++++++++++++
 .../selftests/kvm/x86/vmx_nested_sss_test.c        | 213 +++++++++++++++++++++
 20 files changed, 763 insertions(+), 74 deletions(-)
---
base-commit: cbe54fc3462b3949ab27b9ae81fb9ddb509040c7
change-id: 20261204-nested-sss-0798eddc4d58

Best regards,
-- 
Dennis Reußwig <dennis@reusswig.codes>


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-12-03 23:50 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-03 23:49 [PATCH 00/10] KVM: nVMX: Supervisor shadow-stack control for nested EPT and CET with eVMCS Dennis Reußwig
2026-12-03 23:49 ` [PATCH 01/10] KVM: nVMX: Allow CET entry/exit controls with enlightened VMCS Dennis Reußwig
2026-12-03 23:49 ` [PATCH 02/10] KVM: x86/mmu: Move TDP A/D tracking type to SPTE bits 56-57 Dennis Reußwig
2026-12-03 23:49 ` [PATCH 03/10] KVM: VMX: Report shadow-stack accesses in EPT violations as PFERR_SS Dennis Reußwig
2026-12-03 23:49 ` [PATCH 04/10] KVM: x86/mmu: Handle the EPT supervisor shadow-stack bit like a write bit Dennis Reußwig
2026-12-03 23:49 ` [PATCH 05/10] KVM: nVMX: Shadow supervisor shadow-stack control of nested EPT Dennis Reußwig
2026-12-03 23:49 ` [PATCH 06/10] KVM: nVMX: Advertise supervisor shadow-stack control for " Dennis Reußwig
2026-12-03 23:49 ` [PATCH 07/10] KVM: selftests: Add helpers for nested EPT shadow-stack and MBEC tests Dennis Reußwig
2026-12-03 23:49 ` [PATCH 08/10] KVM: selftests: Add nested EPT supervisor shadow-stack test Dennis Reußwig
2026-12-03 23:49 ` [PATCH 09/10] KVM: selftests: Add nested EPT mode-based execute control test Dennis Reußwig
2026-12-03 23:49 ` [PATCH 10/10] KVM: selftests: Check VMX capabilities for CET in L2 with MBEC Dennis Reußwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®