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

Unexpected WPRI Bit Behavior in Nutshell's mstatus Register Handling #173

Open
youzi27 opened this issue Mar 5, 2024 · 0 comments
Open

Comments

@youzi27
Copy link

youzi27 commented Mar 5, 2024

Describe the bug:
The Nutshell implementation allows reading and writing to the WPRI (Write Preserve, Read Ignore) bit of the mstatus register, which seems to contradict the general guidance of the RISC-V specification. Specifically, writes to the WPRI bit are preserved, and reads reflect the written value, instead of being ignored or read as zero in Nutshell.
image

To Reproduce

  1. Write a value to the mstatus register that modifies the WPRI bit (e.g., 4-bit).
  2. Read the mstatus register value into a general-purpose register (e.g., t0).
  3. Observe that the WPRI bit's value is preserved and not ignored as expected.

Expected behavior
According to the RISC-V spec, WPRI bits are reserved and should not affect operational semantics. Writes to these bits should be preserved internally but ignored upon reading, typically yielding a zero for these bits. The observed behavior where WPRI bits can be read and written as normal register bits might not align with the intention of future compatibility and specification adherence.

Screenshots
For writing to the fourth bit, the WPRI (Write Preserve, Read Ignore) bit, NutShell allows writing.
image

After writing the value, it is discovered upon reading that this value can be fully retrieved.
image

Environment (optional, if necessary):
OS: Ubuntu 22.04.3 LTS
Compiler: gcc 11.4.0

Additional context
None

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

No branches or pull requests

1 participant