pmp: do not suppress pmpcfg writes for OFF or empty-range TOR entries under MML - #2495
Open
devtyagi3909 wants to merge 1 commit into
Open
devtyagi3909 wants to merge 1 commit into
devtyagi3909 wants to merge 1 commit into
Conversation
… under MML
With mseccfg.MML=1 and mseccfg.RLB=0, is_mml_m_exec_cfg checked only the L
bit and the {R,W,X} permission bits, ignoring the A (address-matching) field.
This caused three classes of writes to be incorrectly suppressed:
1. A=OFF, L=1, X=1 -- OFF creates no PMP rule; the write must not be blocked.
2. A=NA4, G=1, L=1, X=1 -- NA4 is converted to OFF when G>0, same as above.
3. A=TOR, L=1, X=1, pmpaddr[i-1] >= pmpaddr[i] -- empty range, no rule exists.
The Smepmp specification (v20260120, section 3.1) restricts writes only when
the resulting entry would produce a valid M-mode-only or Shared-Region rule.
An entry with A=OFF or an empty TOR range matches no address in any mode and
therefore cannot grant M-mode execute access.
Fix:
- is_mml_m_exec_cfg: add pmp_cfg.mode != PMP_MODE_OFF to the guard, covering
cases 1 and 2. The previous code silenced the unused mode field with a
parity reduction; that dummy assignment is removed.
- pmp_cfg_wr_suppress: add a tor_range_nonempty signal, generated per-region
inside the existing genvar loop:
* For region 0 the implicit TOR base is 0, so the range is non-empty iff
pmpaddr[0] != 0.
* For region i > 0, the range is non-empty iff pmpaddr[i-1] < pmpaddr[i].
Suppression is gated on tor_range_nonempty, covering case 3.
Fixes lowRISC#2491
Signed-off-by: Dev Tyagi <devtyagi3909@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2491
Root cause
is_mml_m_exec_cfgchecked only theLbit and the{R,W,X}permission bits, ignoring the address-matching field (A).pmp_cfg.modewas explicitly silenced with a parity reduction (logic unused_cfg = ^{pmp_cfg.mode}), making the suppression blind to whether the entry actually creates a PMP rule.This caused three classes of writes to be incorrectly suppressed under
MML=1, RLB=0:A=OFF, L=1, X=1A=NA4, G=1, L=1, X=1A=TOR, L=1, X=1, pmpaddr[i-1] >= pmpaddr[i]The Smepmp specification (section 3.1, v20260120) restricts writes only when the resulting entry produces a valid M-mode-only or Shared-Region rule. An entry with
A=OFFor an empty TOR range matches no address in any privilege mode.Fix
is_mml_m_exec_cfg: addpmp_cfg.mode != PMP_MODE_OFFto the guard. Removes the dummyunused_cfgparity assignment. Covers cases 1 and 2.pmp_cfg_wr_suppress: addtor_range_nonemptyper-region inside the existing genvar loop:pmpaddr[0] != 0pmpaddr[i-1] < pmpaddr[i]Suppression is gated on
tor_range_nonempty, covering case 3.