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

Simplify PMP code #738

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Timmmm
Copy link
Collaborator

@Timmmm Timmmm commented Feb 14, 2025

Inline pmpCheckPerms and use == Machine instead of match. I think this is a lot easier to understand, and shorter.

Inline `pmpCheckPerms` and use `== Machine` instead of `match`. I think this is a lot easier to understand, and shorter.
Copy link

Test Results

392 tests  ±0   392 ✅ ±0   1m 21s ⏱️ -1s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 36c42df. ± Comparison against base commit bc09ef9.

@@ -95,7 +84,7 @@ function pmpMatchEntry(addr: physaddr, width: xlenbits, acc: AccessType(ext_acce
match pmpMatchAddr(addr, width, rng) {
PMP_NoMatch => PMP_Continue,
PMP_PartialMatch => PMP_Fail,
PMP_Match => if pmpCheckPerms(ent, acc, priv)
PMP_Match => if pmpCheckRWX(ent, acc) | (priv == Machine & not(pmpLocked(ent)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the other options would be

  1. pass priv to pmpcheckRWX() and add if priv == Machine & not(pmpLocked(ent)) then true else match ...?
  2. change pmpCheckPerms to an if instead of a match().

But 2) seems unnecessary since there is only one caller of pmpCheckPerms() so we might as inline it. LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants