Skip to content

Commit a8aa9d4

Browse files
MaureenHelmgalak
authored andcommitted
arm: nxp: mpu: Fix region descriptor 0 attributes
Clearing fields in the region descriptor attributes doesn't always have the expected effect of revoking permissions. In the case of bus master supervisor mode fields (MxSM), setting to zero actually enables read, write, and execute access. When we reworked handling of region descriptor 0, we inadvertently enabled execution from RAM by clearing the MxSM fields and enabling the descriptor. This caused samples/mpu_test run to throw a usage fault instead of an MPU-triggered bus fault. Fix this by setting all the MxSM fields to 2'b11, which gives supervisor mode the same access as user mode. Signed-off-by: Maureen Helm <[email protected]>
1 parent 286fd35 commit a8aa9d4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

arch/arm/soc/nxp_kinetis/k6x/nxp_mpu_regions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ static struct nxp_mpu_region mpu_regions[] = {
1515
MPU_REGION_ENTRY("DEBUGGER_0",
1616
0,
1717
0xFFFFFFFF,
18-
0),
18+
REGION_DEBUG_ATTR),
1919
/* Region 1 */
2020
MPU_REGION_ENTRY("FLASH_0",
2121
CONFIG_FLASH_BASE_ADDRESS,

include/arch/arm/cortex_m/mpu/nxp_mpu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@
7878
#define REGION_RO_ATTR (MPU_REGION_READ | \
7979
MPU_REGION_SU)
8080

81+
#define REGION_DEBUG_ATTR MPU_REGION_SU
82+
83+
8184
/* Region definition data structure */
8285
struct nxp_mpu_region {
8386
/* Region Base Address */

0 commit comments

Comments
 (0)