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(); }