Forvis_RISCV-ISA-Spec
Forvis_RISCV-ISA-Spec copied to clipboard
MXL feature - not working
I was trying to test the MXL feature on forvis. I think I found a few issues in that:
-
When running forvis with the --RV64 flag, if I change the MISA.MXL field from 2 (default reset value) to 1 the architecture enters RV32 mode (as per latest privelege spec page 14). Now if the next instruction is an "LD" (from the RV64I extension) shouldn't the model raise an exception since this is not a valid RV32I instruction? This doesn't seem to be happening.
-
In the similar situation as above, once I set MISA.MXL to 1 and execute the following piece of assembly:
li a1, 0xFFFFFFFF00000000;
addi a2, a1, 1;
According to spec the result in a2 should be 0x0000000000000001 but forvis gives a result of: 0xFFFFFFFF00000001. Isn't this wrong as well?
I am using the following piece of assembly to change MISA.MXL which seems to be reflecting correctly for forvis in the MISA value
li a1, 0x4000000000000000;
li a2, 0x3FFFFFFFFFFFFFFF;
csrrs x6, misa, x0;
and x7, a2, x6;
or x7, x7, a1;
csrrw x4, misa, x7;
csrrs x6, misa, x0;
Is the above the correct way to change MXL?
BTW: I tried changing the UXL and SXL fields in mstatus but for some reason they are not reflected in forvis.
Thanks, Neel
You are correct, Forvis is not yet properly handling dynamic changes to WARL fields such as MISA.MXL, MSTATUS.SXL and MSTATUS.UXL. These are still on my TODO list (marked as such in the Haskell code). My initial focus had been to get the ISA tests and Linux kernel boot running, none of which make such dynamic changes, and I haven't yet started on implementing dynamic changes.
Currently MISA.MXL is writable, but the code for LD/SD is not correctly checking for the "current" RV value (32/64), instead relying on the creation-time value. This is a bug I have to fix.
Currently MSTATUS.SXL and MSTATUS.UXL are read-only. Again, this will be fixed.