Skip to content

Commit 6e8cc9d

Browse files
committed
Only implement tcontrol to handle reentrant triggers.
The spec says to only implement a single option. Option 2 gives software more flexibility, and we already have an implementation. Let's use that one. See also riscv-software-src#1777.
1 parent a8c9d9c commit 6e8cc9d

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

riscv/triggers.cc

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,21 +110,6 @@ bool trigger_t::textra_match(processor_t * const proc) const noexcept
110110
return true;
111111
}
112112

113-
bool trigger_t::allow_action(const state_t * const state) const
114-
{
115-
if (get_action() == ACTION_DEBUG_EXCEPTION) {
116-
const bool mstatus_mie = state->mstatus->read() & MSTATUS_MIE;
117-
const bool sstatus_sie = state->sstatus->read() & MSTATUS_SIE;
118-
const bool vsstatus_sie = state->vsstatus->read() & MSTATUS_SIE;
119-
const bool medeleg_breakpoint = (state->medeleg->read() >> CAUSE_BREAKPOINT) & 1;
120-
const bool hedeleg_breakpoint = (state->hedeleg->read() >> CAUSE_BREAKPOINT) & 1;
121-
return (state->prv != PRV_M || mstatus_mie) &&
122-
(state->prv != PRV_S || state->v || !medeleg_breakpoint || sstatus_sie) &&
123-
(state->prv != PRV_S || !state->v || !medeleg_breakpoint || !hedeleg_breakpoint || vsstatus_sie);
124-
}
125-
return true;
126-
}
127-
128113
reg_t disabled_trigger_t::tdata1_read(const processor_t * const proc) const noexcept
129114
{
130115
auto xlen = proc->get_xlen();
@@ -235,7 +220,7 @@ std::optional<match_result_t> mcontrol_common_t::detect_memory_access_match(proc
235220
value &= 0xffffffff;
236221
}
237222

238-
if (simple_match(xlen, value) && allow_action(proc->get_state())) {
223+
if (simple_match(xlen, value)) {
239224
/* This is OK because this function is only called if the trigger was not
240225
* inhibited by the previous trigger in the chain. */
241226
set_hit(timing ? HIT_IMMEDIATELY_AFTER : HIT_BEFORE);
@@ -316,7 +301,7 @@ void mcontrol6_t::tdata1_write(processor_t * const proc, const reg_t val, const
316301

317302
std::optional<match_result_t> icount_t::detect_icount_fire(processor_t * const proc) noexcept
318303
{
319-
if (!common_match(proc) || !allow_action(proc->get_state()))
304+
if (!common_match(proc))
320305
return std::nullopt;
321306

322307
std::optional<match_result_t> ret = std::nullopt;
@@ -331,7 +316,7 @@ std::optional<match_result_t> icount_t::detect_icount_fire(processor_t * const p
331316

332317
void icount_t::detect_icount_decrement(processor_t * const proc) noexcept
333318
{
334-
if (!common_match(proc) || !allow_action(proc->get_state()))
319+
if (!common_match(proc))
335320
return;
336321

337322
if (count >= 1) {
@@ -423,7 +408,7 @@ std::optional<match_result_t> trap_common_t::detect_trap_match(processor_t * con
423408
bool interrupt = (t.cause() & ((reg_t)1 << (xlen - 1))) != 0;
424409
reg_t bit = t.cause() & ~((reg_t)1 << (xlen - 1));
425410
assert(bit < xlen);
426-
if (simple_match(interrupt, bit) && allow_action(proc->get_state())) {
411+
if (simple_match(interrupt, bit)) {
427412
hit = true;
428413
return match_result_t(TIMING_AFTER, action);
429414
}

riscv/triggers.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ class trigger_t {
9999
protected:
100100
static action_t legalize_action(reg_t val, reg_t action_mask, reg_t dmode_mask) noexcept;
101101
bool common_match(processor_t * const proc, bool use_prev_prv = false) const noexcept;
102-
bool allow_action(const state_t * const state) const;
103102
reg_t tdata2;
104103

105104
bool vs = false;

0 commit comments

Comments
 (0)