Skip to contentSkip to conversation

sparc32: don't clear the nocache pool through the PROM mappings

PATCH New Imre Kaloz 1 participant 1 message Nov 4

Subsystems (2)
lore
Share & tools
lore

Imre Kaloz

author
#0 lore raw

PATCH v2 1/1 sparc32: don't clear the nocache pool through the PROM mappings

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.

---
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/[email protected]/

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(-)
arch/sparc/mm/srmmu.c +13 -3
index 337987e021d4..f0fb7b33c3e3 100644
@@ -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

Signature · 1 line
2.47.3