From: "Dennis Reußwig" <dennis@reusswig.codes>
To: Sean Christopherson <seanjc@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Thomas Gleixner <tglx@kernel.org>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Jon Kohler <jon@nutanix.com>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Shuah Khan <shuah@kernel.org>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org,
"Chao Gao" <chao.gao@intel.com>,
"Maxim Levitsky" <mlevitsk@redhat.com>,
"Vitaly Kuznetsov" <vkuznets@redhat.com>,
"Panayotis Katsaloulis" <panayotis@panayotis.com>,
"Dennis Reußwig" <dennis@reusswig.codes>
Subject: [PATCH 01/10] KVM: nVMX: Allow CET entry/exit controls with enlightened VMCS
Date: Fri, 04 Dec 2026 00:49:14 +0100 [thread overview]
Message-ID: <20261204-nested-sss-v1-1-57de06f58b2b@reusswig.codes> (raw)
In-Reply-To: <20261204-nested-sss-v1-0-57de06f58b2b@reusswig.codes>
Since commit 55a71224bd90 ("KVM: nVMX: allow MBEC with EVMCS"), L1 is
offered mode-based execute control also when it uses the enlightened
VMCS. Windows Hyper-V then enables CET for its guests and needs the
VM-entry and VM-exit controls that load CET state. With eVMCS,
nested_evmcs_filter_control_msr() hides them from L1, because they are
missing from EVMCS1_SUPPORTED_VMENTRY_CTRL and
EVMCS1_SUPPORTED_VMEXIT_CTRL, and the CET fields of the eVMCS are
neither in vmcs_field_to_evmcs_1[] nor copied to and from vmcs12.
Add the CET fields (GUEST_S_CET, GUEST_SSP, GUEST_INTR_SSP_TABLE,
HOST_S_CET, HOST_SSP, HOST_INTR_SSP_TABLE) to the field table, using
the clean-field groups of the entries that were commented out, copy
them in copy_enlightened_to_vmcs12() and the guest fields back in
copy_vmcs12_to_enlightened(), and allow the two controls.
This alone does not make Windows boot: Hyper-V also needs supervisor
shadow-stack control for nested EPT, which is added later in this
series.
Fixes: 55a71224bd90 ("KVM: nVMX: allow MBEC with EVMCS")
Reported-by: Panayotis Katsaloulis <panayotis@panayotis.com>
Closes: https://lore.kernel.org/kvm/58dcd595e3187d335e103a042d196cb7@panayotis.com/
Signed-off-by: Dennis Reußwig <dennis@reusswig.codes>
---
arch/x86/kvm/vmx/hyperv_evmcs.c | 24 ++++++++++++------------
arch/x86/kvm/vmx/hyperv_evmcs.h | 6 ++++--
arch/x86/kvm/vmx/nested.c | 31 +++++++++++++------------------
3 files changed, 29 insertions(+), 32 deletions(-)
diff --git a/arch/x86/kvm/vmx/hyperv_evmcs.c b/arch/x86/kvm/vmx/hyperv_evmcs.c
index cc728c9a3de5..f00e4edf1e6c 100644
--- a/arch/x86/kvm/vmx/hyperv_evmcs.c
+++ b/arch/x86/kvm/vmx/hyperv_evmcs.c
@@ -128,23 +128,23 @@ const struct evmcs_field vmcs_field_to_evmcs_1[] = {
HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2),
EVMCS1_FIELD(TSC_MULTIPLIER, tsc_multiplier,
HV_VMX_ENLIGHTENED_CLEAN_FIELD_CONTROL_GRP2),
+ EVMCS1_FIELD(GUEST_S_CET, guest_ia32_s_cet,
+ HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1),
+ EVMCS1_FIELD(GUEST_SSP, guest_ssp,
+ HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC),
+ EVMCS1_FIELD(GUEST_INTR_SSP_TABLE, guest_ia32_int_ssp_table_addr,
+ HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1),
+ EVMCS1_FIELD(HOST_S_CET, host_ia32_s_cet,
+ HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1),
+ EVMCS1_FIELD(HOST_SSP, host_ssp,
+ HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1),
+ EVMCS1_FIELD(HOST_INTR_SSP_TABLE, host_ia32_int_ssp_table_addr,
+ HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1),
/*
* Not used by KVM:
*
- * EVMCS1_FIELD(0x00006828, guest_ia32_s_cet,
- * HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1),
- * EVMCS1_FIELD(0x0000682A, guest_ssp,
- * HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_BASIC),
- * EVMCS1_FIELD(0x0000682C, guest_ia32_int_ssp_table_addr,
- * HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1),
* EVMCS1_FIELD(0x00002816, guest_ia32_lbr_ctl,
* HV_VMX_ENLIGHTENED_CLEAN_FIELD_GUEST_GRP1),
- * EVMCS1_FIELD(0x00006C18, host_ia32_s_cet,
- * HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1),
- * EVMCS1_FIELD(0x00006C1A, host_ssp,
- * HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1),
- * EVMCS1_FIELD(0x00006C1C, host_ia32_int_ssp_table_addr,
- * HV_VMX_ENLIGHTENED_CLEAN_FIELD_HOST_GRP1),
*/
/* 64 bit read only */
diff --git a/arch/x86/kvm/vmx/hyperv_evmcs.h b/arch/x86/kvm/vmx/hyperv_evmcs.h
index 052b62b8ed8e..a6e9210e4fa5 100644
--- a/arch/x86/kvm/vmx/hyperv_evmcs.h
+++ b/arch/x86/kvm/vmx/hyperv_evmcs.h
@@ -104,7 +104,8 @@
VM_EXIT_LOAD_IA32_EFER | \
VM_EXIT_CLEAR_BNDCFGS | \
VM_EXIT_PT_CONCEAL_PIP | \
- VM_EXIT_CLEAR_IA32_RTIT_CTL)
+ VM_EXIT_CLEAR_IA32_RTIT_CTL | \
+ VM_EXIT_LOAD_CET_STATE)
#define EVMCS1_SUPPORTED_VMENTRY_CTRL \
(VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR | \
@@ -115,7 +116,8 @@
VM_ENTRY_LOAD_IA32_EFER | \
VM_ENTRY_LOAD_BNDCFGS | \
VM_ENTRY_PT_CONCEAL_PIP | \
- VM_ENTRY_LOAD_IA32_RTIT_CTL)
+ VM_ENTRY_LOAD_IA32_RTIT_CTL | \
+ VM_ENTRY_LOAD_CET_STATE)
#define EVMCS1_SUPPORTED_VMFUNC (0)
diff --git a/arch/x86/kvm/vmx/nested.c b/arch/x86/kvm/vmx/nested.c
index 1a98f28651f7..a7c8bbdfe4ca 100644
--- a/arch/x86/kvm/vmx/nested.c
+++ b/arch/x86/kvm/vmx/nested.c
@@ -1758,10 +1758,7 @@ static void copy_enlightened_to_vmcs12(struct vcpu_vmx *vmx, u32 hv_clean_fields
vmcs12->guest_rflags = evmcs->guest_rflags;
vmcs12->guest_interruptibility_info =
evmcs->guest_interruptibility_info;
- /*
- * Not present in struct vmcs12:
- * vmcs12->guest_ssp = evmcs->guest_ssp;
- */
+ vmcs12->guest_ssp = evmcs->guest_ssp;
}
if (unlikely(!(hv_clean_fields &
@@ -1809,12 +1806,9 @@ static void copy_enlightened_to_vmcs12(struct vcpu_vmx *vmx, u32 hv_clean_fields
vmcs12->host_gs_selector = evmcs->host_gs_selector;
vmcs12->host_tr_selector = evmcs->host_tr_selector;
vmcs12->host_ia32_perf_global_ctrl = evmcs->host_ia32_perf_global_ctrl;
- /*
- * Not present in struct vmcs12:
- * vmcs12->host_ia32_s_cet = evmcs->host_ia32_s_cet;
- * vmcs12->host_ssp = evmcs->host_ssp;
- * vmcs12->host_ia32_int_ssp_table_addr = evmcs->host_ia32_int_ssp_table_addr;
- */
+ vmcs12->host_s_cet = evmcs->host_ia32_s_cet;
+ vmcs12->host_ssp = evmcs->host_ssp;
+ vmcs12->host_ssp_tbl = evmcs->host_ia32_int_ssp_table_addr;
}
if (unlikely(!(hv_clean_fields &
@@ -1932,11 +1926,11 @@ static void copy_enlightened_to_vmcs12(struct vcpu_vmx *vmx, u32 hv_clean_fields
vmcs12->guest_activity_state = evmcs->guest_activity_state;
vmcs12->guest_sysenter_cs = evmcs->guest_sysenter_cs;
vmcs12->guest_ia32_perf_global_ctrl = evmcs->guest_ia32_perf_global_ctrl;
+ vmcs12->guest_s_cet = evmcs->guest_ia32_s_cet;
+ vmcs12->guest_ssp_tbl = evmcs->guest_ia32_int_ssp_table_addr;
/*
* Not present in struct vmcs12:
- * vmcs12->guest_ia32_s_cet = evmcs->guest_ia32_s_cet;
* vmcs12->guest_ia32_lbr_ctl = evmcs->guest_ia32_lbr_ctl;
- * vmcs12->guest_ia32_int_ssp_table_addr = evmcs->guest_ia32_int_ssp_table_addr;
*/
}
@@ -2046,6 +2040,9 @@ static void copy_vmcs12_to_enlightened(struct vcpu_vmx *vmx)
* evmcs->vm_entry_msr_load_count = vmcs12->vm_entry_msr_load_count;
* evmcs->guest_ia32_perf_global_ctrl = vmcs12->guest_ia32_perf_global_ctrl;
* evmcs->host_ia32_perf_global_ctrl = vmcs12->host_ia32_perf_global_ctrl;
+ * evmcs->host_ia32_s_cet = vmcs12->host_s_cet;
+ * evmcs->host_ssp = vmcs12->host_ssp;
+ * evmcs->host_ia32_int_ssp_table_addr = vmcs12->host_ssp_tbl;
* evmcs->encls_exiting_bitmap = vmcs12->encls_exiting_bitmap;
* evmcs->tsc_multiplier = vmcs12->tsc_multiplier;
*
@@ -2054,13 +2051,7 @@ static void copy_vmcs12_to_enlightened(struct vcpu_vmx *vmx)
* evmcs->exit_io_instruction_esi = vmcs12->exit_io_instruction_esi;
* evmcs->exit_io_instruction_edi = vmcs12->exit_io_instruction_edi;
* evmcs->exit_io_instruction_eip = vmcs12->exit_io_instruction_eip;
- * evmcs->host_ia32_s_cet = vmcs12->host_ia32_s_cet;
- * evmcs->host_ssp = vmcs12->host_ssp;
- * evmcs->host_ia32_int_ssp_table_addr = vmcs12->host_ia32_int_ssp_table_addr;
- * evmcs->guest_ia32_s_cet = vmcs12->guest_ia32_s_cet;
* evmcs->guest_ia32_lbr_ctl = vmcs12->guest_ia32_lbr_ctl;
- * evmcs->guest_ia32_int_ssp_table_addr = vmcs12->guest_ia32_int_ssp_table_addr;
- * evmcs->guest_ssp = vmcs12->guest_ssp;
*/
evmcs->guest_es_selector = vmcs12->guest_es_selector;
@@ -2154,6 +2145,10 @@ static void copy_vmcs12_to_enlightened(struct vcpu_vmx *vmx)
evmcs->guest_bndcfgs = vmcs12->guest_bndcfgs;
+ evmcs->guest_ia32_s_cet = vmcs12->guest_s_cet;
+ evmcs->guest_ssp = vmcs12->guest_ssp;
+ evmcs->guest_ia32_int_ssp_table_addr = vmcs12->guest_ssp_tbl;
+
return;
#else /* CONFIG_KVM_HYPERV */
KVM_BUG_ON(1, vmx->vcpu.kvm);
--
2.53.0
next prev parent reply other threads:[~2026-12-03 23:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Dennis Reußwig [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204-nested-sss-v1-1-57de06f58b2b@reusswig.codes \
--to=dennis@reusswig.codes \
--cc=bp@alien8.de \
--cc=chao.gao@intel.com \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jon@nutanix.com \
--cc=kvm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=mlevitsk@redhat.com \
--cc=panayotis@panayotis.com \
--cc=pbonzini@redhat.com \
--cc=rdunlap@infradead.org \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=tglx@kernel.org \
--cc=vkuznets@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®