diff options
author | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-03-16 18:48:49 -0700 |
---|---|---|
committer | Chih-Min Chao <chihmin.chao@sifive.com> | 2020-03-23 21:53:53 -0700 |
commit | 7bdc7c2017239f0673b25be6961743763a8413c3 (patch) | |
tree | b730cf15caa737ce8f56ba7417f277f29efc12e3 /riscv/execute.cc | |
parent | b4add16f4923a782f79b478d980791ec1d0bee06 (diff) | |
download | spike-7bdc7c2017239f0673b25be6961743763a8413c3.zip spike-7bdc7c2017239f0673b25be6961743763a8413c3.tar.gz spike-7bdc7c2017239f0673b25be6961743763a8413c3.tar.bz2 |
commitlog: fix wrong dump when exception occurs
1. store_fault_access
reorder the log and slow_path code
2. misaligned_access
reset the log buffer in the beginning rather at the end of execution to
avoid that uncompleted execution status is brought to the next
instruction
Signed-off-by: Chih-Min Chao <chihmin.chao@sifive.com>
Diffstat (limited to 'riscv/execute.cc')
-rw-r--r-- | riscv/execute.cc | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/riscv/execute.cc b/riscv/execute.cc index 12dd781..2d84242 100644 --- a/riscv/execute.cc +++ b/riscv/execute.cc @@ -4,15 +4,20 @@ #include "mmu.h" #include <cassert> +#ifdef RISCV_ENABLE_COMMITLOG +static void commit_log_reset(processor_t* p) +{ + p->get_state()->log_reg_write.clear(); + p->get_state()->log_mem_read.clear(); + p->get_state()->log_mem_write.clear(); +} static void commit_log_stash_privilege(processor_t* p) { -#ifdef RISCV_ENABLE_COMMITLOG state_t* state = p->get_state(); state->last_inst_priv = state->prv; state->last_inst_xlen = p->get_xlen(); state->last_inst_flen = p->get_flen(); -#endif } static void commit_log_print_value(int width, const void *data) @@ -50,7 +55,6 @@ static void commit_log_print_value(int width, uint64_t hi, uint64_t lo) static void commit_log_print_insn(processor_t* p, reg_t pc, insn_t insn) { -#ifdef RISCV_ENABLE_COMMITLOG auto& reg = p->get_state()->log_reg_write; auto& load = p->get_state()->log_mem_read; auto& store = p->get_state()->log_mem_write; @@ -122,11 +126,12 @@ static void commit_log_print_insn(processor_t* p, reg_t pc, insn_t insn) commit_log_print_value(std::get<2>(item) << 3, 0, std::get<1>(item)); } fprintf(stderr, "\n"); - reg.clear(); - load.clear(); - store.clear(); -#endif } +#else +static void commit_log_reset(processor_t* p) {} +static void commit_log_stash_privilege(processor_t* p) {} +static void commit_log_print_insn(processor_t* p, reg_t pc, insn_t insn) {} +#endif inline void processor_t::update_histogram(reg_t pc) { @@ -140,7 +145,9 @@ inline void processor_t::update_histogram(reg_t pc) // function calls. static reg_t execute_insn(processor_t* p, reg_t pc, insn_fetch_t fetch) { + commit_log_reset(p); commit_log_stash_privilege(p); + reg_t npc = fetch.func(p, fetch.insn, pc); if (npc != PC_SERIALIZE_BEFORE) { if (p->get_log_commits()) { |