Skip to content

Commit 3aa435c

Browse files
committed
Mark RAM as non executable
1 parent a29467a commit 3aa435c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mpu.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ void mpu_init(void)
8686
/* NULL pointer protection, highest priority. */
8787
mpu_configure_region(7, NULL, 5, AP_NO_NO, false);
8888

89+
/* Mark RAM as non executable. Using lowest priority means explicitely
90+
* allowing a RAM region to be executable is possible.
91+
*
92+
* We can use a fixed address range for RAM because it is a standard define
93+
* by ARM. */
94+
void *ram_base = (void *)0x20000000;
95+
int ram_size_pow2 = 29; /* 2^29 = 0.5GB. */
96+
mpu_configure_region(0, ram_base, ram_size_pow2, AP_RW_RW, false);
97+
8998
mpu_enable();
9099
}
91100

0 commit comments

Comments
 (0)