Commit 04419c9
committed
riscv: pmp: Add support for custom user-defined PMP entry
This commit introduces configuration and infrastructure to reserve a
dedicated Physical Memory Protection (PMP) slot for a custom memory
region.
This feature is designed for applications requiring **runtime control of
memory permissions** for critical areas, such as firmware rollback
segments or sensitive configuration data. This control is established
early in the boot process and allows the system to **temporarily modify
the privileges granted to the ROM flash** or other protected regions as
necessary during execution.
The new Kconfig options allow the user to define:
- **CONFIG_CUSTOM_PMP_ENTRY_START**: Base address of the protected
region.
- **CONFIG_CUSTOM_PMP_ENTRY_SIZE**: Size of the protected region.
- **CONFIG_CUSTOM_PMP_ENTRY_PERMISSIONS**: R/W/X access permissions for
the slot.
The custom PMP entry is configured in `z_riscv_pmp_init()` and
purposefully placed before the locked read-only ROM protection entry to
ensure early enforcement.
The necessary context switch logic (`z_riscv_custom_pmp_entry_enable`)
is added to `switch.S` and `pmp.c` to handle the required MPRV/MPP
register configuration when the custom entry is enabled and the PMP
stack guard is disabled.
Signed-off-by: Firas Sammoura <fsammoura@google.com>1 parent 803dc90 commit 04419c9
4 files changed
+78
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
435 | 473 | | |
436 | 474 | | |
437 | 475 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
357 | 364 | | |
358 | 365 | | |
359 | 366 | | |
| |||
371 | 378 | | |
372 | 379 | | |
373 | 380 | | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
374 | 392 | | |
375 | 393 | | |
376 | 394 | | |
| |||
446 | 464 | | |
447 | 465 | | |
448 | 466 | | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
449 | 481 | | |
450 | 482 | | |
451 | 483 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
64 | 70 | | |
65 | 71 | | |
66 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
17 | 18 | | |
18 | 19 | | |
0 commit comments