Skip to content

Commit 99a637a

Browse files
calmisibonzini
authored andcommitted
i386/cpu: Set and track CPUID_EXT3_CMP_LEG in env->features[FEAT_8000_0001_ECX]
The correct usage is tracking and maintaining features in env->features[] instead of manually set it in cpu_x86_cpuid(). Signed-off-by: Xiaoyao Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent c6bd2dd commit 99a637a

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

target/i386/cpu.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6953,17 +6953,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
69536953
*ecx = env->features[FEAT_8000_0001_ECX];
69546954
*edx = env->features[FEAT_8000_0001_EDX];
69556955

6956-
/* The Linux kernel checks for the CMPLegacy bit and
6957-
* discards multiple thread information if it is set.
6958-
* So don't set it here for Intel to make Linux guests happy.
6959-
*/
6960-
if (threads_per_pkg > 1) {
6961-
if (env->cpuid_vendor1 != CPUID_VENDOR_INTEL_1 ||
6962-
env->cpuid_vendor2 != CPUID_VENDOR_INTEL_2 ||
6963-
env->cpuid_vendor3 != CPUID_VENDOR_INTEL_3) {
6964-
*ecx |= 1 << 1; /* CmpLegacy bit */
6965-
}
6966-
}
69676956
if (tcg_enabled() && env->cpuid_vendor1 == CPUID_VENDOR_INTEL_1 &&
69686957
!(env->hflags & HF_LMA_MASK)) {
69696958
*edx &= ~CPUID_EXT2_SYSCALL;
@@ -7530,6 +7519,15 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
75307519

75317520
if (x86_threads_per_pkg(&env->topo_info) > 1) {
75327521
env->features[FEAT_1_EDX] |= CPUID_HT;
7522+
7523+
/*
7524+
* The Linux kernel checks for the CMPLegacy bit and
7525+
* discards multiple thread information if it is set.
7526+
* So don't set it here for Intel to make Linux guests happy.
7527+
*/
7528+
if (!IS_INTEL_CPU(env)) {
7529+
env->features[FEAT_8000_0001_ECX] |= CPUID_EXT3_CMP_LEG;
7530+
}
75337531
}
75347532

75357533
for (i = 0; i < ARRAY_SIZE(feature_dependencies); i++) {

0 commit comments

Comments
 (0)