Skip to content

Commit 370a7dc

Browse files
filipleplemkopec
authored andcommitted
arch/x86/smbios.c: fix incorrect L3 cache size in SMBIOS Type 7
L3 cache is typically unified and shared across all logical CPUs. The CPUID leaf 0x4 already reports the total cache size for such shared caches. Multiplying L3 size by the number of cores sharing it results in an inflated value that may exceed SMBIOS limits or be misinterpreted, leading Windows and other OSes to report the L3 cache size as zero. Upstream-Status: Pending Signed-off-by: Filip Lewiński <[email protected]>
1 parent 121fc4f commit 370a7dc

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/arch/x86/smbios.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,20 @@ int smbios_write_type7_cache_parameters(unsigned long *current,
240240
const u8 level = info.level;
241241
const size_t assoc = info.num_ways;
242242
const size_t cache_share = info.num_cores_shared;
243-
const size_t cache_size = info.size * get_number_of_caches(cache_share);
243+
244+
/*
245+
* In the case of unified L3 cache, the info_size is already the correct
246+
* total size. Multiplying by number of cores is unnecessary and might result
247+
* in the cache displaying as zero.
248+
*/
249+
size_t tmp_cache_size;
250+
if (level < 3) {
251+
tmp_cache_size = info.size * get_number_of_caches(cache_share);
252+
}
253+
else {
254+
tmp_cache_size = info.size;
255+
}
256+
const size_t cache_size = tmp_cache_size;
244257

245258
if (!cache_type)
246259
/* No more caches in the system */

0 commit comments

Comments
 (0)