whpx: i386: remove CPUID trapping
Very partial in its current state and results in significantly inconsistent CPUID data. Remove it until it's reimplemented later. Signed-off-by: Mohamed Mediouni <mohamed@unpredictable.fr> Link: https://lore.kernel.org/r/20260223233950.96076-15-mohamed@unpredictable.fr Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Mohamed Mediouni committed
Feb 24, 2026 at 00:39 UTC
2c08624db03d7f791b69e5cf6b1a4e859f6b0dd0
1 file changed
-104
target/i386/whpx/whpx-all.c
-104
@@ -1795,75 +1795,6 @@ int whpx_vcpu_run(CPUState *cpu)
1795
ret = 0;
1796
break;
1797
}
1798
- case WHvRunVpExitReasonX64Cpuid: {
1799
- WHV_REGISTER_VALUE reg_values[5];
1800
- WHV_REGISTER_NAME reg_names[5];
1801
- UINT32 reg_count = 5;
1802
- UINT64 cpuid_fn, rip = 0, rax = 0, rcx = 0, rdx = 0, rbx = 0;
1803
- X86CPU *x86_cpu = X86_CPU(cpu);
1804
- CPUX86State *env = &x86_cpu->env;
1805
-
1806
- memset(reg_values, 0, sizeof(reg_values));
1807
-
1808
- rip = vcpu->exit_ctx.VpContext.Rip +
1809
- vcpu->exit_ctx.VpContext.InstructionLength;
1810
- cpuid_fn = vcpu->exit_ctx.CpuidAccess.Rax;
1811
-
1812
- /*
1813
- * Ideally, these should be supplied to the hypervisor during VCPU
1814
- * initialization and it should be able to satisfy this request.
1815
- * But, currently, WHPX doesn't support setting CPUID values in the
1816
- * hypervisor once the partition has been setup, which is too late
1817
- * since VCPUs are realized later. For now, use the values from
1818
- * QEMU to satisfy these requests, until WHPX adds support for
1819
- * being able to set these values in the hypervisor at runtime.
1820
- */
1821
- cpu_x86_cpuid(env, cpuid_fn, 0, (UINT32 *)&rax, (UINT32 *)&rbx,
1822
- (UINT32 *)&rcx, (UINT32 *)&rdx);
1823
- switch (cpuid_fn) {
1824
- case 0x40000000:
1825
- /* Expose the vmware cpu frequency cpuid leaf */
1826
- rax = 0x40000010;
1827
- rbx = rcx = rdx = 0;
1828
- break;
1829
-
1830
- case 0x40000010:
1831
- rax = env->tsc_khz;
1832
- rbx = env->apic_bus_freq / 1000; /* Hz to KHz */
1833
- rcx = rdx = 0;
1834
- break;
1835
-
1836
- case 0x80000001:
1837
- /* Remove any support of OSVW */
1838
- rcx &= ~CPUID_EXT3_OSVW;
1839
- break;
1840
- }
1841
-
1842
- reg_names[0] = WHvX64RegisterRip;
1843
- reg_names[1] = WHvX64RegisterRax;
1844
- reg_names[2] = WHvX64RegisterRcx;
1845
- reg_names[3] = WHvX64RegisterRdx;
1846
- reg_names[4] = WHvX64RegisterRbx;
1847
-
1848
- reg_values[0].Reg64 = rip;
1849
- reg_values[1].Reg64 = rax;
1850
- reg_values[2].Reg64 = rcx;
1851
- reg_values[3].Reg64 = rdx;
1852
- reg_values[4].Reg64 = rbx;
1853
-
1854
- hr = whp_dispatch.WHvSetVirtualProcessorRegisters(
1855
- whpx->partition, cpu->cpu_index,
1856
- reg_names,
1857
- reg_count,
1858
- reg_values);
1859
-
1860
- if (FAILED(hr)) {
1861
- error_report("WHPX: Failed to set CpuidAccess state registers,"
1862
- " hr=%08lx", hr);
1863
- }
1864
- ret = 0;
1865
- break;
1866
- }
1798
case WHvRunVpExitReasonException:
1799
whpx_get_registers(cpu);
1800
@@ -2017,26 +1948,6 @@ int whpx_init_vcpu(CPUState *cpu)
1948
}
1949
}
1950
2020
- /*
2021
- * If the vmware cpuid frequency leaf option is set, and we have a valid
2022
- * tsc value, trap the corresponding cpuid's.
2023
- */
2024
- if (x86_cpu->vmware_cpuid_freq && env->tsc_khz) {
2025
- UINT32 cpuidExitList[] = {1, 0x80000001, 0x40000000, 0x40000010};
2026
-
2027
- hr = whp_dispatch.WHvSetPartitionProperty(
2028
- whpx->partition,
2029
- WHvPartitionPropertyCodeCpuidExitList,
2030
- cpuidExitList,
2031
- RTL_NUMBER_OF(cpuidExitList) * sizeof(UINT32));
2032
-
2033
- if (FAILED(hr)) {
2034
- error_report("WHPX: Failed to set partition CpuidExitList hr=%08lx",
2035
- hr);
2036
- ret = -EINVAL;
2037
- goto error;
2038
- }
2039
- }
1951
1952
vcpu->interruptable = true;
1953
cpu->vcpu_dirty = true;
@@ -2073,7 +1984,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
1984
WHV_CAPABILITY whpx_cap;
1985
UINT32 whpx_cap_size;
1986
WHV_PARTITION_PROPERTY prop;
2076
- UINT32 cpuidExitList[] = {1, 0x80000001};
1987
WHV_CAPABILITY_FEATURES features = {0};
1988
1989
whpx = &whpx_global;
@@ -2183,7 +2093,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2093
/* Register for MSR and CPUID exits */
2094
memset(&prop, 0, sizeof(WHV_PARTITION_PROPERTY));
2095
prop.ExtendedVmExits.X64MsrExit = 1;
2186
- prop.ExtendedVmExits.X64CpuidExit = 1;
2096
prop.ExtendedVmExits.ExceptionExit = 1;
2097
if (whpx_irqchip_in_kernel()) {
2098
prop.ExtendedVmExits.X64ApicInitSipiExitTrap = 1;
@@ -2200,19 +2109,6 @@ int whpx_accel_init(AccelState *as, MachineState *ms)
2109
goto error;
2110
}
2111
2203
- hr = whp_dispatch.WHvSetPartitionProperty(
2204
- whpx->partition,
2205
- WHvPartitionPropertyCodeCpuidExitList,
2206
- cpuidExitList,
2207
- RTL_NUMBER_OF(cpuidExitList) * sizeof(UINT32));
2208
-
2209
- if (FAILED(hr)) {
2210
- error_report("WHPX: Failed to set partition CpuidExitList hr=%08lx",
2211
- hr);
2212
- ret = -EINVAL;
2213
- goto error;
2214
- }
2215
-
2112
/*
2113
* We do not want to intercept any exceptions from the guest,
2114
* until we actually start debugging with gdb.