* [PATCH v2] sparc32: don't clear the nocache pool through the PROM mappings
@ 2026-11-04 9:20 Imre Kaloz
0 siblings, 0 replies; only message in thread
From: Imre Kaloz @ 2026-11-04 9:20 UTC (permalink / raw)
To: Andreas Larsson, sparclinux
Cc: David S . Miller, linux-kernel, stable, Magnus Lindholm, Sang-Heon Jeon
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-04 9:21 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-04 9:20 [PATCH v2] sparc32: don't clear the nocache pool through the PROM mappings Imre Kaloz
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®