Commit 3b124791bd for qemu.org
commit 3b124791bdcea9d5a2fd74db5dcd5ba24cceb843
Author: Mohamed Mediouni <mohamed@unpredictable.fr>
Date: Wed Apr 22 23:41:58 2026 +0200
whpx: i386: disable kernel-irqchip on Windows 10 when PIC enabled
Move WHvCapabilityCodeProcessorPerfmonFeatures queries
as that's how we distinguish if on a legacy OS.
Now that Windows guests are booting, disable kernel-irqchip=on
by default for Windows 10 when the PIC is enabled.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260422214225.2242-11-mohamed@unpredictable.fr
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c
index 03c146dfb8..ab8e97787f 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2523,6 +2523,13 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
0x80000002, 0x80000003, 0x80000004, 0x80000007, 0x80000008,
0x8000000A, 0x80000021, 0x80000022, 0xC0000000, 0xC0000001};
+ X86MachineState *x86ms = X86_MACHINE(ms);
+ bool pic_enabled = false;
+
+ if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
+ pic_enabled = true;
+ }
+
whpx = &whpx_global;
if (!init_whp_dispatch()) {
@@ -2594,6 +2601,35 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
goto error;
}
+ /* Enable supported performance monitoring capabilities */
+ hr = whp_dispatch.WHvGetCapability(
+ WHvCapabilityCodeProcessorPerfmonFeatures, &perfmon_features,
+ sizeof(WHV_PROCESSOR_PERFMON_FEATURES), &whpx_cap_size);
+ /*
+ * Relying on this is a crutch to maintain Windows 10 support.
+ *
+ * WHvCapabilityCodeProcessorPerfmonFeatures and
+ * WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks
+ * are implemented starting from Windows Server 2022 (build 20348).
+ */
+ if (FAILED(hr)) {
+ warn_report("WHPX: Failed to get performance "
+ "monitoring features, hr=%08lx", hr);
+ is_modern_os = false;
+ } else {
+ hr = whp_dispatch.WHvSetPartitionProperty(
+ whpx->partition,
+ WHvPartitionPropertyCodeProcessorPerfmonFeatures,
+ &perfmon_features,
+ sizeof(WHV_PROCESSOR_PERFMON_FEATURES));
+ if (FAILED(hr)) {
+ error_report("WHPX: Failed to set performance "
+ "monitoring features, hr=%08lx", hr);
+ ret = -EINVAL;
+ goto error;
+ }
+ }
+
/*
* Error out if WHP doesn't support apic emulation and user is requiring
* it.
@@ -2606,8 +2642,9 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
goto error;
}
- if (whpx->kernel_irqchip_allowed && features.LocalApicEmulation &&
- whp_dispatch.WHvSetVirtualProcessorInterruptControllerState2) {
+ if (whpx->kernel_irqchip_allowed && !(whpx_is_legacy_os() && pic_enabled
+ && !whpx->kernel_irqchip_required) && features.LocalApicEmulation
+ && whp_dispatch.WHvSetVirtualProcessorInterruptControllerState2) {
WHV_X64_LOCAL_APIC_EMULATION_MODE mode =
WHvX64LocalApicEmulationModeX2Apic;
hr = whp_dispatch.WHvSetPartitionProperty(
@@ -2669,34 +2706,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
goto error;
}
- /* Enable supported performance monitoring capabilities */
- hr = whp_dispatch.WHvGetCapability(
- WHvCapabilityCodeProcessorPerfmonFeatures, &perfmon_features,
- sizeof(WHV_PROCESSOR_PERFMON_FEATURES), &whpx_cap_size);
- /*
- * Relying on this is a crutch to maintain Windows 10 support.
- *
- * WHvCapabilityCodeProcessorPerfmonFeatures and
- * WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks
- * are implemented starting from Windows Server 2022 (build 20348).
- */
- if (FAILED(hr)) {
- warn_report("WHPX: Failed to get performance "
- "monitoring features, hr=%08lx", hr);
- is_modern_os = false;
- } else {
- hr = whp_dispatch.WHvSetPartitionProperty(
- whpx->partition,
- WHvPartitionPropertyCodeProcessorPerfmonFeatures,
- &perfmon_features,
- sizeof(WHV_PROCESSOR_PERFMON_FEATURES));
- if (FAILED(hr)) {
- error_report("WHPX: Failed to set performance "
- "monitoring features, hr=%08lx", hr);
- ret = -EINVAL;
- goto error;
- }
- }
/* Enable synthetic processor features */
WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS synthetic_features;