Skip to content

riscv: fix mstatus/sstatus helpers and field mask#396

Open
elliott10 wants to merge 2 commits intorust-embedded:masterfrom
elliott10:master
Open

riscv: fix mstatus/sstatus helpers and field mask#396
elliott10 wants to merge 2 commits intorust-embedded:masterfrom
elliott10:master

Conversation

@elliott10
Copy link
Copy Markdown

riscv: complete mstatus and sstatus status helpers

Align the mstatus and sstatus helpers with the privileged spec.

  • add missing base-field helpers for UBE, VS, UXL and SXL/SBE/MBE where applicable
  • model XS and SD as read-only summary fields instead of writable fields
  • keep set_uie/set_upie as compatibility helpers for legacy N-extension users
  • fix the CSR masks to preserve all legal status bits
  • update tests to cover the new helpers and read-only field behavior

@elliott10 elliott10 requested a review from a team as a code owner April 15, 2026 13:38
@romancardenas
Copy link
Copy Markdown
Contributor

I will need some time to review this PR. Can you share with me the link to the ISA specification you used for these modifications? I usually use this: https://docs.riscv.org/reference/isa/_attachments/riscv-privileged.pdf

There is a new release (from February) and looks like there is a few more fields

@elliott10
Copy link
Copy Markdown
Author

I will need some time to review this PR. Can you share with me the link to the ISA specification you used for these modifications? I usually use this: https://docs.riscv.org/reference/isa/_attachments/riscv-privileged.pdf

There is a new release (from February) and looks like there is a few more fields

I referred to this ISA Spec: https://docs.riscv.org/reference/isa/priv/supervisor.html#sstatus

If there is anything I have missed, I am willing to keep improving it :)

Copy link
Copy Markdown
Contributor

@romancardenas romancardenas left a comment

Choose a reason for hiding this comment

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

Looks good to me!! Please, address the changes in CHANGELOG.md and the minor docs formatting comment.

///
/// Encodes the status of additional user-mode extensions and associated
/// state.
/// state. This is a read-only field summarizing the status of all
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// state. This is a read-only field summarizing the status of all
/// state.
///
/// This is a read-only field summarizing the status of all

Comment thread riscv/CHANGELOG.md
Comment on lines +10 to 16
###
- Add `mstatus` and `sstatus` CSRs helpers for UBE, VS, UXL and SXL/SBE/MBE where applicable
model XS and SD as read-only summary fields instead of writable fields
- Fix the CSR masks to preserve all legal status bits

### Added

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Move the additions to the Added section:

Suggested change
###
- Add `mstatus` and `sstatus` CSRs helpers for UBE, VS, UXL and SXL/SBE/MBE where applicable
model XS and SD as read-only summary fields instead of writable fields
- Fix the CSR masks to preserve all legal status bits
### Added
### Added
- - Add `mstatus` and `sstatus` CSRs helpers for UBE, VS, UXL and SXL/SBE/MBE where applicable
model XS and SD as read-only summary fields instead of writable fields
- Add `pmpaddr16` ~ `pmpaddr63` CSRs

And the changes to the Changed section:

### Changed (section below Added)

- Fix the CSR masks to preserve all legal status bits
- ...

@romancardenas romancardenas self-requested a review April 17, 2026 14:44
Copy link
Copy Markdown
Contributor

@romancardenas romancardenas left a comment

Choose a reason for hiding this comment

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

Sorry, I approved the PR by mistake. Address the changes before merging

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.

2 participants