[PATCH 01/10] KVM: nVMX: Allow CET entry/exit controls with enlightened VMCS
From: Dennis Reußwig
Date: Thu Dec 03 2026 - 18:50:01 EST
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@xxxxxxxxxxxxx>
Closes: https://lore.kernel.org/kvm/58dcd595e3187d335e103a042d196cb7@xxxxxxxxxxxxx/
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