From 0b9c639f19da48734cbf14b61f6ad200b7c70de9 Mon Sep 17 00:00:00 2001 From: Tim Hutt Date: Wed, 6 Nov 2024 14:40:21 +0000 Subject: [PATCH] Zero mstatus.UPIE/UIE bits in legalize_mstatus 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. --- model/riscv_sys_regs.sail | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/model/riscv_sys_regs.sail b/model/riscv_sys_regs.sail index 6693a45be..4e810d762 100644 --- a/model/riscv_sys_regs.sail +++ b/model/riscv_sys_regs.sail @@ -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)); /* FS is WARL, and making FS writable can support the M-mode emulation of an FPU * to support code running in S/U-modes. Spike does this, and for now, we match it,