diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 2c9517f56d..4603b2b98b 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6828,7 +6828,8 @@ void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count, } *edx = env->features[FEAT_1_EDX]; if (threads_per_pkg > 1) { - *ebx |= threads_per_pkg << 16; + /* Fixup overflow: max value for bits 23-16 is 255. */ + *ebx |= MIN(threads_per_pkg, 255) << 16; } if (!cpu->enable_pmu) { *ecx &= ~CPUID_EXT_PDCM;