]> git.baikalelectronics.ru Git - kernel.git/commit
cacheinfo: Fix shared_cpu_map to handle shared caches at different levels
authorYong-Xuan Wang <yongxuan.wang@sifive.com>
Tue, 17 Jan 2023 10:51:33 +0000 (10:51 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 11 Mar 2023 12:55:34 +0000 (13:55 +0100)
commitdd7428d8b81de878b191dccfcc69f7679ca95f93
treea4eb969015af851c6c8d606cf2e489f63c2b9e3e
parent9bd9423a7f6adb308d823883df990cd922c7cd90
cacheinfo: Fix shared_cpu_map to handle shared caches at different levels

[ Upstream commit 862d3adfd5356b4c7e0ea1193652b3f3ff9719d4 ]

The cacheinfo sets up the shared_cpu_map by checking whether the caches
with the same index are shared between CPUs. However, this will trigger
slab-out-of-bounds access if the CPUs do not have the same cache hierarchy.
Another problem is the mismatched shared_cpu_map when the shared cache does
not have the same index between CPUs.

CPU0 I D L3
index 0 1 2 x
^ ^ ^ ^
index 0 1 2 3
CPU1 I D L2 L3

This patch checks each cache is shared with all caches on other CPUs.

Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
Signed-off-by: Yong-Xuan Wang <yongxuan.wang@sifive.com>
Link: https://lore.kernel.org/r/20230117105133.4445-2-yongxuan.wang@sifive.com
Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/base/cacheinfo.c