@@ -66,8 +66,30 @@ bool trigger_t::common_match(processor_t * const proc, bool use_prev_prv) const
66
66
auto state = proc->get_state ();
67
67
auto prv = use_prev_prv ? state->prev_prv : state->prv ;
68
68
auto v = use_prev_prv ? state->prev_v : state->v ;
69
- auto m_enabled = get_action () != 0 || (tcontrol_value (state) & CSR_TCONTROL_MTE);
70
- return (prv < PRV_M || m_enabled) && mode_match (prv, v) && textra_match (proc);
69
+
70
+ if (!mode_match (prv, v))
71
+ return false ;
72
+
73
+ if (!textra_match (proc))
74
+ return false ;
75
+
76
+ if (get_action () == ACTION_DEBUG_EXCEPTION) {
77
+ const bool mstatus_mie = state->mstatus ->read () & MSTATUS_MIE;
78
+ if (prv == PRV_M && !mstatus_mie)
79
+ return false ;
80
+
81
+ const bool sstatus_sie = state->sstatus ->read () & MSTATUS_SIE;
82
+ const bool medeleg_breakpoint = (state->medeleg ->read () >> CAUSE_BREAKPOINT) & 1 ;
83
+ if (prv == PRV_S && !v && medeleg_breakpoint && !sstatus_sie)
84
+ return false ;
85
+
86
+ const bool vsstatus_sie = state->vsstatus ->read () & MSTATUS_SIE;
87
+ const bool hedeleg_breakpoint = (state->hedeleg ->read () >> CAUSE_BREAKPOINT) & 1 ;
88
+ if (prv == PRV_S && v && medeleg_breakpoint && hedeleg_breakpoint && !vsstatus_sie)
89
+ return false ;
90
+ }
91
+
92
+ return true ;
71
93
}
72
94
73
95
bool trigger_t::mode_match (reg_t prv, bool v) const noexcept
@@ -117,22 +139,6 @@ bool trigger_t::textra_match(processor_t * const proc) const noexcept
117
139
return true ;
118
140
}
119
141
120
- bool trigger_t::allow_action (processor_t * const proc) const
121
- {
122
- const state_t *state = proc->get_state ();
123
- if (get_action () == ACTION_DEBUG_EXCEPTION) {
124
- const bool mstatus_mie = state->mstatus ->read () & MSTATUS_MIE;
125
- const bool sstatus_sie = state->sstatus ->read () & MSTATUS_SIE;
126
- const bool vsstatus_sie = state->vsstatus ->read () & MSTATUS_SIE;
127
- const bool medeleg_breakpoint = (state->medeleg ->read () >> CAUSE_BREAKPOINT) & 1 ;
128
- const bool hedeleg_breakpoint = (state->hedeleg ->read () >> CAUSE_BREAKPOINT) & 1 ;
129
- return (state->prv != PRV_M || mstatus_mie) &&
130
- (state->prv != PRV_S || state->v || !medeleg_breakpoint || sstatus_sie) &&
131
- (state->prv != PRV_S || !state->v || !medeleg_breakpoint || !hedeleg_breakpoint || vsstatus_sie);
132
- }
133
- return true ;
134
- }
135
-
136
142
reg_t disabled_trigger_t::tdata1_read (const processor_t * const proc) const noexcept
137
143
{
138
144
auto xlen = proc->get_xlen ();
@@ -243,7 +249,7 @@ std::optional<match_result_t> mcontrol_common_t::detect_memory_access_match(proc
243
249
value &= 0xffffffff ;
244
250
}
245
251
246
- if (simple_match (xlen, value) && allow_action (proc) ) {
252
+ if (simple_match (xlen, value)) {
247
253
/* This is OK because this function is only called if the trigger was not
248
254
* inhibited by the previous trigger in the chain. */
249
255
set_hit (timing ? HIT_IMMEDIATELY_AFTER : HIT_BEFORE);
@@ -332,7 +338,7 @@ void mcontrol6_t::tdata1_write(processor_t * const proc, const reg_t val, const
332
338
333
339
std::optional<match_result_t > icount_t::detect_icount_fire (processor_t * const proc) noexcept
334
340
{
335
- if (!common_match (proc) || ! allow_action (proc) )
341
+ if (!common_match (proc))
336
342
return std::nullopt;
337
343
338
344
std::optional<match_result_t > ret = std::nullopt;
@@ -347,7 +353,7 @@ std::optional<match_result_t> icount_t::detect_icount_fire(processor_t * const p
347
353
348
354
void icount_t::detect_icount_decrement (processor_t * const proc) noexcept
349
355
{
350
- if (!common_match (proc) || ! allow_action (proc) )
356
+ if (!common_match (proc))
351
357
return ;
352
358
353
359
if (count >= 1 ) {
@@ -439,7 +445,7 @@ std::optional<match_result_t> trap_common_t::detect_trap_match(processor_t * con
439
445
bool interrupt = (t.cause () & ((reg_t )1 << (xlen - 1 ))) != 0 ;
440
446
reg_t bit = t.cause () & ~((reg_t )1 << (xlen - 1 ));
441
447
assert (bit < xlen);
442
- if (simple_match (interrupt, bit) && allow_action (proc) ) {
448
+ if (simple_match (interrupt, bit)) {
443
449
hit = true ;
444
450
return match_result_t (TIMING_AFTER, action);
445
451
}
0 commit comments