-
Notifications
You must be signed in to change notification settings - Fork 167
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
Add missing mstatus.MPP legalization #397
Conversation
Something also needs to happen at initialization, I think? Right now sail-riscv/model/riscv_sys_control.sail Line 553 in d5e89a7
mstatus[MPP] as 0b00 , even if that's not a legal value (say, on a M-mode-only core).
|
Agree. This was missed. I have committed an update to fix this. |
19056d8
to
ac841b8
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I slightly prefer using an if/else
instead of tuple match (since the first element is only needed for one case), but happy either way.
if not(haveUsrMode()) then privLevel_to_bits(Machine)
else match p {
0b01 => if haveSupMode() then p else privLevel_to_bits(User),
0b10 => privLevel_to_bits(if haveSupMode() then Supervisor else Machine),
_ => p
}
This goes away when riscv#397 lands upstream
This goes away when riscv#397 lands upstream
We also came across this, so... alternative implementation, which I think is clearer:
|
ac841b8
to
6ef392e
Compare
This is nicer. Updated to this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
@billmcspadden-riscv We should merge this fix IMO. It's been a few months and there are no issues with it. |
I'll merge this next week if nobody objects. |
mstatus.MPP
legal values are User (00) (if U-mode implemented), Supervisor (
01) (if S-mode implemented) and Machine (11). Encoding
10 is illegal.