Skip to content

Commit 473d79b

Browse files
calmisibonzini
authored andcommitted
i386/cpu: Hoist check of CPUID_EXT3_TOPOEXT against threads_per_core
Now it changes to use env->topo_info.threads_per_core and doesn't depend on qemu_init_vcpu() anymore. Put it together with other feature checks before qemu_init_vcpu() Signed-off-by: Xiaoyao Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 84b71a1 commit 473d79b

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

target/i386/cpu.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7883,6 +7883,21 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
78837883
*/
78847884
cpu->mwait.ecx |= CPUID_MWAIT_EMX | CPUID_MWAIT_IBE;
78857885

7886+
/*
7887+
* Most Intel and certain AMD CPUs support hyperthreading. Even though QEMU
7888+
* fixes this issue by adjusting CPUID_0000_0001_EBX and CPUID_8000_0008_ECX
7889+
* based on inputs (sockets,cores,threads), it is still better to give
7890+
* users a warning.
7891+
*/
7892+
if (IS_AMD_CPU(env) &&
7893+
!(env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_TOPOEXT) &&
7894+
env->topo_info.threads_per_core > 1) {
7895+
warn_report_once("This family of AMD CPU doesn't support "
7896+
"hyperthreading(%d). Please configure -smp "
7897+
"options properly or try enabling topoext "
7898+
"feature.", env->topo_info.threads_per_core);
7899+
}
7900+
78867901
/* For 64bit systems think about the number of physical bits to present.
78877902
* ideally this should be the same as the host; anything other than matching
78887903
* the host can cause incorrect guest behaviour.
@@ -7987,21 +8002,6 @@ static void x86_cpu_realizefn(DeviceState *dev, Error **errp)
79878002
x86_cpu_gdb_init(cs);
79888003
qemu_init_vcpu(cs);
79898004

7990-
/*
7991-
* Most Intel and certain AMD CPUs support hyperthreading. Even though QEMU
7992-
* fixes this issue by adjusting CPUID_0000_0001_EBX and CPUID_8000_0008_ECX
7993-
* based on inputs (sockets,cores,threads), it is still better to give
7994-
* users a warning.
7995-
*/
7996-
if (IS_AMD_CPU(env) &&
7997-
!(env->features[FEAT_8000_0001_ECX] & CPUID_EXT3_TOPOEXT) &&
7998-
env->topo_info.threads_per_core > 1) {
7999-
warn_report_once("This family of AMD CPU doesn't support "
8000-
"hyperthreading(%d). Please configure -smp "
8001-
"options properly or try enabling topoext "
8002-
"feature.", env->topo_info.threads_per_core);
8003-
}
8004-
80058005
#ifndef CONFIG_USER_ONLY
80068006
x86_cpu_apic_realize(cpu, &local_err);
80078007
if (local_err != NULL) {

0 commit comments

Comments
 (0)