Commit 8022c62878 for qemu.org
commit 8022c62878f9199f2f436f8058ad5504bbeca8ff
Author: Mohamed Mediouni <mohamed@unpredictable.fr>
Date: Sat Feb 28 22:46:59 2026 +0100
whpx: i386: enable synthetic processor features
At the point in time in which we setup the partition, the vCPUs
aren't available yet.
So enable them by default for now like what the MSHV backend does.
AccessFrequencyRegs is shared for both the LAPIC frequency reporting and the TSC frequency.
To still benefit from the fixed TSC frequency reporting when kernel-irqchip=off, still enable AccessFrequencyRegs anyway.
Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/r/20260228214704.19048-4-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 285740bae8..2863224cd2 100644
--- a/target/i386/whpx/whpx-all.c
+++ b/target/i386/whpx/whpx-all.c
@@ -2167,6 +2167,40 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
goto error;
}
+ /* Enable synthetic processor features */
+ WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS synthetic_features;
+ memset(&synthetic_features, 0, sizeof(WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS));
+ synthetic_features.BanksCount = 1;
+
+ synthetic_features.Bank0.HypervisorPresent = 1;
+ synthetic_features.Bank0.Hv1 = 1;
+ synthetic_features.Bank0.AccessPartitionReferenceCounter = 1;
+ synthetic_features.Bank0.AccessPartitionReferenceTsc = 1;
+ /* if kernel-irqchip=off, HV_X64_MSR_APIC_FREQUENCY = 0. */
+ synthetic_features.Bank0.AccessFrequencyRegs = 1;
+ synthetic_features.Bank0.AccessVpIndex = 1;
+ synthetic_features.Bank0.AccessHypercallRegs = 1;
+ synthetic_features.Bank0.TbFlushHypercalls = 1;
+
+ if (whpx_irqchip_in_kernel()) {
+ synthetic_features.Bank0.AccessSynicRegs = 1;
+ synthetic_features.Bank0.AccessSyntheticTimerRegs = 1;
+ synthetic_features.Bank0.AccessIntrCtrlRegs = 1;
+ synthetic_features.Bank0.SyntheticClusterIpi = 1;
+ synthetic_features.Bank0.DirectSyntheticTimers = 1;
+ }
+
+ hr = whp_dispatch.WHvSetPartitionProperty(
+ whpx->partition,
+ WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks,
+ &synthetic_features,
+ sizeof(WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS));
+ if (FAILED(hr)) {
+ error_report("WHPX: Failed to set synthetic features, hr=%08lx", hr);
+ ret = -EINVAL;
+ goto error;
+ }
+
/* Register for MSR and CPUID exits */
memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
prop.ExtendedVmExits.X64MsrExit = 1;