Skip to content

fix(csr): csr reserved fields#1565

Open
amkr6207 wants to merge 6 commits intoriscv:mainfrom
amkr6207:fix/1186-csr-reserved-fields
Open

fix(csr): csr reserved fields#1565
amkr6207 wants to merge 6 commits intoriscv:mainfrom
amkr6207:fix/1186-csr-reserved-fields

Conversation

@amkr6207
Copy link
Copy Markdown
Contributor

@amkr6207 amkr6207 commented Feb 7, 2026

This PR addresses Issue #1186 by explicitly defining all reserved/WPRI fields in mnstatus.yaml as per the RISC-V Smrnmi specification.

Changes:

  • Explicitly defined Reserved_High (Bits 63-13).
  • Added MNPELP (Bit 9) from Zicfilp extension.
  • Added Reserved fields for all gaps (Bits 0-2, 4-6, 8, 10).
  • Fixed Reserved field locations to use valid rv32/rv64 ranges.

Note: This is a pilot implementation to establish the correct pattern. Once approved, I will apply this pattern to the remaining CSR files in subsequent PRs.
Closes #1186

Explicitly define reserved/WPRI bits in mnstatus.yaml to remove
architectural assumptions in the database.

Also update .gitignore to exclude docker artifacts.

Closes riscv#1186
Copy link
Copy Markdown
Member

@AFOliveira AFOliveira left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution! This is new to UDB and may need some discussion. but if you're willing to wait and see, I think this is already along the lines of what to insert, I'm just not sure about the how. @ThinkOpenly and @dhower-qc have worked with CSRs inside UDB way more than me, so let's see what they think.

extension:
name: Smrnmi
fields:
Reserved_High:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm not super sure about this name for the reserved, locations... @ThinkOpenly @dhower-qc, any thoughts?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Agreed, but I don't have anything that would make it better. Other than maybe having the names with numbers match the order of "location", e.g., Reserved_4_6 --> Reserved_6_4

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay . I'll rename it to match the location order ( Reserved_4_6 --> Reserved_6_4 )

extension:
name: H

Reserved_4_6:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same

type: RW-H
reset_value: 0

Reserved_0_2:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same

@amkr6207 amkr6207 changed the title Fix/1186 csr reserved fields fix(csr): CSR reserved fields Feb 9, 2026
@amkr6207 amkr6207 changed the title fix(csr): CSR reserved fields fix(csr): csr reserved fields Feb 9, 2026
Copy link
Copy Markdown
Collaborator

@dhower-qc dhower-qc left a comment

Choose a reason for hiding this comment

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

The big-picture question on this is whether or not it's needed. What does explicitly naming the reserved fields add beyond just assuming that any unused bits are unnamed WPRI, as is the case now?

@AFOliveira
Copy link
Copy Markdown
Member

The big-picture question on this is whether or not it's needed. What does explicitly naming the reserved fields add beyond just assuming that any unused bits are unnamed WPRI, as is the case now?

If I can recall correctly, the question is that reserved and WPRI mean differnt things.

@dhower-qc
Copy link
Copy Markdown
Collaborator

I thought we determined they were the same. Do you have the differing definitions?

@AFOliveira
Copy link
Copy Markdown
Member

I thought we determined they were the same. Do you have the differing definitions?

Going down the issue rabbit-hole, I don't think that's true. i.e.

In general the definition of "Reserved" is as specified in the WPRI definition. So yes, in general, Reserved fields MUST be treated as defined.

BUT in specific cases that define a different behavior for a specific field, then that specific field MUST be implemented per that specific definition. In such cases one cannot instead implement the behavior in the WPRI definition since that would be incompatible with what is specified for the field.

Originally posted by @gfavor in #2318

@dhower-qc
Copy link
Copy Markdown
Collaborator

Talked about this in the PR meeting -- general direction is that we should treat missing bits as WPRI, and only document the reserved fields that are not WPRI. Much less work!

@AFOliveira
Copy link
Copy Markdown
Member

Talked about this in the PR meeting -- general direction is that we should treat missing bits as WPRI, and only document the reserved fields that are not WPRI. Much less work!

That's what this PR does, right?

@ThinkOpenly
Copy link
Copy Markdown
Collaborator

Talked about this in the PR meeting -- general direction is that we should treat missing bits as WPRI, and only document the reserved fields that are not WPRI. Much less work!

That's what this PR does, right?

The guidance in the spec is:

The other bits in mnstatus are reserved; software should write zeros and hardware implementations should return zeros.

I'm not sure I like that guidance, because it breaks forward compatibility. If I always write zeros to those bits, how can they ever be used in the future? Maybe we need to change the spec there. I think it should really be "the other bits in mnstatus are WPRI.`

@AFOliveira
Copy link
Copy Markdown
Member

I'm not sure I like that guidance, because it breaks forward compatibility. If I always write zeros to those bits, how can they ever be used in the future? Maybe we need to change the spec there. I think it should really be "the other bits in mnstatus are WPRI.`

Well, I wasn't making judgments on the spec here. I understand your concern, but the spec is ratified as is, so changing that shouldn't be possible without modifying the extension number, right? So, @amkr6207 change should be in UDB as it agrees with current RISC-V specification

@ThinkOpenly
Copy link
Copy Markdown
Collaborator

FYI, I reopened riscv/riscv-isa-manual#2318, because the words in the spec seem wrong to me.

@AFOliveira
Copy link
Copy Markdown
Member

FYI, I reopened riscv/riscv-isa-manual#2318, because the words in the spec seem wrong to me.

I don't think it's the words. You seem to be disagreeing with the behavior, which is fine, but as of right now, I think the spec mandates what Greg described and I'm afraid that it has been implemented in real HW, so it seems to late to change it?

@ThinkOpenly
Copy link
Copy Markdown
Collaborator

FYI, I reopened riscv/riscv-isa-manual#2318, because the words in the spec seem wrong to me.

I don't think it's the words. You seem to be disagreeing with the behavior, which is fine, but as of right now, I think the spec mandates what Greg described and I'm afraid that it has been implemented in real HW, so it seems to late to change it?

I understand your point. I've reopened the issue to get more clarity, for me at least. I will note that "should" != "must". So, that would make actual behavior implementation-dependent, and thus in need of a configuration parameter.

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 69.18%. Comparing base (d29399e) to head (7e271ae).
⚠️ Report is 51 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1565      +/-   ##
==========================================
+ Coverage   60.05%   69.18%   +9.13%     
==========================================
  Files          42       43       +1     
  Lines       26120    27059     +939     
  Branches     6246     6475     +229     
==========================================
+ Hits        15686    18721    +3035     
+ Misses      10434     8338    -2096     
Flag Coverage Δ
idlc 72.92% <ø> (+13.94%) ⬆️
udb 62.16% <ø> (+0.18%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@amkr6207
Copy link
Copy Markdown
Contributor Author

Thank you all for the detailed feedback!

Hi @AFOliveira, @ThinkOpenly

Reserved vs WPRI — I see there's an ongoing discussion about whether missing bits should be treated as WPRI by default (riscv/riscv-isa-manual#2318). Should I wait for that to be resolved before extending this to other CSRs, or should I proceed with the current approach?

@ThinkOpenly
Copy link
Copy Markdown
Collaborator

Should I wait for that to be resolved before extending this to other CSRs, or should I proceed with the current approach?

I'd wait.

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.

CSR Reserved fields

4 participants