Skip to content

NetBSD fails to boot with smp for legacy Intel CPUs

This is the bug reported in NetBSD community: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1107104

For both 32 bits and 64 bits x86 QEMU, legacy intel CPUs can't boot NetBSD successfully if there's more than 1 threads per package.

Some modules can't be loaded (reported by @mjt0k ):

Choose an option; RETURN for default; SPACE to stop countdown. Option 1 will be chosen in 0 seconds. 20389236+589100+746196 [919406+939408+1024752]=0x17787ac WARNING: couldn't open /var/db/entropy-file Loading /stand/i386/10.1/modules/cd9660/cd9660.kmod WARNING: 1 module failed to load ESC[2JESCcESC[?7lESC[2JESC[0mSeaBIOS (version 1.16.3-debian-1.16.3-2)

And thanks to @mjt0k 's help, it can be confirmed that bug is caused by the commit 88dd4ca0 ("i386/cpu: Use APIC ID info to encode cache topo in CPUID[4]"), and is fixed by the commit f985a119 ("i386/cpu: Fix number of addressable IDs field for CPUID.01H.EBX[23:16]").

This is because NetBSD calculates smt information via lp_max / core_max, where lp_max is from CPUID[0x1].EBX.bits[16-23] and core_max is from CPUID[0x4].0x0.bits[26-31], for legacy Intel CPUs which doesn't support 0xb leaf.

The commit 88dd4ca0 changes the encoding rule of core_max and the commit f985a119 updates the rule for lp_max. Only when the encoding rules of these 2 fields are matched, then the smt information can be correct. And the smt info could affect the NetBSD loading.

Therefore, we need to backport the commit f985a119 to previous stable QEMU.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information