Skip to content

Commit

Permalink
add amocas specific addr check
Browse files Browse the repository at this point in the history
  • Loading branch information
ved-rivos committed Aug 18, 2023
1 parent 8949f86 commit d0cc13c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 7 additions & 0 deletions model/riscv_addr_checks.sail
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,13 @@ function ext_data_get_addr(base : regidx, offset : xlenbits, acc : AccessType(ex
let addr = X(base) + offset in
Ext_DataAddr_OK(addr)

/* Default AMO data addr is just base register.
Extensions might override and add additional checks. */
function ext_data_get_amo_addr(base : regidx, acc : AccessType(ext_access_type), width : amo_word_width)
-> Ext_DataAddr_Check(ext_data_addr_error) =
let addr = X(base) in
Ext_DataAddr_OK(addr)

function ext_handle_data_check_error(err : ext_data_addr_error) -> unit =
()

Expand Down
3 changes: 1 addition & 2 deletions model/riscv_insts_aext.sail
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,8 @@ function clause execute (AMO(op, aq, rl, rs2, rs1, width, rd)) = {
if haveAtomics() then {
/* Get the address, X(rs1) (no offset).
* Some extensions perform additional checks on address validity.
* For obtaining virtual address, the width is not needed.
*/
match ext_data_get_addr(rs1, zeros(), ReadWrite(Data, Data), BYTE) {
match ext_data_get_amo_addr(rs1, ReadWrite(Data, Data), width) {
Ext_DataAddr_Error(e) => { ext_handle_data_check_error(e); RETIRE_FAIL },
Ext_DataAddr_OK(vaddr) => {
match translateAddr(vaddr, ReadWrite(Data, Data)) {
Expand Down

0 comments on commit d0cc13c

Please sign in to comment.