aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerry Zhao <jerryz123@berkeley.edu>2023-01-02 16:29:42 -0800
committerJerry Zhao <jerryz123@berkeley.edu>2023-01-03 22:05:14 -0800
commit7334b0180e010dc7b9b89128db53045fe67bf3f4 (patch)
treeddbef88453ff8a868cd7c6a0c72836c8c1efaaca
parent4ac904b7c09c80c455e3006d3a934ea49b169ffd (diff)
downloadspike-7334b0180e010dc7b9b89128db53045fe67bf3f4.zip
spike-7334b0180e010dc7b9b89128db53045fe67bf3f4.tar.gz
spike-7334b0180e010dc7b9b89128db53045fe67bf3f4.tar.bz2
Fix debug-mode regression introduced by 20e7f53
- Debug mode should break the processor out of wfi - wfi in debug mode should execute as a nop
-rw-r--r--riscv/execute.cc12
-rw-r--r--riscv/processor.cc2
2 files changed, 9 insertions, 5 deletions
diff --git a/riscv/execute.cc b/riscv/execute.cc
index c922602..cd6ae1a 100644
--- a/riscv/execute.cc
+++ b/riscv/execute.cc
@@ -203,7 +203,7 @@ static inline reg_t execute_insn_logged(processor_t* p, reg_t pc, insn_fetch_t f
bool processor_t::slow_path()
{
return debug || state.single_step != state.STEP_NONE || state.debug_mode ||
- log_commits_enabled || histogram_enabled;
+ log_commits_enabled || histogram_enabled || in_wfi;
}
// fetch/decode/execute loop
@@ -242,10 +242,6 @@ void processor_t::step(size_t n)
try
{
take_pending_interrupt();
- if (unlikely(in_wfi)) {
- // No unmasked pending interrupt, so remain in wfi
- throw wait_for_interrupt_t();
- }
if (unlikely(slow_path()))
{
@@ -265,6 +261,12 @@ void processor_t::step(size_t n)
state.single_step = state.STEP_STEPPED;
}
+ // debug mode wfis must nop
+ if (unlikely(in_wfi && !state.debug_mode)) {
+ throw wait_for_interrupt_t();
+ }
+
+ in_wfi = false;
insn_fetch_t fetch = mmu->load_insn(pc);
if (debug && !state.serialized)
disasm(fetch.insn);
diff --git a/riscv/processor.cc b/riscv/processor.cc
index 666884f..c3c5d8f 100644
--- a/riscv/processor.cc
+++ b/riscv/processor.cc
@@ -537,6 +537,7 @@ void processor_t::reset()
state.dcsr->halt = halt_on_reset;
halt_on_reset = false;
VU.reset();
+ in_wfi = false;
if (n_pmp > 0) {
// For backwards compatibility with software that is unaware of PMP,
@@ -744,6 +745,7 @@ void processor_t::enter_debug_mode(uint8_t cause)
set_privilege(PRV_M);
state.dpc->write(state.pc);
state.pc = DEBUG_ROM_ENTRY;
+ in_wfi = false;
}
void processor_t::debug_output_log(std::stringstream *s)