arch-riscv: Updating the SD bit of mstatus upon the register read
Per RISC-V ISA Manual, vol II, section 126.96.36.199, page 26, the SD bit is
a read-only bit indicating whether any of FS, VS, and XS fields being
in the respective dirty state.
Per section 3.1.6, page 20, the SD bit is the most significant bit of
the mstatus register for both RV32 and RV64.
Per section 188.8.131.52, page 29, the explicit formula for updating the SD is,
SD = ((FS==DIRTY) | (XS==DIRTY) | (VS==DIRTY))
Previously in gem5, this bit is not updated anywhere in the gem5
implementation. This cause an issue of incorrectly saving the context
before entering the system call and consequently, incorecttly restoring
the context after a system call as described here .
Ideally, we want to update the SD after every relevant instruction;
however, lazily updating the Status register upon its read produces
the same effect.
Signed-off-by: Hoa Nguyen <firstname.lastname@example.org>
Maintainer: Jason Lowe-Power <email@example.com>
Reviewed-by: Jason Lowe-Power <firstname.lastname@example.org>
Tested-by: kokoro <email@example.com>
1 file changed