[PATCH 1/5] ARM: NOMMU: pmsa-v7: Do not probe the region order on M-class
From: Brad Hawthorne
Date: Tue Nov 24 2026 - 21:58:49 EST
__mpu_min_region_order() finds the minimum region size by writing
0xFFFFFFFC to the region base register and reading it back. That
works on R-class, where the low bits are reserved. On M-class,
MPU_RBAR bits [4:0] are VALID and REGION, so the write selects region
12, which an MPU with fewer than 13 regions does not have. QEMU
(mps2-an385, 8 regions) logs "MPU region out of range 12/8", the
read-back is 0, every RAM region fails, and the kernel panics:
Kernel panic - not syncing: MPU region initialization failure! -12
Region 12 is outside the permitted values on hardware too. If the write
lands, the read-back returns the current region number in bits [3:0]
(MPU_RBAR, Cortex-M3 Devices Generic User Guide), so the probe returns
order 2 instead of 5. Nothing checks against that, so the bug can go
unseen there.
On M-class the minimum region size is fixed at 32 bytes, so return
that order without probing.
Tested under QEMU (mps2-an385): the kernel now sets up the MPU and
reaches user space. Not tested on PMSAv7 hardware.
This patch was written with an AI coding assistant (Claude Opus 5.5,
Anthropic): it found the bug in review, wrote the fix, the QEMU tests
and this changelog, and ran them; I reviewed the reasoning and the test
results.
Fixes: 9fcb01a9f54c ("ARM: 8711/1: V7M: Add support for MPU to M-class")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Brad Hawthorne <brad@xxxxxx>
---
arch/arm/mm/pmsa-v7.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm/mm/pmsa-v7.c b/arch/arm/mm/pmsa-v7.c
index 59d916ccdf25..a20a43867210 100644
--- a/arch/arm/mm/pmsa-v7.c
+++ b/arch/arm/mm/pmsa-v7.c
@@ -341,6 +341,10 @@ static int __init __mpu_min_region_order(void)
{
u32 drbar_result, irbar_result;
+ /* On M-class, writing MPU_RBAR selects a region; the minimum is 32 bytes */
+ if (IS_ENABLED(CONFIG_CPU_V7M))
+ return 5;
+
/* We've kept a region free for this probing */
rgnr_write(PMSAv7_PROBE_REGION);
isb();
--
2.43.0