-
Notifications
You must be signed in to change notification settings - Fork 204
Add satp mode guard #807
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
base: master
Are you sure you want to change the base?
Add satp mode guard #807
Conversation
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.
Need to think about whether extensionEnabled()
makes sense for this. Technically only one of these extensions is ever enabled at a time (whichever is set in satp
), but this may be the simplest way to implement this.
No? The extension just means it's a supported option for satp.MODE, not that it's the currently active one. |
The way it's handled in the model right now, we use |
The extension is always active, there's no way to turn it off. You just may not currently be using that specific mode in satp. It makes total sense for extensionEnabled to be true for each of the SvXX that the model is configured to support, because that's what the architecture says happens. |
69451f7
to
27d771d
Compare
If I understand correctly, my current implementation should be fine, right? Going forward, we just need to add the |
27d771d
to
81708dc
Compare
81708dc
to
bc8ff5f
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 now
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, but I think minor simplification is possible.
bc8ff5f
to
081f8d4
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.
From section 3.1.6.4 of the privileged spec:
SUM is read-only 0 if S-mode is not supported or if satp.MODE is read-only 0.
Right now mstatus.SUM
is guarded on S, but now that we are adding a way to disable writes to satp
it needs to be guarded on that as well. Same for sstatus.SUM
.
081f8d4
to
8bca1db
Compare
8bca1db
to
4def74c
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
4def74c
to
1326854
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.
Just needs to be updated for the new config system. Then should be good to go.
model/riscv_sys_regs.sail
Outdated
@@ -160,6 +160,19 @@ function sys_enable_supervisor() -> bool = true | |||
function clause extensionEnabled(Ext_U) = misa[U] == 0b1 | |||
function clause extensionEnabled(Ext_S) = misa[S] == 0b1 | |||
|
|||
// TODO: Make configurable | |||
function clause extensionEnabled(Ext_Svbare) = extensionEnabled(Ext_S) | |||
function clause extensionEnabled(Ext_Sv32) = extensionEnabled(Ext_S) & (xlen == 32) |
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.
Update
function clause extensionEnabled(Ext_Sv32) = extensionEnabled(Ext_S) & (xlen == 32) | |
function clause currentlyEnabled(Ext_Sv32) = currentlyEnabled(Ext_S) & (xlen == 32) & hartSupports(Ext_Sv32) |
1326854
to
a1d52ef
Compare
a1d52ef
to
f917603
Compare
config/default.json
Outdated
@@ -183,6 +183,18 @@ | |||
"supported" : true | |||
}, | |||
"Svinval" : { | |||
"supported" : false |
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.
This shouldn’t be disabling Svinval.
f917603
to
72e535f
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 with my comment and https://github.com/riscv/sail-riscv/pull/807/files#r2042691915 addressed
model/riscv_extensions.sail
Outdated
function clause hartSupports(Ext_Sv39) = config extensions.Sv39.supported | ||
enum clause extension = Ext_Sv48 | ||
function clause hartSupports(Ext_Sv48) = config extensions.Sv48.supported | ||
enum clause extension = Ext_Sv57 | ||
function clause hartSupports(Ext_Sv57) = config extensions.Sv57.supported |
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.
Should these have an xlen check (or a configuration sanity check that gives a fatal error if you try to enable them for RV32?)? That would allow us to remove the checks lower down.
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.
They should definitely check xlen, similar to sv32.
We probably need a whole new file/function that checks for illegal configurations since there a number of other extensions that have the same issue. I’d hold off on that part in this PR.
72e535f
to
c37f0db
Compare
c37f0db
to
6dfd1ac
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.
Looks great!
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. The only other thing I wonder is if we should enforce that Sv48 depends on Sv39 and Sv57 depends on Sv48? E.g. you can't just enable Sv57.
True, and maybe that is the easiest way for now. |
Discussed in the meeting. We think we're going to eventually have a config validation function to check you don't enable Sv57 without Sv48 etc. so this is fine. |
6dfd1ac
to
abefe2a
Compare
abefe2a
to
03e322f
Compare
From #796 , as the spec say
so adding extensionenabled and applying guard in legalize_satp I think might work.