From: Imre Kaloz <kaloz@kernel.org>
To: Andreas Larsson <andreas@gaisler.com>, sparclinux@vger.kernel.org
Cc: "David S . Miller" <davem@davemloft.net>,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Magnus Lindholm <linmag7@gmail.com>,
Sang-Heon Jeon <ekffu200098@gmail.com>
Subject: [PATCH v2] sparc32: don't clear the nocache pool through the PROM mappings
Date: Wed, 4 Nov 2026 10:20:22 +0100 [thread overview]
Message-ID: <20261104092022.5837-1-kaloz@kernel.org> (raw)
srmmu_nocache_init() runs before the switch to srmmu_swapper_pg_dir, so
lowmem is reached through the PROM mappings inherited for KERNBASE,
which end at 10MB on a SPARCstation 20. The pool, up to 5MB and
allocated right above the kernel, was cleared there by
memblock_alloc_or_panic(). Once the kernel image ends above 5MB the
clear runs past the window, faults, and the boot CPU enters error mode.
Every user of the pool clears what it allocates, so allocate the pool
with memblock_alloc_raw(), after the bitmap so the bitmap lands below it.
This has been broken since 2.4.0-test2pre2.
Cc: stable@vger.kernel.org
Signed-off-by: Imre Kaloz <kaloz@kernel.org>
---
Changes in v2:
- Rebased onto sparc for-next, where "sparc32: remove redundant memset
in srmmu_nocache_init()" already dropped the memset(); the pool is
still cleared once by memblock_alloc_or_panic().
- v1: https://lore.kernel.org/sparclinux/20260927005801.8338-1-kaloz@kernel.org/
No Fixes: tag: this has been broken since 2.4.0-test2pre2, before the
git history.
arch/sparc/mm/srmmu.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/arch/sparc/mm/srmmu.c b/arch/sparc/mm/srmmu.c
index 337987e021d4..f0fb7b33c3e3 100644
--- a/arch/sparc/mm/srmmu.c
+++ b/arch/sparc/mm/srmmu.c
@@ -263,14 +263,24 @@ static void __init srmmu_nocache_init(void)
bitmap_bits = srmmu_nocache_size >> SRMMU_NOCACHE_BITMAP_SHIFT;
- srmmu_nocache_pool = memblock_alloc_or_panic(srmmu_nocache_size,
- SRMMU_NOCACHE_ALIGN_MAX);
-
srmmu_nocache_bitmap =
memblock_alloc_or_panic(BITS_TO_LONGS(bitmap_bits) * sizeof(long),
SMP_CACHE_BYTES);
bit_map_init(&srmmu_nocache_map, srmmu_nocache_bitmap, bitmap_bits);
+ /*
+ * Until the switch to srmmu_swapper_pg_dir, lowmem is only reachable
+ * through the PROM's mappings, which may end below the top of the pool
+ * (at 10MB on the SPARCstation 20). Allocate the pool after the bitmap
+ * so the bitmap stays below it, and leave it uncleared: every user of
+ * the pool clears what it allocates.
+ */
+ srmmu_nocache_pool = memblock_alloc_raw(srmmu_nocache_size,
+ SRMMU_NOCACHE_ALIGN_MAX);
+ if (!srmmu_nocache_pool)
+ panic("%s: Failed to allocate %lu bytes\n", __func__,
+ srmmu_nocache_size);
+
srmmu_swapper_pg_dir = __srmmu_get_nocache(SRMMU_PGD_TABLE_SIZE, SRMMU_PGD_TABLE_SIZE);
memset(__nocache_fix(srmmu_swapper_pg_dir), 0, SRMMU_PGD_TABLE_SIZE);
init_mm.pgd = srmmu_swapper_pg_dir;
base-commit: c95443b98771a74c6689f5e7bbc56794fe95f550
--
2.47.3
reply other threads:[~2026-11-04 9:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261104092022.5837-1-kaloz@kernel.org \
--to=kaloz@kernel.org \
--cc=andreas@gaisler.com \
--cc=davem@davemloft.net \
--cc=ekffu200098@gmail.com \
--cc=linmag7@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sparclinux@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®