-
Notifications
You must be signed in to change notification settings - Fork 244
Extend access type to cache accesses #792
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
Conversation
|
I'm getting pretty close to pushing our latest code (just trying to get it to build) so give me a couple of days and then I can point you at it. |
|
Here's how we are doing it for CBOs: Basically you just have to make sure to pass in the correct access type, and for cbom it is based on the original access type rather than the modified one. @tomaird that bit isn't super clear in the CHERI spec. Do you know where it came from? |
|
Not sure I understand which bit isn't clear so I'll just explain the full rationale behind all this code... The CHERI spec describes the following checks for the CBO instructions (amongst others): So for the bounds check, But for the permissions checks it's a bit different, with The RISC-V spec describes that Does that answer your question? |
|
Yeah I think my question is do you definitely still need ASR permission if INVAL executes as FLUSH. My understanding was that INVAL needs the extra permission because it's "unsafe" - you can resurrect capabilities that should have died. But if it's actually doing a FLUSH then it's safe. Although now that I check the spec again it does actually explicitly mention this:
|
aaf0b57 to
4ccd8e2
Compare
This should be "All bytes":
|
|
@jrtc27 where are you quoting that bit of spec from? On latest main of the CHERI spec has https://github.com/riscv/riscv-cheri/blob/main/src/cheri/insns/cbo_exceptions.adoc?plain=1#L23 |
I guess I still had an old version open somehow. But this is very wrong. See riscv/riscv-cheri#221 (comment) :( |
4ccd8e2 to
e15c292
Compare
e15c292 to
2cd25b0
Compare
|
It would be good to get this in - do you mind if I just update it to remove |
|
Okay, I'll remove it. |
2cd25b0 to
ac78c42
Compare
ac78c42 to
3851ce1
Compare
|
Hey, I rebased this and changed it to use the AMO PMA level in the AMO access type instead of the full AMO op since a) that's all we really need to know, and b) we don't have access to that type in Also I think we probably want to go the full way and remove all the |
|
Thanks for the rebase @Timmmm . I'm also considering how to proceed. Perhaps we should first open an issue to document the removal of the |
|
I don't think we need to document anything, we just need to remove those parameters and instead source them from the access type. I did start working on this, it doesn't look too bad. The only minor issue I ran into is that a couple of functions have the bool flags but not the access type, but we can just add that. |
|
@KotorinMinami @Timmmm This would be great to get in soon as it is blocking #328 (which was recently ratified and would be good to get merged). Are either of you able to rebase and finish this (after the holidays)? |
|
Yeah maybe we could take a look at each of our approaches in the next meeting and see which one is best (I haven't actually looked yet). |
pmundkur
left a comment
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.
Notes from comparing this to #1405. Sorry, I should have checked this before.
| width <= xlen_bytes | (op == AMOCAS & width <= xlen_bytes * 2 & rs2[0] == bitzero & rd[0] == bitzero) | ||
| )) | ||
|
|
||
| function amo_level(op : amoop, width : word_width_wide) -> AmoLevel = |
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.
AMO width handling is not handled in #1405. In that PR, pmaCheck gets a more informative access, but doesn't do anything with it. I think that's best left to a subsequent PR, which would also handle the width of cache block accesses.
| */ | ||
| let data = X(rs2)[width * 8 - 1 .. 0]; | ||
| match vmem_write(rs1, zeros(), width, data, Write(Data), aq & rl, rl, true) { | ||
| match vmem_write(rs1, zeros(), width, data, StoreConditional(aq, rl, Data), aq & rl, rl, true) { |
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.
It's not clear whether to use StoreConditional(aq, rl,..) here or StoreConditional(aq & rl, rl, ...) as per the original code. This is why I did not fold in these flags in #1405. It's probably better to have litmus tests running first to ensure we don't break things in the refactor.
| enum CacheAccessType = { | ||
| CleanFlush, | ||
| Inval, | ||
| Zero, |
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.
We've since added prefetch from Zicbop as well.
| Cache(_) => false, | ||
| }); | ||
| // Update 'accessed'-bit? | ||
| let update_a = (pte_flags[A] == 0b0); |
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 needs to be updated: "During address translation, the [cache-block management] instruction also checks the accessed bit and may either raise an exception or set the bit as required." Similarly for cache-block zero.
| AMOAccess(_, _, _, _, _) => true, | ||
| LoadReserved(_, _, _) => false, | ||
| StoreConditional(_, _, _) => true, | ||
| Cache(_) => 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 is incorrect: "During address translation, the [cache-block zero] instruction also checks the accessed and dirty bits and may either raise an exception or set the bits as required."
| Read(_) => "R", | ||
| Write(_) => "W", | ||
| ReadWrite(_, _) => "RW", | ||
| AMOAccess(_) => "A", |
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 left this as "RW" in #1405. Is "A" preferable?
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.
Until we have other trace/logging formats, I would avoid changing what is printed in the log. It is currently the only way of parsing the output of the model, so switching from RW to A would likely break many tools. Once we have new machine-readable formats available, we can intentionally break the human-readable log, and then I think switching to A/LR/SC is worth considering.
| LoadReserved(_) => "LR", | ||
| StoreConditional(_) => "SC", |
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 left these as "R" and "W", perhaps "LR" and "SC" are more informative?
|
Should we close this, now that #1405 is merged? |
Added an implementation for #787, but I was wondering how to implement this TODO in the comment