Re: [PATCH v2 1/3] KVM: VMX: Support the secondary VM-exit controls
From: Sohil Mehta
Date: Thu Dec 03 2026 - 16:25:55 EST
+Vitaly
> arch/x86/include/asm/msr-index.h | 1 +
> arch/x86/include/asm/vmx.h | 3 +++
> arch/x86/kvm/vmx/capabilities.h | 6 ++++++
> arch/x86/kvm/vmx/nested.c | 3 +++
> arch/x86/kvm/vmx/vmcs.h | 1 +
> arch/x86/kvm/vmx/vmx.c | 25 +++++++++++++++++++++++++
> arch/x86/kvm/vmx/vmx.h | 7 ++++++-
> 7 files changed, 45 insertions(+), 1 deletion(-)
>
Sashiko identified a sanitization item in kvm/vmx/ related to Hyper-V's
eVMCS.
https://lore.kernel.org/all/sashiko-outbox-247271@xxxxxxxxxx/
The change is just two additional lines and avoids a future pitfall. So,
I plan to add the below diff to this patch. I don't think this warrants
a separate patch, especially since vmexit_2nd_ctrl is defined here.
Please let me know if anyone prefers otherwise.
Changelog update:
Like the tertiary controls, clear the secondary VM-exit controls when
KVM is running on Hyper-V, as eVMCS has no field for them.
diff --git a/arch/x86/kvm/vmx/hyperv_evmcs.h
b/arch/x86/kvm/vmx/hyperv_evmcs.h
index 052b62b8ed8e..99a4be8a2a40 100644
--- a/arch/x86/kvm/vmx/hyperv_evmcs.h
+++ b/arch/x86/kvm/vmx/hyperv_evmcs.h
@@ -106,6 +106,8 @@
VM_EXIT_PT_CONCEAL_PIP | \
VM_EXIT_CLEAR_IA32_RTIT_CTL)
+#define EVMCS1_SUPPORTED_VMEXIT_2ND_CTRL (0ULL)
+
#define EVMCS1_SUPPORTED_VMENTRY_CTRL \
(VM_ENTRY_ALWAYSON_WITHOUT_TRUE_MSR | \
VM_ENTRY_LOAD_DEBUG_CONTROLS | \
diff --git a/arch/x86/kvm/vmx/vmx_onhyperv.c
b/arch/x86/kvm/vmx/vmx_onhyperv.c
index b9a8b91166d0..56afb372e50d 100644
--- a/arch/x86/kvm/vmx/vmx_onhyperv.c
+++ b/arch/x86/kvm/vmx/vmx_onhyperv.c
@@ -33,4 +33,5 @@ void evmcs_sanitize_exec_ctrls(struct vmcs_config
*vmcs_conf)
evmcs_check_vmcs_conf(cpu_based_3rd_exec_ctrl, 3RDEXEC);
evmcs_check_vmcs_conf(vmentry_ctrl, VMENTRY_CTRL);
evmcs_check_vmcs_conf(vmexit_ctrl, VMEXIT_CTRL);
+ evmcs_check_vmcs_conf(vmexit_2nd_ctrl, VMEXIT_2ND_CTRL);
}