commit log now correctly prints privilege
authorScott Beamer <sbeamer@eecs.berkeley.edu>
Wed, 16 Sep 2015 00:43:37 +0000 (17:43 -0700)
committerScott Beamer <sbeamer@eecs.berkeley.edu>
Wed, 16 Sep 2015 00:43:37 +0000 (17:43 -0700)
adopting convention of privilege at time of commit, not after commit

riscv/execute.cc
riscv/processor.h

index 42d59cb4ce5295fe3248efda2562e322298b3c0a..249d6aefe0eb22ba6efeb8fe0e720387a38ed8f4 100644 (file)
@@ -4,10 +4,18 @@
 #include "mmu.h"
 #include <cassert>
 
-static void commit_log(state_t* state, reg_t pc, insn_t insn)
+
+static void commit_log_stash_privilege(state_t* state)
+{
+#ifdef RISCV_ENABLE_COMMITLOG
+  state->last_inst_priv = get_field(state->mstatus, MSTATUS_PRV);
+#endif
+}
+
+static void commit_log_print_insn(state_t* state, reg_t pc, insn_t insn)
 {
 #ifdef RISCV_ENABLE_COMMITLOG
-  int32_t priv = get_field(state->mstatus, MSTATUS_PRV);
+  int32_t priv = state->last_inst_priv;
   uint64_t mask = (insn.length() == 8 ? uint64_t(0) : (uint64_t(1) << (insn.length() * 8))) - 1;
   if (state->log_reg_write.addr) {
     fprintf(stderr, "%1d 0x%016" PRIx64 " (0x%08" PRIx64 ") %c%2" PRIu64 " 0x%016" PRIx64 "\n",
@@ -34,9 +42,10 @@ inline void processor_t::update_histogram(size_t pc)
 
 static reg_t execute_insn(processor_t* p, reg_t pc, insn_fetch_t fetch)
 {
+  commit_log_stash_privilege(p->get_state());
   reg_t npc = fetch.func(p, fetch.insn, pc);
   if (npc != PC_SERIALIZE) {
-    commit_log(p->get_state(), pc, fetch.insn);
+    commit_log_print_insn(p->get_state(), pc, fetch.insn);
     p->update_histogram(pc);
   }
   return npc;
index d117ff1acbcc1d8988b68e412b373739efdbf6c4..f1de05efb00c0c56d8b4d3b6fd02639694df940b 100644 (file)
@@ -67,6 +67,7 @@ struct state_t
 
 #ifdef RISCV_ENABLE_COMMITLOG
   commit_log_reg_t log_reg_write;
+  reg_t last_inst_priv;
 #endif
 };