Take interrupts as soon as interrupts are enabled
authorAndrew Waterman <waterman@cs.berkeley.edu>
Wed, 20 May 2015 20:49:01 +0000 (13:49 -0700)
committerAndrew Waterman <waterman@cs.berkeley.edu>
Mon, 1 Jun 2015 01:29:45 +0000 (18:29 -0700)
Previously, if interrupts were enabled then disabled quickly enough,
no interrupt would ever be taken, resulting in deadlock.

riscv/insns/c_addi4.h [deleted file]
riscv/insns/c_jalr.h [deleted file]
riscv/processor.cc
riscv/processor.h

diff --git a/riscv/insns/c_addi4.h b/riscv/insns/c_addi4.h
deleted file mode 100644 (file)
index 3c9b7b2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-require_extension('C');
-WRITE_RD(sext_xlen(RVC_RS2 + insn.rvc_lwsp_imm()));
diff --git a/riscv/insns/c_jalr.h b/riscv/insns/c_jalr.h
deleted file mode 100644 (file)
index ef6edfc..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-require_extension('C');
-reg_t tmp = npc;
-set_pc(RVC_RS1 & ~reg_t(1));
-WRITE_RD(tmp);
index 2978ef81a4777380b43576a0dc83bfbfbb4edabe..b8e848bd61cbeae8eb1a9e5423bb0ceaa66e1809 100644 (file)
@@ -230,7 +230,7 @@ void processor_t::step(size_t n)
    if (unlikely(pc == PC_SERIALIZE)) { \
      pc = state.pc; \
      state.serialized = true; \
-     continue; \
+     break; \
    }
 
   try
@@ -276,7 +276,7 @@ void processor_t::step(size_t n)
   }
   catch(trap_t& t)
   {
-    state.pc = take_trap(t, pc);
+    take_trap(t, pc);
   }
 
   update_timer(&state, instret);
@@ -307,19 +307,18 @@ void processor_t::pop_privilege_stack()
   set_csr(CSR_MSTATUS, s);
 }
 
-reg_t processor_t::take_trap(trap_t& t, reg_t epc)
+void processor_t::take_trap(trap_t& t, reg_t epc)
 {
   if (debug)
     fprintf(stderr, "core %3d: exception %s, epc 0x%016" PRIx64 "\n",
             id, t.name(), epc);
 
-  reg_t tvec = DEFAULT_MTVEC + 0x40 * get_field(state.mstatus, MSTATUS_PRV);
+  state.pc = DEFAULT_MTVEC + 0x40 * get_field(state.mstatus, MSTATUS_PRV);
   push_privilege_stack();
   yield_load_reservation();
   state.mcause = t.cause();
   state.mepc = epc;
   t.side_effects(&state); // might set badvaddr etc.
-  return tvec;
 }
 
 void processor_t::deliver_ipi()
index 61d77cb8be79a52eff422a9d1c48f87fbb4cdab3..1d497d0c8ef5f5678d2bc90e7f5405d3eee0075b 100644 (file)
@@ -119,7 +119,7 @@ private:
   std::map<size_t,size_t> pc_histogram;
 
   void take_interrupt(); // take a trap if any interrupts are pending
-  reg_t take_trap(trap_t& t, reg_t epc); // take an exception
+  void take_trap(trap_t& t, reg_t epc); // take an exception
   void disasm(insn_t insn); // disassemble and print an instruction
 
   friend class sim_t;