Skip to contentSkip to conversation

target/openrisc: Fix FPCSR mask to allow setting DZF

PATCH New Stafford Horne 2 participants 2 messages Jan 10, 2020 – Jan 17, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target/openrisc: Fix FPCSR mask to allow setting DZF

The mask used when setting FPCSR allows setting bits 10 to 1. However, OpenRISC has flags and config bits in 11 to 1, 11 being Divide by Zero Flag (DZF). This seems like an off-by-one bug.

This was found when testing the GLIBC test suite which has test cases to set and clear all bits.

---
 target/openrisc/fpu_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target/openrisc/fpu_helper.c +1 -1
index 59e1413279..6f75ea0505 100644
@@ -70,7 +70,7 @@ void cpu_set_fpcsr(CPUOpenRISCState *env, uint32_t val)
         float_round_down
     };
 
-    env->fpcsr = val & 0x7ff;
+    env->fpcsr = val & 0xfff;
     set_float_rounding_mode(rm_to_sf[extract32(val, 1, 2)], &env->fp_status);
 }
 
Signature · 1 line
2.21.0
#1 lore raw

PATCH 1/1 target/openrisc: Fix FPCSR mask to allow setting DZF

Quoted 11 lines · Stafford Horne

The mask used when setting FPCSR allows setting bits 10 to 1. However, OpenRISC has flags and config bits in 11 to 1, 11 being Divide by Zero Flag (DZF). This seems like an off-by-one bug.

This was found when testing the GLIBC test suite which has test cases to set and clear all bits.

---
 target/openrisc/fpu_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, queued.

r~