]> git.ipfire.org Git - thirdparty/kernel/stable.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:50:39 +0000 (13:50 +0100)
commitdea49f2993f57d8a2df2cacb0bf649ef49b28879
tree540ac437a92c0fc928fb91360a055a9917258e72
parentcc00340fb1226a2a3a5cf15473ac417da3c952f1
cacheinfo: Fix shared_cpu_map to handle shared caches at different levels

[ Upstream commit 198102c9103fc78d8478495971947af77edb05c1 ]

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