Skip to content

Commit

Permalink
Check misalignment of AMOs before address translation
Browse files Browse the repository at this point in the history
This is optional according to the spec - you can check afterwards. However

1. it seems extremely unlikely that any real designs will do that for atomics, which (ignoring Zam which the model doesn't support yet), always have to be aligned, and
2. the LR and SC instructions already check before address translation, so this wasn't even consistent.

Ideally in future this would be configurable.

This also includes a minor refactor to reuse the existing alignment checking code.
  • Loading branch information
Timmmm committed Jun 11, 2024
1 parent 7ff6d94 commit e1dcef1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion model/riscv_insts_aext.sail
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,9 @@ function clause execute (AMO(op, aq, rl, rs2, rs1, width, rd)) = {
match ext_data_get_addr(rs1, zeros(), ReadWrite(Data, Data), width_bytes) {
Ext_DataAddr_Error(e) => { ext_handle_data_check_error(e); RETIRE_FAIL },
Ext_DataAddr_OK(vaddr) => {
match translateAddr(vaddr, ReadWrite(Data, Data)) {
if not(is_aligned(vaddr, width))
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 },
TR_Address(addr, _) => {
let eares = mem_write_ea(addr, width_bytes, aq & rl, rl, true);
Expand Down

0 comments on commit e1dcef1

Please sign in to comment.