You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/target/i386
Zhao Liu 4e5d58969e target/i386/cpu: Move addressable ID encoding out of compat property in CPUID[0x1]
Currently, the addressable ID encoding for CPUID[0x1].EBX[bits 16-23]
(Maximum number of addressable IDs for logical processors in this
physical package) is covered by vendor_cpuid_only_v2 compat property.
The previous consideration was to avoid breaking migration and this
compat property makes it unfriendly to backport the commit f985a1195b
("i386/cpu: Fix number of addressable IDs field for CPUID.01H.EBX
[23:16]").

However, NetBSD booting is broken since the commit 88dd4ca06c
("i386/cpu: Use APIC ID info to encode cache topo in CPUID[4]"),
because NetBSD calculates smt information via `lp_max` / `core_max` for
legacy Intel CPUs which doesn't support 0xb leaf, where `lp_max` is from
CPUID[0x1].EBX.bits[16-23] and `core_max` is from CPUID[0x4].0x0.bits[26
-31].

The commit 88dd4ca0 changed the encoding rule of `core_max` but didn't
update `lp_max`, so that NetBSD would get the wrong smt information,
which leads to the module loading failure.

Luckily, the commit f985a1195b ("i386/cpu: Fix number of addressable
IDs field for CPUID.01H.EBX[23:16]") updated the encoding rule for
`lp_max` and accidentally fixed the NetBSD issue too. This also shows
that using CPUID[0x1] and CPUID[0x4].0x0 to calculate HT/SMT information
is a common practice to detect CPU topology on legacy Intel CPUs.

Therefore, it's necessary to backport the commit f985a1195b to
previous stable QEMU to help address the similar issues as well. Then
the compat property is not needed any more since all stable QEMUs will
follow the same encoding way.

So, in CPUID[0x1], move addressable ID encoding out of compat property.

Reported-by: Michael Tokarev <mjt@tls.msk.ru>
Inspired-by: Chuang Xu <xuchuangxclwt@bytedance.com>
Fixes: commit f985a1195b ("i386/cpu: Fix number of addressable IDs field for CPUID.01H.EBX[23:16]")
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3061
Signed-off-by: Zhao Liu <zhao1.liu@intel.com>
Reviewed-by: Michael Tokarev <mjt@tls.msk.ru>
Tested-by: Michael Tokarev <mjt@tls.msk.ru>
Message-ID: <20250804053548.1808629-1-zhao1.liu@intel.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
6 days ago
..
emulate target/i386/emulate: replace FSF postal address with licenses URL 2 months ago
hvf target/i386: merge host_cpu_instance_init() and host_cpu_max_instance_init() 1 month ago
kvm i386/tdx: Remove the redundant qemu_mutex_init(&tdx->lock) 4 weeks ago
nvmm Accelerators patches 4 weeks ago
tcg target/i386: fix width of third operand of VINSERTx128 2 weeks ago
whpx Accelerators patches 4 weeks ago
Kconfig i386: select correct components for no-board build 1 year ago
arch_dump.c include: Rename sysemu/ -> system/ 8 months ago
arch_memory_mapping.c exec/cpu-all: remove system/memory include 4 months ago
confidential-guest.c qom: Have class_init() take a const data argument 4 months ago
confidential-guest.h i386/cgs: Introduce x86_confidential_guest_check_features() 3 months ago
cpu-apic.c include/system: Move exec/address-spaces.h to system/address-spaces.h 4 months ago
cpu-dump.c target/i386: remove CC_OP_CLR 9 months ago
cpu-internal.h include: Rename sysemu/ -> system/ 8 months ago
cpu-param.h tcg: Remove the TCG_GUEST_DEFAULT_MO definition globally 4 months ago
cpu-qom.h target: Move ArchCPUClass definition to 'cpu.h' 2 years ago
cpu-system.c qapi: make most CPU commands unconditionally available 3 months ago
cpu.c target/i386/cpu: Move addressable ID encoding out of compat property in CPUID[0x1] 6 days ago
cpu.h i386/cpu: Use a unified cache_info in X86CPUState 1 month ago
gdbstub.c target/i386/gdbstub: Expose orig_ax 10 months ago
helper.c tcg: Define INSN_START_WORDS as constant 3 3 months ago
helper.h target/i386: optimize computation of ZF from CC_OP_DYNAMIC 9 months ago
host-cpu.c i386/cpu: Unify family, model and stepping calculation for x86 CPU 1 month ago
host-cpu.h i386/cpu: Cleanup host_cpu_max_instance_init() 4 weeks ago
machine.c hw/i386/x86: Remove X86MachineClass::save_tsc_khz field 2 months ago
meson.build target/i386: nvmm, whpx: add accel/CPU class that sets host vendor 1 month ago
monitor.c qapi: remove the misc-target.json file 3 months ago
ops_sse.h target/i386: Use correct type for get_float_exception_flags() values 2 months ago
sev-system-stub.c qapi: make SEV commands unconditionally available 3 months ago
sev.c sev: Provide sev_features flags from IGVM VMSA to KVM_SEV_INIT2 1 month ago
sev.h i386/sev: Add implementation of CGS set_guest_policy() 1 month ago
svm.h target/i386: check intercept for XSETBV 2 years ago
trace-events target/i386/sev: Use size_t for object sizes 1 year ago
trace.h trace: switch position of headers to what Meson requires 5 years ago
xsave_helper.c qemu: Declare all load/store helper in 'qemu/bswap.h' 4 weeks ago