Skip to content

Commit 8251738

Browse files
trueptolemyMichael Tokarev
authored andcommitted
i386/cpu: Honor maximum value for CPUID.8000001DH.EAX[25:14]
CPUID.8000001DH:EAX[25:14] is "NumSharingCache", and the number of logical processors sharing this cache is the value of this field incremented by 1. Because of its width limitation, the maximum value currently supported is 4095. Though at present Q35 supports up to 4096 CPUs, by constructing a specific topology, the width of the APIC ID can be extended beyond 12 bits. For example, using `-smp threads=33,cores=9,modules=9` results in a die level offset of 6 + 4 + 4 = 14 bits, which can also cause overflow. Check and honor the maximum value as CPUID.04H did. Cc: Babu Moger <[email protected]> Signed-off-by: Zhao Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]> (cherry picked from commit 5d21ee453ad8e3f95f75e542cb3b35c5bb7cf23a) Signed-off-by: Michael Tokarev <[email protected]>
1 parent 1822478 commit 8251738

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

target/i386/cpu.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,8 @@ static void encode_cache_cpuid8000001d(CPUCacheInfo *cache,
496496

497497
*eax = CACHE_TYPE(cache->type) | CACHE_LEVEL(cache->level) |
498498
(cache->self_init ? CACHE_SELF_INIT_LEVEL : 0);
499-
*eax |= max_thread_ids_for_cache(topo_info, cache->share_level) << 14;
499+
/* Bits 25:14 - NumSharingCache: maximum 4095. */
500+
*eax |= MIN(max_thread_ids_for_cache(topo_info, cache->share_level), 4095) << 14;
500501

501502
assert(cache->line_size > 0);
502503
assert(cache->partitions > 0);

0 commit comments

Comments
 (0)