On 5/21/20 2:43 AM, LIU Zhiwei wrote:
@@ -174,6 +175,9 @@ static int write_frm(CPURISCVState *env, int csrno,
target_ulong val)
env->mstatus |= MSTATUS_FS;
#endif
env->frm = val & (FSR_RD >> FSR_RD_SHIFT);
+ if (!riscv_cpu_set_rounding_mode(env, env->frm)) {
+ return -1;
+ }
This will raise an exception immediately in helper_csrrw().
According to Section 8.2, the no exception should occur until the next fp
operation that uses the invalid frm.
You're doing this just fine in helper_set_rounding_mode(), which is sufficient
for scalar fp ops. Without looking forward to later patches, I suppose we'll
need to do something else for vector fp ops.