This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 519c9a4b8ba06d382a2ce3778a872480c142feff Author: DuoYuWang <[email protected]> AuthorDate: Wed Aug 26 22:05:04 2026 +0800 stm32h7: Keep protected user SRAM non-shareable. The generic ARMv7-M user SRAM helper marks memory shareable. STM32H7 Protected user data and heaps can reside in cacheable AXI or D2 SRAM, where userspace synchronization needs LDREX/STREX to use the CPU-local exclusive monitor. Map protected user SRAM as Normal, cacheable, and non-shareable. Dual-core RPTUN SRAM remains unaffected because it is mapped separately with explicit shareable attributes. Tested by booting a Protected image and running user and kernel work-queue stress tests on an STM32H7 PX4 FMUv6C. Assisted-by: Codex:GPT-5 Signed-off-by: DuoYuWang <[email protected]> --- arch/arm/src/stm32h7/stm32_mpuinit.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/arm/src/stm32h7/stm32_mpuinit.c b/arch/arm/src/stm32h7/stm32_mpuinit.c index a141895b210..f6912bb5d1d 100644 --- a/arch/arm/src/stm32h7/stm32_mpuinit.c +++ b/arch/arm/src/stm32h7/stm32_mpuinit.c @@ -52,6 +52,26 @@ # endif #endif +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#ifdef CONFIG_BUILD_PROTECTED +static void stm32_mpu_user_intsram(uintptr_t start, size_t size) +{ + /* STM32H7 protected user memory can span AXI and D2 SRAM. Keep it + * Normal and non-shareable so that LDREX/STREX use the CPU-local + * exclusive monitor. Dual-core RPTUN shared memory is mapped separately + * below with shareable attributes. + */ + + mpu_configure_region(start, size, + MPU_RASR_TEX_SO | + MPU_RASR_C | + MPU_RASR_AP_RWRW); +} +#endif + /**************************************************************************** * Public Functions ****************************************************************************/ @@ -94,7 +114,7 @@ void stm32_mpuinitialize(void) mpu_user_flash(USERSPACE->us_textstart, USERSPACE->us_textend - USERSPACE->us_textstart); - mpu_user_intsram(datastart, dataend - datastart); + stm32_mpu_user_intsram(datastart, dataend - datastart); #endif #ifdef CONFIG_RPTUN @@ -121,7 +141,7 @@ void stm32_mpuinitialize(void) void stm32_mpu_uheap(uintptr_t start, size_t size) { - mpu_user_intsram(start, size); + stm32_mpu_user_intsram(start, size); } #endif
