Skip to content

Commit

Permalink
Make supervisor interrupt bits read only zero without supervisor mode
Browse files Browse the repository at this point in the history
Implements this requirement from the spec:

> If supervisor mode is not implemented, bits SEIP, STIP, and SSIP of mip and SEIE, STIE, and SSIE of mie are read-only zeros.
  • Loading branch information
KotorinMinami authored Nov 23, 2024
1 parent 7e30e2d commit 07fa23e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions model/riscv_sys_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,11 @@ function legalize_mip(o : Minterrupts, v : xlenbits) -> Minterrupts = {
/* The only writable bits are the S-mode bits, and with the 'N'
* extension, the U-mode bits. */
let v = Mk_Minterrupts(v);
[o with SEI = v[SEI], STI = v[STI], SSI = v[SSI]]
[o with
SEI = if extensionEnabled(Ext_S) then v[SEI] else 0b0,
STI = if extensionEnabled(Ext_S) then v[STI] else 0b0,
SSI = if extensionEnabled(Ext_S) then v[SSI] else 0b0,
]
}

function legalize_mie(o : Minterrupts, v : xlenbits) -> Minterrupts = {
Expand All @@ -336,9 +340,9 @@ function legalize_mie(o : Minterrupts, v : xlenbits) -> Minterrupts = {
MEI = v[MEI],
MTI = v[MTI],
MSI = v[MSI],
SEI = v[SEI],
STI = v[STI],
SSI = v[SSI]
SEI = if extensionEnabled(Ext_S) then v[SEI] else 0b0,
STI = if extensionEnabled(Ext_S) then v[STI] else 0b0,
SSI = if extensionEnabled(Ext_S) then v[SSI] else 0b0,
]
}

Expand Down

0 comments on commit 07fa23e

Please sign in to comment.