Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

⚠️ Rework physical memory protection (PMP) [NAPOT -> TOR] #281

Merged
merged 14 commits into from Feb 27, 2022

Conversation

stnolting
Copy link
Owner

@stnolting stnolting commented Feb 26, 2022

This PR is a complete rework of the CPU's Physical Memory Protection (PMP).

The optional physical memory protection allows to define access rights (read/write/execute) for custom memory regions. By default, all PMP rules only apply to user-mode but can also be enforced for machine-mode.

The pre-PR PMP only provided "NAPOT" mode, where protected memory regions had to be a naturally aligned power of two. This PR removes the NAPOT mode and replaces it by the "TOR" mode (top of region), which is a base and bound scheme that is easier to handle (and easier to understand).

The NEORV32 PMP (and the TOR mode) is compatible to the RISC-V privileged architecture specifications section 3.7.

⚠️ Furthermore, the maximum number of PMP regions (PMP_NUM_REGIONS generic) is limited to 16 entries. NEORV32 is a small RISC-V core and I think there should be no need to have more than 16 PMP regions (a core with 64 regions would require more than ~200% of the base core's hardware resources).

✨ This PR adds a new demo program to illustrate PMP usage (sw/example/demo_pmp).

⚠️ This PR also removes the programmable "NULL address check" from the BUSKEEPER module. This optional function was used to detect NULL-pointer accesses. However, NULL-pointer accesses can also be tracked using a single PMP entry.

comment/description and default value (now 4 bytes)
use a single PMP entry instead
replaced PMP's NAPOT mode by TOR mode (easier to use, much more flexible); CSR read access logic optimization/clean-up
@stnolting stnolting added the HW hardware-related label Feb 26, 2022
@stnolting stnolting self-assigned this Feb 26, 2022
@stnolting stnolting added the risc-v compliance Modification to comply with official RISC-V specs. label Feb 26, 2022
* rework PMP
* replace PMP NAPOT mode by TOR mode
* remove BUSKEEPER's NULL pointer check (access to address zero)
@stnolting stnolting marked this pull request as ready for review February 26, 2022 17:35
@stnolting stnolting changed the title ⚠️ Rework physical memory protection (PMP) ⚠️ Rework physical memory protection (PMP) [NAPOT -> TOR] Feb 26, 2022
@stnolting stnolting marked this pull request as draft February 26, 2022 20:56
@stnolting stnolting marked this pull request as ready for review February 27, 2022 12:55
@stnolting stnolting merged commit d616301 into main Feb 27, 2022
@stnolting stnolting deleted the rework_pmp branch February 27, 2022 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HW hardware-related risc-v compliance Modification to comply with official RISC-V specs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant