Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] ARM: NOMMU: fix PMSAv7/v8 MPU setup on M-class
@ 2026-11-25  2:57 Brad Hawthorne
  2026-11-25  2:57 ` [PATCH 1/5] ARM: NOMMU: pmsa-v7: Do not probe the region order " Brad Hawthorne
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Brad Hawthorne @ 2026-11-25  2:57 UTC (permalink / raw)
  To: linux, linux-arm-kernel; +Cc: vladimir.murzin, linux-kernel

With CONFIG_ARM_MPU=y, a Cortex-M3 kernel under QEMU (mps2-an385)
panics before its console comes up. Patch 1 fixes that: the M-class
region base register has VALID and REGION in its low bits, so the
R-class probe selects a region that does not exist. After that,
allocate_region() can return one region too many (2),
mpu_setup_region() accepts a number one past the end (3), and
try_split_region() can return a base not aligned to its size (4).
Patch 5 fixes the same off-by-one as patch 3 in pmsa-v8.c.

Patches 2 to 4 also run on R-class.

I know the Cortex-M platforms are going in 7.5. These are for the
stable kernels that still carry them, and for the v8-M core while its
future is discussed.

Not fixed here: on M-class, pmsav7_setup() rewrites regions with the
MPU on, so for a moment a region has its new base and old size, and
QEMU faults when it covers the running code (an385, 0x3f9000 of RAM).
Turning the MPU off around the rewrite works only where the default
memory map matches the kernel's. Vladimir, how would you want this
handled?

Testing: I have no PMSAv7 hardware, so patches 1 to 4 are tested
under QEMU only (mps2-an385, several memory layouts; every prefix
builds with W=1). Patch 5 is tested under QEMU (mps2-an505) and on an
RP2350 board (Cortex-M33). A test on any Cortex-M3/M4/M7 or Cortex-R
board with CONFIG_ARM_MPU=y would help; the line to check is "Using
ARMv7 PMSA Compliant MPU ... Used N of M regions", with N no larger
than M.

This series was written with an AI coding assistant (Claude Opus 5.5,
Anthropic), as each patch says; I reviewed the reasoning and the test
results.

Brad Hawthorne (5):
  ARM: NOMMU: pmsa-v7: Do not probe the region order on M-class
  ARM: NOMMU: pmsa-v7: Do not allocate more RAM regions than the limit
  ARM: NOMMU: pmsa-v7: Fix off-by-one in mpu_setup_region()
  ARM: NOMMU: pmsa-v7: Align a split region's base to its size
  ARM: NOMMU: pmsa-v8: Fix off-by-one in __pmsav8_setup_region()

 arch/arm/mm/pmsa-v7.c | 29 ++++++++++++++++++-----------
 arch/arm/mm/pmsa-v8.c |  2 +-
 2 files changed, 19 insertions(+), 12 deletions(-)


base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
-- 
2.43.0



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-11-25 13:21 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25  2:57 [PATCH 0/5] ARM: NOMMU: fix PMSAv7/v8 MPU setup on M-class Brad Hawthorne
2026-11-25  2:57 ` [PATCH 1/5] ARM: NOMMU: pmsa-v7: Do not probe the region order " Brad Hawthorne
2026-11-25 13:12   ` Vladimir Murzin
2026-11-25  2:57 ` [PATCH 2/5] ARM: NOMMU: pmsa-v7: Do not allocate more RAM regions than the limit Brad Hawthorne
2026-11-25  2:57 ` [PATCH 3/5] ARM: NOMMU: pmsa-v7: Fix off-by-one in mpu_setup_region() Brad Hawthorne
2026-11-25 13:18   ` Vladimir Murzin
2026-11-25  2:57 ` [PATCH 4/5] ARM: NOMMU: pmsa-v7: Align a split region's base to its size Brad Hawthorne
2026-11-25  2:57 ` [PATCH 5/5] ARM: NOMMU: pmsa-v8: Fix off-by-one in __pmsav8_setup_region() Brad Hawthorne
2026-11-25 13:20   ` Vladimir Murzin
2026-11-25  7:46 ` [PATCH 0/5] ARM: NOMMU: fix PMSAv7/v8 MPU setup on M-class Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox