This is an automated email from the ASF dual-hosted git repository.
ligd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
The following commit(s) were added to refs/heads/master by this push:
new 14e5d8a9955 arm64: fix mpu_freeregion
14e5d8a9955 is described below
commit 14e5d8a995510a8dc0394b062bf1d662a9802172
Author: hujun5 <[email protected]>
AuthorDate: Tue May 13 15:12:59 2025 +0800
arm64: fix mpu_freeregion
The limit register contains the enable/disable bit for the MPU region,
so it must be written first before writing the base register to ensure
proper region disable operation.
Signed-off-by: hujun5 <[email protected]>
---
arch/arm64/src/common/arm64_mpu.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/arch/arm64/src/common/arm64_mpu.c
b/arch/arm64/src/common/arm64_mpu.c
index 41f3c081a64..e9cd12e44f9 100644
--- a/arch/arm64/src/common/arm64_mpu.c
+++ b/arch/arm64/src/common/arm64_mpu.c
@@ -187,10 +187,14 @@ void mpu_freeregion(unsigned int region)
write_sysreg(region, prselr_el1);
UP_DSB();
- /* Set the region base, limit and attribute */
+ /* Set the region base, limit and attribute
+ * Have to set limit register first as the enable/disable bit of the
+ * region is in the limit register.
+ */
- write_sysreg(0, prbar_el1);
write_sysreg(0, prlar_el1);
+ write_sysreg(0, prbar_el1);
+
g_mpu_region[this_cpu()] &= ~(1 << region);
UP_MB();
}