Skip to content

Commit

Permalink
Zero mstatus.UPIE/UIE bits in legalize_mstatus
Browse files Browse the repository at this point in the history
This was missed when we removed the N extension.

I'm not really a fan of this code style - in other places we explicitly copy the bits that *are* implemented using their field names, which is also not ideal but definitely better and less error prone. We should change this code to do that at some point. I added a TODO.
  • Loading branch information
Timmmm committed Nov 5, 2024
1 parent b8d1fa5 commit c75b379
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion model/riscv_sys_regs.sail
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ function legalize_mstatus(o : Mstatus, v : xlenbits) -> Mstatus = {
* that does not have a matching bitfield entry. All bits above 32 are handled
* explicitly later.
*/
let m : Mstatus = Mk_Mstatus(zero_extend(v[22 .. 7] @ 0b0 @ v[5 .. 3] @ 0b0 @ v[1 .. 0]));
// TODO: This method is error prone. We should instead explicitly copy the
// fields that are implemented. See legalize_mie() for an example.
let m : Mstatus = Mk_Mstatus(zero_extend(v[22 .. 7] @ 0b0 @ v[5 .. 5] @ 0b0 @ v[3 .. 3] @ 0b0 @ v[1 .. 1] @ 0b0));

/* Legalize MPP */
let m = [m with MPP = if have_privLevel(m[MPP]) then m[MPP]
Expand Down

0 comments on commit c75b379

Please sign in to comment.