From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=109.224.244.108 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796341789; b=P+VOCv34qcylhlVwZ6Crp1rb3J1p3qCIj9Vv8ZWZ9lSXCBNl25cJziNcXArAtQZKrixM EdychDUmNG3WaYgOD/HR7LRnYmj9Hh4jiPpz8ZKF4iR4Sd1OvSWB0T3VMht1FK8yILcrK soMnePbd6ZdiG+bge9/B3Bqp0aNFy0x689ALOFktC7eSk/X9ObN5qiP0hx9DsbRIJ5sac lgCVGYMSG/11Rgkauyekk9IJGUQJdSStg96acYXeARu2CIWQ8A+AVWnosSwaG7uaowhox AoRydb0d1XENCylH/gtZr2vMfX3XHLZ3cA8Y4b/yS4ju2cArqfNVp7GKq+EBv/79rGg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796341789; h=DMARC-Filter:DKIM-Signature:X-Pm-Submission-Id:From:Subject:Date: Message-Id:MIME-Version:Content-Type:Content-Transfer-Encoding: X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer:X-Developer-Signature: X-Developer-Key; bh=6X2iEQbuiDTLXvI96qEnHmM/d52L7oUKvxgLxSf1A8E=; b=z92LyWlZx8pp2tT074/gOPV2k76fSDmWIROH0AE2B5J42rO0dwVXXIeQ6Zq/jvZcNZN7 pqF97YT7BoYNeq6gA8C0qe0jUY6YelUkGusuPexqr9mS3xc8HCjfWB7yo52qf/tecpKCS Q4aqGMl42uIi5Hr2nHrnIUO5bSkfl03b+2FFYh7hvab7C5s/6b7FS24hH/JaLsyHI866s Qxz+jfqJDMHwd1ncRzk54f0FjSf/YJdqOIK4KDhBs0WImQIpbr+F/fynNwrT1RMI5g+mj D5mQ0q+iZP3gZ+4j3pIo43/AliHpEvw/kgMy4mrJp11DRlC9u2rdeswWrcHLxWdD17A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=reusswig.codes; spf=pass smtp.mailfrom=reusswig.codes; dkim=pass header.d=reusswig.codes header.i=@reusswig.codes header.a=rsa-sha256 header.s=protonmail3 header.b=h+bcAigG; arc=none smtp.remote-ip=109.224.244.108 Received: from mail-244108.protonmail.ch (mail-244108.protonmail.ch [109.224.244.108]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 006FB606A32C; Thu, 3 Dec 2026 23:49:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 006FB606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=reusswig.codes Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=reusswig.codes Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=reusswig.codes header.i=@reusswig.codes header.a=rsa-sha256 header.s=protonmail3 header.b=h+bcAigG DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=reusswig.codes; s=protonmail3; t=1796341784; x=1796600984; bh=6X2iEQbuiDTLXvI96qEnHmM/d52L7oUKvxgLxSf1A8E=; h=From:Subject:Date:Message-Id:To:Cc:From:To:Cc:Date:Subject: Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=h+bcAigGnUf+tE8qLexOSJrSwUu/DUzdbKL5VQEON60odr0u0yWBRTuzPvXpnQ+BY 1aCADF4mo4HVZypghGgNdYkVZH/uuDMlY8MiqvCUBUBS1/X6x8YwZ6WNdMbAqv67oR 6chAZo52x88WfuYtt+NU0KEy6rZr2O3wH30KUyXhblBJYAG9FEuOyhtIkh/lk7L5GD hulrkh0ob6Yoq1gB5vPRCx4oQhBlJ9FjXsr92az0DJFhWf+E5lDSBRYUv+rgXJ9a1L avwJq6/jB0ba7YEN0MpUMikEKzevhPlsCx3V9+xVqXlko3+9XOC4hwi0pmREndKYBt MEbrP0lMrvSAw== X-Pm-Submission-Id: 4jgWZD1GSPz2ScNx From: =?utf-8?q?Dennis_Reu=C3=9Fwig?= Subject: [PATCH 00/10] KVM: nVMX: Supervisor shadow-stack control for nested EPT and CET with eVMCS Date: Fri, 04 Dec 2026 00:49:13 +0100 Message-Id: <20261204-nested-sss-v1-0-57de06f58b2b@reusswig.codes> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-B4-Tracking: v=1; b=H4sIAAAAAAAC/x3MQQqAIBBA0avIrBNUrKyrRItwppqNhRMRSHdPW r7F/wWEMpPAqApkuln4SBW2URD3JW2kGavBGddZZ7xOJBehFhFt+iEQYvTYBqjBmWnl559N8/t +qDg761wAAAA= X-Change-ID: 20261204-nested-sss-0798eddc4d58 To: Sean Christopherson , Paolo Bonzini , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Jon Kohler , Jonathan Corbet , Shuah Khan , Randy Dunlap , Shuah Khan Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Chao Gao , Maxim Levitsky , Vitaly Kuznetsov , Panayotis Katsaloulis , =?utf-8?q?Dennis_Reu=C3=9Fwig?= X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=7966; i=dennis@reusswig.codes; h=from:subject:message-id; bh=XlA+jnqltmwQx6Z6xv54EtM38e0KQhSbExt0ccCMAqU=; b=owEBbQKS/ZANAwAIAWBucoRlTGuCAcsmYgBrEgAG/7cmiQK70MNylLoPIO9XNOruUnkejOQqN LNQqnTRfcGJAjMEAAEIAB0WIQS59eJ1vy/tsv/LkIBgbnKEZUxrggUCaxIABgAKCRBgbnKEZUxr gpuGD/4xbvITQlojSdFYTLqRL0Ow7JnpOQtbCd6CYyYGkotsRQo4m8ddqalPhmLW6OVN3C+7Jzv 27NGoFRt7VJSqrkvOrz0CCUgvGASUguikYoDyeNRKofB3WFr8CX0aMdqGAwsBuPc5jLyLA4txB1 FSUQYnWQxRGNEJ4psHCBHyTiTQEa8XJ9BvQowztbOtyhjDXfyt+Odn/52wZYV8jJC+iOiNTVPaA 3CwNojA25dC3qK/iCdXHt9i07Y2KyObULEGolgm4TfNLNIpAhmhPs296KI54HtaHRnF1msIih/y HByqNuFu56jqC/yFvEIgN3L5YRThl1jTBdruD6wmvhXg6mSgJH/MHv+F9jaNhvZOPd6BSjYbAOO gDgIWnXqnV7VGM2h23dH+iLsQC5RuRz7lJUhrfrrhCjwBUtG7e5tTYygvszoQ5pEnisQS2Hbx4Z +UyLC80AWSt/HnD/EDsqio62iTVM1GrVnQWn3Q7bNrZrDzRl8beXLwopGL3O9D7lKO3Py4cWIIM XURDAZmxKB5tOB1F19l6c2txfA3Bae/XhzpVsXw/d1ASUNq/hCaEdRItraa510VflKbfnvfH0bX NWt+kW4FlKjzEQklm5k4tnDT8Qn63CIe03kAPnebgYFd3RCkNqUkrGIyWlFs6UoYfnturRWUUFQ UQ/qwVEQcp5q7SQ== X-Developer-Key: i=dennis@reusswig.codes; a=openpgp; fpr=D8E955E3BCD7A0A0DEDE55D1B92D668A3A02E8CA 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