Serialize simulator on ERET
authorAndrew Waterman <waterman@cs.berkeley.edu>
Mon, 8 Feb 2016 01:04:28 +0000 (17:04 -0800)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Wed, 2 Mar 2016 20:15:25 +0000 (12:15 -0800)
This guarantees interrupts will eventually be taken.

riscv/decode.h
riscv/insns/sret.h

index 1dfeac1bf7c715be628ff17f9c8338ba499cdab6..f8437cae5f178c87c510f5aca039cf2b7c2e7069 100644 (file)
@@ -198,6 +198,12 @@ private:
        npc = sext_xlen(x); \
      } while(0)
 
+#define set_pc_and_serialize(x) \
+  do { set_pc(x); /* check alignment */ \
+       npc = PC_SERIALIZE; \
+       STATE.pc = (x); \
+     } while(0)
+
 #define PC_SERIALIZE 3 /* sentinel value indicating simulator pipeline flush */
 
 /* Convenience wrappers to simplify softfloat code sequences */
index eacf5bee5ff9cad6ce9106a8176b1b2281b99a18..c3561d38e45a8f6cfce93df9ccca339e89b5eb72 100644 (file)
@@ -1,8 +1,8 @@
 require_privilege(PRV_S);
 switch (STATE.prv)
 {
-  case PRV_S: set_pc(p->get_state()->sepc); break;
-  case PRV_M: set_pc(p->get_state()->mepc); break;
+  case PRV_S: set_pc_and_serialize(p->get_state()->sepc); break;
+  case PRV_M: set_pc_and_serialize(p->get_state()->mepc); break;
   default: abort();
 }