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>
Mohamed Mediouni committed
Apr 22, 2026 at 23:41 UTC
3b124791bdcea9d5a2fd74db5dcd5ba24cceb843
1 file changed
+39
-30
target/i386/whpx/whpx-all.c
+39
-30
@@ -2523,6 +2523,13 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2523
0x80000002, 0x80000003, 0x80000004, 0x80000007, 0x80000008,
2524
0x8000000A, 0x80000021, 0x80000022, 0xC0000000, 0xC0000001};
2525
2526
+ X86MachineState *x86ms = X86_MACHINE(ms);
2527
+ bool pic_enabled = false;
2528
+
2529
+ if (x86ms->pic == ON_OFF_AUTO_ON || x86ms->pic == ON_OFF_AUTO_AUTO) {
2530
+ pic_enabled = true;
2531
+ }
2532
+
2533
whpx = &whpx_global;
2534
2535
if (!init_whp_dispatch()) {
@@ -2594,6 +2601,35 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2601
goto error;
2602
}
2603
2604
+ /* Enable supported performance monitoring capabilities */
2605
+ hr = whp_dispatch.WHvGetCapability(
2606
+ WHvCapabilityCodeProcessorPerfmonFeatures, &perfmon_features,
2607
+ sizeof(WHV_PROCESSOR_PERFMON_FEATURES), &whpx_cap_size);
2608
+ /*
2609
+ * Relying on this is a crutch to maintain Windows 10 support.
2610
+ *
2611
+ * WHvCapabilityCodeProcessorPerfmonFeatures and
2612
+ * WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks
2613
+ * are implemented starting from Windows Server 2022 (build 20348).
2614
+ */
2615
+ if (FAILED(hr)) {
2616
+ warn_report("WHPX: Failed to get performance "
2617
+ "monitoring features, hr=%08lx", hr);
2618
+ is_modern_os = false;
2619
+ } else {
2620
+ hr = whp_dispatch.WHvSetPartitionProperty(
2621
+ whpx->partition,
2622
+ WHvPartitionPropertyCodeProcessorPerfmonFeatures,
2623
+ &perfmon_features,
2624
+ sizeof(WHV_PROCESSOR_PERFMON_FEATURES));
2625
+ if (FAILED(hr)) {
2626
+ error_report("WHPX: Failed to set performance "
2627
+ "monitoring features, hr=%08lx", hr);
2628
+ ret = -EINVAL;
2629
+ goto error;
2630
+ }
2631
+ }
2632
+
2633
/*
2634
* Error out if WHP doesn't support apic emulation and user is requiring
2635
* it.
@@ -2606,8 +2642,9 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2642
goto error;
2643
}
2644
2609
- if (whpx->kernel_irqchip_allowed && features.LocalApicEmulation &&
2610
- whp_dispatch.WHvSetVirtualProcessorInterruptControllerState2) {
2645
+ if (whpx->kernel_irqchip_allowed && !(whpx_is_legacy_os() && pic_enabled
2646
+ && !whpx->kernel_irqchip_required) && features.LocalApicEmulation
2647
+ && whp_dispatch.WHvSetVirtualProcessorInterruptControllerState2) {
2648
WHV_X64_LOCAL_APIC_EMULATION_MODE mode =
2649
WHvX64LocalApicEmulationModeX2Apic;
2650
hr = whp_dispatch.WHvSetPartitionProperty(
@@ -2669,34 +2706,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2706
goto error;
2707
}
2708
2672
- /* Enable supported performance monitoring capabilities */
2673
- hr = whp_dispatch.WHvGetCapability(
2674
- WHvCapabilityCodeProcessorPerfmonFeatures, &perfmon_features,
2675
- sizeof(WHV_PROCESSOR_PERFMON_FEATURES), &whpx_cap_size);
2676
- /*
2677
- * Relying on this is a crutch to maintain Windows 10 support.
2678
- *
2679
- * WHvCapabilityCodeProcessorPerfmonFeatures and
2680
- * WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks
2681
- * are implemented starting from Windows Server 2022 (build 20348).
2682
- */
2683
- if (FAILED(hr)) {
2684
- warn_report("WHPX: Failed to get performance "
2685
- "monitoring features, hr=%08lx", hr);
2686
- is_modern_os = false;
2687
- } else {
2688
- hr = whp_dispatch.WHvSetPartitionProperty(
2689
- whpx->partition,
2690
- WHvPartitionPropertyCodeProcessorPerfmonFeatures,
2691
- &perfmon_features,
2692
- sizeof(WHV_PROCESSOR_PERFMON_FEATURES));
2693
- if (FAILED(hr)) {
2694
- error_report("WHPX: Failed to set performance "
2695
- "monitoring features, hr=%08lx", hr);
2696
- ret = -EINVAL;
2697
- goto error;
2698
- }
2699
- }
2709
2710
/* Enable synthetic processor features */
2711
WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS synthetic_features;