|
|
|
@ -66,8 +66,30 @@ bool trigger_t::common_match(processor_t * const proc, bool use_prev_prv) const |
|
|
|
auto state = proc->get_state(); |
|
|
|
auto prv = use_prev_prv ? state->prev_prv : state->prv; |
|
|
|
auto v = use_prev_prv ? state->prev_v : state->v; |
|
|
|
auto m_enabled = get_action() != 0 || (tcontrol_value(state) & CSR_TCONTROL_MTE); |
|
|
|
return (prv < PRV_M || m_enabled) && mode_match(prv, v) && textra_match(proc); |
|
|
|
|
|
|
|
if (!mode_match(prv, v)) |
|
|
|
return false; |
|
|
|
|
|
|
|
if (!textra_match(proc)) |
|
|
|
return false; |
|
|
|
|
|
|
|
if (get_action() == ACTION_DEBUG_EXCEPTION) { |
|
|
|
const bool mstatus_mie = state->mstatus->read() & MSTATUS_MIE; |
|
|
|
if (prv == PRV_M && !mstatus_mie) |
|
|
|
return false; |
|
|
|
|
|
|
|
const bool sstatus_sie = state->sstatus->read() & MSTATUS_SIE; |
|
|
|
const bool medeleg_breakpoint = (state->medeleg->read() >> CAUSE_BREAKPOINT) & 1; |
|
|
|
if (prv == PRV_S && !v && medeleg_breakpoint && !sstatus_sie) |
|
|
|
return false; |
|
|
|
|
|
|
|
const bool vsstatus_sie = state->vsstatus->read() & MSTATUS_SIE; |
|
|
|
const bool hedeleg_breakpoint = (state->hedeleg->read() >> CAUSE_BREAKPOINT) & 1; |
|
|
|
if (prv == PRV_S && v && medeleg_breakpoint && hedeleg_breakpoint && !vsstatus_sie) |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
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 |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
bool trigger_t::allow_action(processor_t * const proc) const |
|
|
|
{ |
|
|
|
const state_t *state = proc->get_state(); |
|
|
|
if (get_action() == ACTION_DEBUG_EXCEPTION) { |
|
|
|
const bool mstatus_mie = state->mstatus->read() & MSTATUS_MIE; |
|
|
|
const bool sstatus_sie = state->sstatus->read() & MSTATUS_SIE; |
|
|
|
const bool vsstatus_sie = state->vsstatus->read() & MSTATUS_SIE; |
|
|
|
const bool medeleg_breakpoint = (state->medeleg->read() >> CAUSE_BREAKPOINT) & 1; |
|
|
|
const bool hedeleg_breakpoint = (state->hedeleg->read() >> CAUSE_BREAKPOINT) & 1; |
|
|
|
return (state->prv != PRV_M || mstatus_mie) && |
|
|
|
(state->prv != PRV_S || state->v || !medeleg_breakpoint || sstatus_sie) && |
|
|
|
(state->prv != PRV_S || !state->v || !medeleg_breakpoint || !hedeleg_breakpoint || vsstatus_sie); |
|
|
|
} |
|
|
|
return true; |
|
|
|
} |
|
|
|
|
|
|
|
reg_t disabled_trigger_t::tdata1_read(const processor_t * const proc) const noexcept |
|
|
|
{ |
|
|
|
auto xlen = proc->get_xlen(); |
|
|
|
@ -243,7 +249,7 @@ std::optional<match_result_t> mcontrol_common_t::detect_memory_access_match(proc |
|
|
|
value &= 0xffffffff; |
|
|
|
} |
|
|
|
|
|
|
|
if (simple_match(xlen, value) && allow_action(proc)) { |
|
|
|
if (simple_match(xlen, value)) { |
|
|
|
/* This is OK because this function is only called if the trigger was not
|
|
|
|
* inhibited by the previous trigger in the chain. */ |
|
|
|
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 |
|
|
|
|
|
|
|
std::optional<match_result_t> icount_t::detect_icount_fire(processor_t * const proc) noexcept |
|
|
|
{ |
|
|
|
if (!common_match(proc) || !allow_action(proc)) |
|
|
|
if (!common_match(proc)) |
|
|
|
return std::nullopt; |
|
|
|
|
|
|
|
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 |
|
|
|
|
|
|
|
void icount_t::detect_icount_decrement(processor_t * const proc) noexcept |
|
|
|
{ |
|
|
|
if (!common_match(proc) || !allow_action(proc)) |
|
|
|
if (!common_match(proc)) |
|
|
|
return; |
|
|
|
|
|
|
|
if (count >= 1) { |
|
|
|
@ -439,7 +445,7 @@ std::optional<match_result_t> trap_common_t::detect_trap_match(processor_t * con |
|
|
|
bool interrupt = (t.cause() & ((reg_t)1 << (xlen - 1))) != 0; |
|
|
|
reg_t bit = t.cause() & ~((reg_t)1 << (xlen - 1)); |
|
|
|
assert(bit < xlen); |
|
|
|
if (simple_match(interrupt, bit) && allow_action(proc)) { |
|
|
|
if (simple_match(interrupt, bit)) { |
|
|
|
hit = true; |
|
|
|
return match_result_t(TIMING_AFTER, action); |
|
|
|
} |
|
|
|
|