From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794063420; b=v4cdK5xRezPn0wXyVW7PjA0VLGH+Jaf4fjrU93hyQQmFdjUqOI1eR++Z2o/W76SnyDTq Jjdt1OTTrAE+YuUZDA/AprEZaiV/NvTFKShbflTkGnHdwxpiDBdSHQ9IrP07F4SUsI+T1 Twol4mn/LNQ+UQN9tIlxiYvecUagZYQnv53D+/5FszYvqM4BxClvBX1xYqp271kWLF6Im m39PQV7vHAuHr0UnjFGzcGboU8ubB+fG9jUKBCthW7XGkuYHmtpiYClbqm1tcknunpRq7 QUl7QqRxIqMkFTeUfSWeP2B79dPBm2geyWo/suG5BG2azPdsSBKkfdxgITBGS56GXyA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794063420; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=m9+ETSvqU0GYDoXqdDvQ9blqgYT+IJ5BKrUs8BkfdpU=; b=CLKGIIVwy0YDRGrr4iqI1eZivbnr7kcS2EVnN6EgH3kGngP75zIe0e2mAewT5SfgvwXn lGU5A/3hyDxbzUgE1bipsW4iLFeeAEDCUvSRui7fKHT8gxdBWZV0Xi1QHt8Eb2dHo0ZoA 0MCT9om4UDx1ZDu4OarqwyfiTbScKvFtk78bbvb+QjdN3MeyPE4SKlv27VTdF49kKR5+C vJ4tJV9w4x1qpPTCswCG/IwvyPkZ4UpDkr/LtM7HcFUkH0brj/dZQpudOvao7fP0sJ8GH 5eOjwIdl6R9UUqf1wKKTe+PpEqzjcyoMrf/A8S92r+Tg2srHO1YwznN1WZzlgePQbnw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=CY8iw962; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78390606D80D; Sat, 7 Nov 2026 14:57:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=CY8iw962 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 078631F0089F; Sat, 7 Nov 2026 14:56:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1794063420; bh=m9+ETSvqU0GYDoXqdDvQ9blqgYT+IJ5BKrUs8BkfdpU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CY8iw962bPBmEGxBB3/XsChjTdxjhF1L4w+COXxlNGB3ArP5oaq+WhZT8wKMUjFvy rrkFvCjElP7btY877KAGkX0GJRssGXdTneMvoIhtBwum4+X8Ji2LH/q67QuyDk0hJj KJgyXzvmtVI2G9FaPLJkKa8nfOAfP4qSi666NS1s= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sebastian Andrzej Siewior , Karl Mehltretter , Russell King , Sasha Levin Subject: [PATCH 6.18 560/869] ARM: 9522/1: cacheinfo: guard the CLIDR read in populate_cache_leaves() Date: Sat, 7 Nov 2026 08:54:02 -0500 Message-ID: <20261107134912.297562593@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261107134852.069646174@linuxfoundation.org> References: <20261107134852.069646174@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Karl Mehltretter [ Upstream commit 2315f2c46e0813d010e7b3ea40f2769621453e27 ] ARM1176 and ARM11 MPCore can be reported as ARMv7 by cpu_architecture() even though they lack CLIDR. populate_cache_leaves() therefore needs the CTR-format check used by detect_cache_level(). DT-based early allocation bypasses init_cache_level(), so its check no longer protects populate_cache_leaves(). A combined ARMv6/ARMv7 SMP kernel can reach this path on BCM2835, whose DT describes its caches. Share the CLIDR capability check between detection and population. Return -ENOENT from population when CLIDR is unavailable, preserving the existing absence of cacheinfo and avoiding a new topology warning. Assisted-by: LLM Cc: stable@vger.kernel.org Tested-by: Sebastian Andrzej Siewior Link: https://lore.kernel.org/r/20260912195552.76673-4-kmehltretter@gmail.com/ Signed-off-by: Karl Mehltretter Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/kernel/cacheinfo.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/arch/arm/kernel/cacheinfo.c b/arch/arm/kernel/cacheinfo.c index 31591c9472548..993c8a1347860 100644 --- a/arch/arm/kernel/cacheinfo.c +++ b/arch/arm/kernel/cacheinfo.c @@ -80,19 +80,21 @@ static void ci_leaf_init(struct cacheinfo *this_leaf, this_leaf->type = type; } -static int detect_cache_level(unsigned int *level_p, unsigned int *leaves_p) +static bool clidr_present(void) { - unsigned int ctype, level, leaves; - u32 ctr, format; - /* CLIDR is not present before ARMv7/v7m */ if (cpu_architecture() < CPU_ARCH_ARMv7) - return -EOPNOTSUPP; + return false; /* Don't try reading CLIDR if CTR declares old format */ - ctr = read_cpuid_cachetype(); - format = FIELD_GET(CTR_FORMAT_MASK, ctr); - if (format != CTR_FORMAT_ARMV7) + return FIELD_GET(CTR_FORMAT_MASK, read_cpuid_cachetype()) == CTR_FORMAT_ARMV7; +} + +static int detect_cache_level(unsigned int *level_p, unsigned int *leaves_p) +{ + unsigned int ctype, level, leaves; + + if (!clidr_present()) return -EOPNOTSUPP; for (level = 1, leaves = 0; level <= MAX_CACHE_LEVEL; level++) { @@ -150,11 +152,10 @@ int populate_cache_leaves(unsigned int cpu) enum cache_type type; struct cpu_cacheinfo *this_cpu_ci = get_cpu_cacheinfo(cpu); struct cacheinfo *infos = this_cpu_ci->info_list; - unsigned int arch = cpu_architecture(); - /* CLIDR is not present before ARMv7/v7m */ - if (arch < CPU_ARCH_ARMv7) - return -EOPNOTSUPP; + /* The device tree can describe caches CLIDR cannot fill in. */ + if (!clidr_present()) + return -ENOENT; for (idx = 0, level = 1; level <= this_cpu_ci->num_levels && idx < this_cpu_ci->num_leaves; level++) { -- 2.53.0