-
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
Added pmm Support #454
base: master
Are you sure you want to change the base?
Added pmm Support #454
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.
Can you link to the specification? Sorry, I might be being blind but I can't seem to find one that matches this!
Also this needs to be rebased, and the bitfield field access syntax has changed: mseccfg.PMM()
-> mseccfg[PMM]
.
model/riscv_insts_aext.sail
Outdated
if haveAtomics() then { | ||
/* Get the address, X(rs1) (no offset). | ||
* Extensions might perform additional checks on address validity. | ||
*/ | ||
match ext_data_get_addr(rs1, zeros(), Read(Data), width) { | ||
Ext_DataAddr_Error(e) => { ext_handle_data_check_error(e); RETIRE_FAIL }, | ||
Ext_DataAddr_OK(vaddr) => { | ||
let vaddr_ = transform_effective_address(vaddr, pmm); |
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.
Could this go inside translateAddr
? I think the only reason it couldn't is if transform_effective_address()
would affect alignment but that sounds like it shouldn't be possible? If the address given to handle_mem_exception()
needs to be different I would say add that as a field of TR_Failure
.
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 is possible to do this, but it will complicate the code. But what if the code is misaligned?
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.
Yeah I'm not sure because I haven't seen the specification. Please can you link to it, ideally in the top message?
1ceb4a1
to
6b82b12
Compare
Please can you link to the specification that this is intended to implement? |
model/riscv_insts_aext.sail
Outdated
then { handle_mem_exception(vaddr, E_SAMO_Addr_Align()); RETIRE_FAIL } | ||
else match translateAddr(vaddr, ReadWrite(Data, Data)) { | ||
TR_Failure(e, _) => { handle_mem_exception(vaddr, e); RETIRE_FAIL }, | ||
let vaddr_ = transform_effective_address(vaddr, pmm); |
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.
let vaddr_ = transform_effective_address(vaddr, pmm); | |
let vaddr = transform_effective_address(vaddr, pmm); |
Should reduce the diff.
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.
Ok I've read the spec and this seems mostly ok. I've added some more comments.
I think the major thing is that the handling of pointer masking should be inside translateAddr
. I checked very briefly and I think if you exclude Execute
accesses then it matches the situations where pointer masking should be applied. (Double check that though - apart from fetches are there any translateAddr()
calls that you didn't have to add pointer masking to?
IIRC pointer masking isn't applied to the xtval
address (passed into handle_mem_exception()
). To deal with that, add an address field to TR_Failure
. Something like:
if check_misaligned(vaddr, width)
then { handle_mem_exception(vaddr, E_Load_Addr_Align()); RETIRE_FAIL }
else match translateAddr(vaddr, Read(Data)) {
TR_Failure(xtval_addr, e, _) => { handle_mem_exception(xtval_addr, e); RETIRE_FAIL },
Putting pointer masking inside translateAddr would compose poorly with DDC on CHERI, which should authorise the actual masked virtual address used. |
We already have |
Ah yeah we don't call You reminded me actually there's a bit of spec I didn't quite follow:
The Sail model has a TLB so maybe we need to do something, but I didn't quite get what it was trying to say here. It seems to be talking about 3 different cases:
It just doesn't seem to make any sense. There are only two parts of the address - NVBITS and VBITS, so what three cases is this referring to? Can anyone say if we need to change the TLB code? I'm not sure. |
f8b4fe6
to
0245007
Compare
Regarding the comment on @jrtc27 and @Timmmm of implementing Pointer Masking in |
IMO this should be part of |
RISC-V Pointer Masking Extension Implementation
This PR features the implementation of the Pointer Masking Extension for the RISC-V architecture, enhancing the Base, Floating Point, Compressed, Vector and Atomics Instruction Set.
Changes
Implemented the
mseccfg
register with associated changes in riscv_sys_regs.sail ,riscv_insts_zicsr.sail ,riscv_sys_control.sail ,riscv_csr_map.sailUpdated the
leglize_envcfg
function and added functionsis_pmm_active
,legalize_mseccfg
andget_pmm
in riscv_sys_regs.sail.Introduced functions
transform_VA
andtransform_PA
in riscv_insts_base.sail.Implemented the function
transform_effective_address
. and Integratedtransform_effective_address
into the execution of LOAD and STORE functions of the targeted instruction files.Testing
The functionality has been verified with several tests. However, testing is still ongoing. Once completed, the repository link will be shared promptly.
The self-checking tests have not been written yet. However, work has commenced on them and they should be available shortly.