Skip to contentSkip to conversation

target/riscv: mask vxrm csrw write to the low 2 bits

PATCH Superseded Abhigyan Kumar 1 participant 1 message May 30 RISC-V

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/riscv: mask vxrm csrw write to the low 2 bits

Citing the RISC-V specification:

"The vector fixed-point rounding-mode register holds a two-bit read-write rounding-mode field in the least-significant bits (vxrm[1:0]). The upper bits, vxrm[XLEN-1:2], should be written as zeros."

QEMU wrote full value into env->vxrm causing read of upper bits too. The 2-bit mask has been added with this change to prevent it.

Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3470

---
 target/riscv/csr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/riscv/csr.c +1 -1
index 5514e0f45..f5b0895fd 100644
@@ -977,7 +977,7 @@ static RISCVException write_vxrm(CPURISCVState *env, int csrno,
 #if !defined(CONFIG_USER_ONLY)
     env->mstatus |= MSTATUS_VS;
 #endif
-    env->vxrm = val;
+    env->vxrm = val & 0x03;
     return RISCV_EXCP_NONE;
 }
 
Signature · 1 line
2.54.0