Allow writing mstatus.fs even if FPU isn't present
authorAndrew Waterman <waterman@cs.berkeley.edu>
Tue, 31 Mar 2015 23:07:56 +0000 (16:07 -0700)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Tue, 31 Mar 2015 23:07:56 +0000 (16:07 -0700)
This allows the OS to track FP state dirtiness.

riscv/decode.h
riscv/processor.cc

index a1c28d50827d6a0a0a888c84595bc4dff77a6ad8..5d304a123a7c404e75ec3d43d8562114c1de4ff3 100644 (file)
@@ -173,7 +173,11 @@ private:
 #define require_privilege(p) if (get_field(STATE.mstatus, MSTATUS_PRV) < (p)) throw trap_illegal_instruction()
 #define require_rv64 if(unlikely(xlen != 64)) throw trap_illegal_instruction()
 #define require_rv32 if(unlikely(xlen != 32)) throw trap_illegal_instruction()
-#define require_fp if (unlikely((STATE.mstatus & MSTATUS_FS) == 0)) throw trap_illegal_instruction()
+#ifdef RISCV_ENABLE_FPU
+# define require_fp if (unlikely((STATE.mstatus & MSTATUS_FS) == 0)) throw trap_illegal_instruction()
+#else
+# define require_fp throw trap_illegal_instruction()
+#endif
 #define require_accelerator if (unlikely((STATE.mstatus & MSTATUS_XS) == 0)) throw trap_illegal_instruction()
 
 #define cmp_trunc(reg) (reg_t(reg) << (64-xlen))
index afae1ce348913b5e7f8dd0affc0ad6707ca3cc6c..51e56b1a46629a949de6a151b679ca9540d7dadb 100644 (file)
@@ -335,10 +335,7 @@ void processor_t::set_csr(int which, reg_t val)
         mmu->flush_tlb();
 
       reg_t mask = MSTATUS_SSIP | MSTATUS_MSIP | MSTATUS_IE | MSTATUS_IE1
-                   | MSTATUS_IE2 | MSTATUS_IE3 | MSTATUS_STIE;
-#ifdef RISCV_ENABLE_FPU
-      mask |= MSTATUS_FS;
-#endif
+                   | MSTATUS_IE2 | MSTATUS_IE3 | MSTATUS_STIE | MSTATUS_FS;
       if (ext)
         mask |= MSTATUS_XS;
       state.mstatus = (state.mstatus & ~mask) | (val & mask);