Commit 32452bac6d for qemu.org
commit 32452bac6d991e9778dd7a9fb2b3eed3a2b23d71
Author: Mohamed Mediouni <mohamed@unpredictable.fr>
Date: Wed Aug 12 10:28:10 2026 +0200
hw/i386: fw_cfg: do not set VMX feature control on WHPX
Hyper-V doesn't allow setting this bit on build 26100.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260812082814.27217-3-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/hw/i386/fw_cfg.c b/hw/i386/fw_cfg.c
index d422302c1c..5903994a7c 100644
--- a/hw/i386/fw_cfg.c
+++ b/hw/i386/fw_cfg.c
@@ -13,6 +13,8 @@
*/
#include "qemu/osdep.h"
+#include "system/mshv.h"
+#include "system/whpx.h"
#include "system/numa.h"
#include "hw/acpi/acpi.h"
#include "hw/acpi/aml-build.h"
@@ -182,8 +184,15 @@ void fw_cfg_build_feature_control(MachineState *ms, FWCfgState *fw_cfg)
uint64_t *val;
cpu_x86_cpuid(env, 1, 0, &unused, &unused, &ecx, &edx);
- if (ecx & CPUID_EXT_VMX) {
- feature_control_bits |= FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX;
+
+ /*
+ * Hyper-V in 26100 disallows this bit to be set.
+ * Otherwise a #GP gets raised.
+ */
+ if (!(whpx_enabled())) {
+ if (ecx & CPUID_EXT_VMX) {
+ feature_control_bits |= FEATURE_CONTROL_VMXON_ENABLED_OUTSIDE_SMX;
+ }
}
if ((edx & (CPUID_EXT2_MCE | CPUID_EXT2_MCA)) ==