-
Notifications
You must be signed in to change notification settings - Fork 173
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
Use better types for virtual memory translation code #637
base: master
Are you sure you want to change the base?
Conversation
I wrote this code quite a while ago and kind of got sidetracked by other stuff, but it looks like I finished it so I thought I may as well push a draft and see what people think. It hasn't been tested extensively yet but I can do that. One slightly awkward thing I found is that you can use really nice strict types everywhere for the actual translation because the lifetime of |
55e080e
to
8c15f7c
Compare
8c15f7c
to
dcb8d5b
Compare
Ok I think this is ready. I will run it through our CI system and report the test results. |
dcb8d5b
to
079b1a7
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.
I have not reviewed this super thoroughly and am probably not the best person to review the vmem code but it looks good to me.
559d67b
to
4063c08
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 but someone else should also take a look
Change the VM code from using `bits(64)` everywhere to using more accurate types. This also enables Sv57 support.
4063c08
to
da2538a
Compare
// and does not legalize the asid field if asidlen is not the maximum. | ||
function legalize_satp( | ||
a : Architecture, | ||
o : xlenbits, |
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.
Suggest adding comment: /* previous value of satp */
function legalize_satp( | ||
a : Architecture, | ||
o : xlenbits, | ||
v : xlenbits, |
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.
Suggest adding comment: /* proposed new value of satp */
|
||
// PUBLIC: invoked in init_vmem() [riscv_vmem.sail] | ||
function init_TLB() -> unit = { |
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.
Will we not need 'init_TLB()' if we allow a dynamic reset on the Sail model?
@@ -127,7 +127,6 @@ function loop () : unit -> unit = { | |||
function init_model () -> unit = { | |||
init_platform (); /* devices */ | |||
init_sys (); /* processor */ | |||
init_vmem (); /* virtual memory */ |
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.
Will we not need 'init_vmem()' if we allow a dynamic reset on the Sail model?
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.
I have reviewed all 15 changed files; all generally LGTM.
Some very minor suggestions (see individual comments on particular files/lines).
I did not study the translation algorithm in riscv_vmem.sail in detail; it looked similar (structure, flow) to original, just fixing it up for the new tighter vmem types, so I think it's probably fine.
The previous version was less type-safe, using 64 bits everywhere, but could work for dynamic choice between Sv32, Sv39, Sv48 and Sv57. I think perhaps this new code requires this to be a static choice, to enable type-checking?
Change the VM code from using
bits(64)
everywhere to using more accurate types. This also enables Sv57 support.