-
Notifications
You must be signed in to change notification settings - Fork 29
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
More RISC-V CHERI PTE bits #117
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.
Looks good to me
target/riscv/cpu_helper.c
Outdated
return TRANSLATE_CHERI_FAIL; | ||
#endif | ||
} else { | ||
/* if necessary, set accessed and dirty bits. */ | ||
target_ulong updated_pte = pte | PTE_A | | ||
(access_type == MMU_DATA_STORE ? PTE_D : 0); | ||
|
||
#if defined(TARGET_CHERI) && !defined(TARGET_RISCV32) | ||
if (access_type == MMU_DATA_CAP_STORE) { | ||
/* (SCM and not SC) transitions to (SC and not SCM) */ |
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.
So I don't see a check for both bits being set. If that is reserved, we should be checking that above and returning some other fault instead? (What fault is defined for invalid settings of PTE bits?)
Similarly for invalid combinations of the load cap bits.
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.
Invalid setting of PTE bits is normally the page fault corresponding to the instruction type. I don't know if that means we'd want a page fault or a capability page fault if the CHERI-specific bits were the issue.
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.
Hmmm. x86 has a special code for reserved bits being set (but it also uses a single PF# vector). I suspect we want to raise the relevant CHERI fault which would happen here by just returning TRANSLATION_FAIL_CHERI
.
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'm torn between raising a CHERI-specific fault or following along with the upstream Sail that maps reserved bit combinations to the PTW_Invalid_PTE internal result (and then on to the generic page fault vector). See
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 added checks that raise the existing TRANSLATE_FAIL
code; if anyone feels strongly that this should be TRANSLATE_CHERI_FAIL
, I'll flip to that.
10f7fe3
to
c1c5474
Compare
c1c5474
to
6587776
Compare
6587776
to
318d800
Compare
318d800
to
9cafb77
Compare
Rebasing. Assuming Jenkins doesn't find any problems and nobody screams, I'll merge. |
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.
Sorry about the conflict.
target/riscv/csr.c
Outdated
} | ||
|
||
/* Take the GCLG bits from the store and update state bits */ | ||
env->mccsr = set_field(env->mccsr, gclgmask, get_field(val, gclgmask)); |
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.
Do we need another bit somewhere determining whether S-mode is allowed to write?
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.
No, they're like [ms]status.SIE. But they should really have S prefixes on all of them to make that clear.
Test failure is my fault. Will fix shortly. |
9cafb77
to
e148b2b
Compare
Renamed the fields as @jrtc27 suggested. |
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.
e148b2b
to
cbd9b41
Compare
d91b0d7
to
8a37b8e
Compare
More obviously parallels the existing W/R bits.
@jrtc27: Are there still changes you want me to make? |
target/riscv/csr.c
Outdated
@@ -1333,12 +1333,8 @@ static int write_pmpaddr(CPURISCVState *env, int csrno, target_ulong val) | |||
#endif | |||
|
|||
#ifdef TARGET_CHERI | |||
|
|||
// See Capability Control and Status Registers (CCSRs) in CHERI ISA spec |
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.
Hm, either this comment should be grouped with the one below (which should also not have a blank line after it) or it should move to where XCCSR_* are defined
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've moved it to the XCCSR_*
definitions and pruned the second comment.
While here, guard the use of all the upper metadata bits with `!defined(TARGET_RISCV32)`
Don't yet let the hypervisor play the load-side trap game, but it's fairly apparent how we might go about it.
This makes [ms]ccsr writable, but only the GCLG bits are updated. Co-Authored-By: Jessica Clarke <[email protected]>
These are `#if 0`-ed out, but has proven useful in testing, as our FPGA cores trap rather than atomically update the PTE.
Thanks to @jrtc27 for pointing out its omission.
7c1abfb
to
e9dbce2
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.
@jrtc27 can we merge this?
As per the ongoing Sail work at CTSRD-CHERI/sail-cheri-riscv#18.