@samitouri / QOSamiQemu / commits / 8022c62878

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>

Mohamed Mediouni committed Feb 28, 2026 at 22:46 UTC 8022c62878f9199f2f436f8058ad5504bbeca8ff
1 file changed +34
target/i386/whpx/whpx-all.c
+34
@@ -2167,6 +2167,40 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2167 goto error;
2168 }
2169
2170 + /* Enable synthetic processor features */
2171 + WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS synthetic_features;
2172 + memset(&synthetic_features, 0, sizeof(WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS));
2173 + synthetic_features.BanksCount = 1;
2174 +
2175 + synthetic_features.Bank0.HypervisorPresent = 1;
2176 + synthetic_features.Bank0.Hv1 = 1;
2177 + synthetic_features.Bank0.AccessPartitionReferenceCounter = 1;
2178 + synthetic_features.Bank0.AccessPartitionReferenceTsc = 1;
2179 + /* if kernel-irqchip=off, HV_X64_MSR_APIC_FREQUENCY = 0. */
2180 + synthetic_features.Bank0.AccessFrequencyRegs = 1;
2181 + synthetic_features.Bank0.AccessVpIndex = 1;
2182 + synthetic_features.Bank0.AccessHypercallRegs = 1;
2183 + synthetic_features.Bank0.TbFlushHypercalls = 1;
2184 +
2185 + if (whpx_irqchip_in_kernel()) {
2186 + synthetic_features.Bank0.AccessSynicRegs = 1;
2187 + synthetic_features.Bank0.AccessSyntheticTimerRegs = 1;
2188 + synthetic_features.Bank0.AccessIntrCtrlRegs = 1;
2189 + synthetic_features.Bank0.SyntheticClusterIpi = 1;
2190 + synthetic_features.Bank0.DirectSyntheticTimers = 1;
2191 + }
2192 +
2193 + hr = whp_dispatch.WHvSetPartitionProperty(
2194 + whpx->partition,
2195 + WHvPartitionPropertyCodeSyntheticProcessorFeaturesBanks,
2196 + &synthetic_features,
2197 + sizeof(WHV_SYNTHETIC_PROCESSOR_FEATURES_BANKS));
2198 + if (FAILED(hr)) {
2199 + error_report("WHPX: Failed to set synthetic features, hr=%08lx", hr);
2200 + ret = -EINVAL;
2201 + goto error;
2202 + }
2203 +
2204 /* Register for MSR and CPUID exits */
2205 memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
2206 prop.ExtendedVmExits.X64MsrExit = 1;