@samitouri / QOSamiQemu / commits / 8b87283ce4

whpx: i386: enable all supported host features

Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Link: https://lore.kernel.org/r/20260228214704.19048-3-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Mohamed Mediouni committed Feb 28, 2026 at 22:46 UTC 8b87283ce4c58cb2da64be4690711205d137eb3c
1 file changed +40
target/i386/whpx/whpx-all.c
+40
@@ -2022,6 +2022,7 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2022 UINT32 whpx_cap_size;
2023 WHV_PARTITION_PROPERTY prop;
2024 WHV_CAPABILITY_FEATURES features = {0};
2025 + WHV_PROCESSOR_FEATURES_BANKS processor_features;
2026
2027 whpx = &whpx_global;
2028
@@ -2127,6 +2128,45 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2128 }
2129 }
2130
2131 + /* Set all the supported features, to follow the MSHV example */
2132 + memset(&processor_features, 0, sizeof(WHV_PROCESSOR_FEATURES_BANKS));
2133 + processor_features.BanksCount = 2;
2134 +
2135 + hr = whp_dispatch.WHvGetCapability(
2136 + WHvCapabilityCodeProcessorFeaturesBanks, &processor_features,
2137 + sizeof(WHV_PROCESSOR_FEATURES_BANKS), &whpx_cap_size);
2138 + if (FAILED(hr)) {
2139 + error_report("WHPX: Failed to get processor features, hr=%08lx", hr);
2140 + ret = -ENOSPC;
2141 + goto error;
2142 + }
2143 +
2144 + if (processor_features.Bank1.NestedVirtSupport) {
2145 + memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
2146 + prop.NestedVirtualization = 1;
2147 + hr = whp_dispatch.WHvSetPartitionProperty(
2148 + whpx->partition,
2149 + WHvPartitionPropertyCodeNestedVirtualization,
2150 + &prop,
2151 + sizeof(WHV_PARTITION_PROPERTY));
2152 + if (FAILED(hr)) {
2153 + error_report("WHPX: Failed to enable nested virtualization, hr=%08lx", hr);
2154 + ret = -EINVAL;
2155 + goto error;
2156 + }
2157 + }
2158 +
2159 + hr = whp_dispatch.WHvSetPartitionProperty(
2160 + whpx->partition,
2161 + WHvPartitionPropertyCodeProcessorFeaturesBanks,
2162 + &processor_features,
2163 + sizeof(WHV_PROCESSOR_FEATURES_BANKS));
2164 + if (FAILED(hr)) {
2165 + error_report("WHPX: Failed to set processor features, hr=%08lx", hr);
2166 + ret = -EINVAL;
2167 + goto error;
2168 + }
2169 +
2170 /* Register for MSR and CPUID exits */
2171 memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
2172 prop.ExtendedVmExits.X64MsrExit = 1;