Skip to content

Commit 16905f5

Browse files
Nicolas Pitrecfriedt
authored andcommitted
riscv: pmp: move the null pointer trap first
Let's move the null pointer trap first so to give set_pmp_entry() the opportunity to use a single-slot TOR entry. Signed-off-by: Nicolas Pitre <[email protected]>
1 parent 283365a commit 16905f5

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

arch/riscv/core/pmp.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,6 @@ void z_riscv_pmp_init(void)
422422
unsigned long pmp_cfg[CONFIG_PMP_SLOTS / PMPCFG_STRIDE];
423423
unsigned int index = 0;
424424

425-
/* The read-only area is always there for every mode */
426-
set_pmp_entry(&index, PMP_R | PMP_X | PMP_L,
427-
(uintptr_t)__rom_region_start,
428-
(size_t)__rom_region_size,
429-
pmp_addr, pmp_cfg, ARRAY_SIZE(pmp_addr));
430-
431425
#ifdef CONFIG_NULL_POINTER_EXCEPTION_DETECTION_PMP
432426
/*
433427
* Use a PMP slot to make region (starting at address 0x0) inaccessible
@@ -439,6 +433,12 @@ void z_riscv_pmp_init(void)
439433
pmp_addr, pmp_cfg, ARRAY_SIZE(pmp_addr));
440434
#endif
441435

436+
/* The read-only area is always there for every mode */
437+
set_pmp_entry(&index, PMP_R | PMP_X | PMP_L,
438+
(uintptr_t)__rom_region_start,
439+
(size_t)__rom_region_size,
440+
pmp_addr, pmp_cfg, ARRAY_SIZE(pmp_addr));
441+
442442
#ifdef CONFIG_PMP_STACK_GUARD
443443
#ifdef CONFIG_MULTITHREADING
444444
/*

0 commit comments

Comments
 (0)