Skip to content

Commit

Permalink
fix(dbltrp): critical-error is not treated as diff error (#492)
Browse files Browse the repository at this point in the history
* When both RTL and NEMU report a critical-error, the hardware behavior is considered correct.
  Upon detecting a critical-error, it should indicate a "good trap."
* If they do not report simultaneously, it results in a diff error and triggers an abort.
  • Loading branch information
lewislzh authored Nov 5, 2024
1 parent 7c4bd54 commit 4233651
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ coherence via RefillTest.
| `DiffLrScEvent` | Executed LR/SC instructions | No |
| `DiffNonRegInterruptPengingEvent` | Non-register interrupts pending | No |
| `DiffMhpmeventOverflowEvent` | Mhpmevent-register overflow | No |
| `DiffDiffCriticalErrorEvent` | Raise critical-error | No |
| `DiffCriticalErrorEvent` | Raise critical-error | No |

The DiffTest framework comes with a simulation framework with some top-level IOs.
They will be automatically created when calling `DifftestModule.finish(cpu: String)`.
Expand Down
12 changes: 9 additions & 3 deletions src/test/csrc/difftest/difftest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1302,9 +1302,15 @@ void Difftest::do_mhpmevent_overflow() {
#ifdef CONFIG_DIFFTEST_CRITICALERROREVENT
void Difftest::do_raise_critical_error() {
if (dut->critical_error.valid) {
display();
Info("Core %d dump: critical_error raise \n", this->id);
raise_trap(STATE_ABORT);
bool ref_critical_error = proxy->raise_critical_error();
if (ref_critical_error == dut->critical_error.criticalError) {
Info("Core %d dump: critical_error raise \n", this->id);
raise_trap(STATE_GOODTRAP);
} else {
display();
Info("Core %d dump: DUT critical_error diff REF \n", this->id);
raise_trap(STATE_ABORT);
}
}
}
#endif
Expand Down
11 changes: 8 additions & 3 deletions src/test/csrc/difftest/refproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,10 @@ class RefProxyConfig {
f(ref_memcpy_init, difftest_memcpy_init, void, uint64_t, void*, size_t, bool) \
f(raise_nmi_intr, difftest_raise_nmi_intr, void, bool) \
f(ref_virtual_interrupt_is_hvictl_inject, difftest_virtual_interrupt_is_hvictl_inject, void, bool) \
f(disambiguation_state, difftest_disambiguation_state, int, ) \
f(ref_non_reg_interrupt_pending, difftest_non_reg_interrupt_pending, void, void*) \
f(raise_mhpmevent_overflow, difftest_raise_mhpmevent_overflow, void, uint64_t)
f(disambiguation_state, difftest_disambiguation_state, int, ) \
f(ref_non_reg_interrupt_pending, difftest_non_reg_interrupt_pending, void, void*) \
f(raise_mhpmevent_overflow, difftest_raise_mhpmevent_overflow, void, uint64_t) \
f(ref_raise_critical_error, difftest_raise_critical_error, bool)

#define RefFunc(func, ret, ...) ret func(__VA_ARGS__)
#define DeclRefFunc(this_func, dummy, ret, ...) RefFunc((*this_func), ret, __VA_ARGS__);
Expand Down Expand Up @@ -258,6 +259,10 @@ class RefProxy : public AbstractRefProxy {
}
}

inline bool raise_critical_error() {
return ref_raise_critical_error ? ref_raise_critical_error() : false;
}

inline void guided_exec(struct ExecutionGuide &guide) {
return ref_guided_exec ? ref_guided_exec(&guide) : ref_exec(1);
}
Expand Down

0 comments on commit 4233651

Please sign in to comment.