target/riscv: mask vxrm csrw write to the low 2 bits
PATCH v2 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. Used existing macros for bit-masking. Previous had a hard-coded value.
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
@@ -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 & (VCSR_VXRM >>VCSR_VXRM_SHIFT );return RISCV_EXCP_NONE ; }
Signature · 1 line
2.54.0
Quoted 7 lines · Abhigyan Kumar
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."
Quoted 6 lines
QEMU wrote full value into
env->vxrmcausing read of upper bits too. Used existing macros for bit-masking. Previous had a hard-coded value.Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3470
Signed-off-by Abhigyan Kumar <[email protected]>---
Quoted 16 lines
target/riscv/csr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/csr.c +1
-1@@ -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 & (VCSR_VXRM >>VCSR_VXRM_SHIFT );return RISCV_EXCP_NONE ; }
Quoted 8 lines · Abhigyan Kumar
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."
Quoted 5 lines
QEMU wrote full value into
env->vxrmcausing read of upper bits too. Used existing macros for bit-masking. Previous had a hard-coded value.Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3470
Signed-off-by Abhigyan Kumar <[email protected]>
Alistair
Quoted 21 lines
--- target/riscv/csr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/csr.c +1
-2@@ -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 & (VCSR_VXRM >>VCSR_VXRM_SHIFT );return RISCV_EXCP_NONE ; } --2.54.0
Alistair Francis
AppliedQuoted 8 lines · Abhigyan Kumar
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."
Quoted 5 lines
QEMU wrote full value into
env->vxrmcausing read of upper bits too. Used existing macros for bit-masking. Previous had a hard-coded value.Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3470
Signed-off-by Abhigyan Kumar <[email protected]>
Thanks!
Applied to riscv-to-apply.next
Alistair
Quoted 21 lines
--- target/riscv/csr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)target/riscv/csr.c +1
-2@@ -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 & (VCSR_VXRM >>VCSR_VXRM_SHIFT );return RISCV_EXCP_NONE ; } --2.54.0