Skip to content

Commit c6bd2dd

Browse files
calmisibonzini
authored andcommitted
i386/cpu: Set up CPUID_HT in x86_cpu_expand_features() instead of cpu_x86_cpuid()
Currently CPUID_HT is evaluated in cpu_x86_cpuid() each time. It's not a correct usage of how feature bit is maintained and evaluated. The expected practice is that features are tracked in env->features[] and cpu_x86_cpuid() should be the consumer of env->features[]. Track CPUID_HT in env->features[FEAT_1_EDX] instead and evaluate it in cpu's realizefn(). Signed-off-by: Xiaoyao Li <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 6e090ff commit c6bd2dd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

target/i386/cpu.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6538,7 +6538,6 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
65386538
*edx = env->features[FEAT_1_EDX];
65396539
if (threads_per_pkg > 1) {
65406540
*ebx |= threads_per_pkg << 16;
6541-
*edx |= CPUID_HT;
65426541
}
65436542
if (!cpu->enable_pmu) {
65446543
*ecx &= ~CPUID_EXT_PDCM;
@@ -7529,6 +7528,10 @@ void x86_cpu_expand_features(X86CPU *cpu, Error **errp)
75297528
}
75307529
}
75317530

7531+
if (x86_threads_per_pkg(&env->topo_info) > 1) {
7532+
env->features[FEAT_1_EDX] |= CPUID_HT;
7533+
}
7534+
75327535
for (i = 0; i < ARRAY_SIZE(feature_dependencies); i++) {
75337536
FeatureDep *d = &feature_dependencies[i];
75347537
if (!(env->features[d->from.index] & d->from.mask)) {

0 commit comments

Comments
 (0)