target/openrisc: Fix FPCSR mask to allow setting DZF
authorStafford Horne <shorne@gmail.com>
Fri, 10 Jan 2020 21:28:43 +0000 (06:28 +0900)
committerRichard Henderson <richard.henderson@linaro.org>
Fri, 17 Jan 2020 00:50:43 +0000 (14:50 -1000)
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.

Signed-off-by: Stafford Horne <shorne@gmail.com>
Message-Id: <20200110212843.27335-1-shorne@gmail.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
target/openrisc/fpu_helper.c

index 59e1413279148917dff5bd50f1345992000cfcda..6f75ea0505b90d3e302786c6156559c102d5ada0 100644 (file)
@@ -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);
 }