From: Mohamed Mediouni <[email protected]> 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]> --- target/i386/whpx/whpx-all.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 285740bae87..2863224cd2e 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; -- 2.53.0
