diff options
author | Tim Newsome <tim@sifive.com> | 2022-04-01 13:29:01 -0700 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2022-04-05 10:09:56 -0700 |
commit | 21975f9ebc19c90798e0e559a015f352e45e3e50 (patch) | |
tree | 1a150ce763a4bf2d2d2e4c8956c39d65529f4b58 | |
parent | 02b3b36901daa3e030af40c71ac2418fc80fd90e (diff) | |
download | spike-21975f9ebc19c90798e0e559a015f352e45e3e50.zip spike-21975f9ebc19c90798e0e559a015f352e45e3e50.tar.gz spike-21975f9ebc19c90798e0e559a015f352e45e3e50.tar.bz2 |
Turn unsupported mcontrol.match into a supported one.
This way you cannot get the assert in mcontrol_t::simple_match() by
writing an "incorrect" value to tdata1.
-rw-r--r-- | riscv/triggers.cc | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc index 527ae71..5acca77 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -41,7 +41,20 @@ bool mcontrol_t::tdata1_write(processor_t *proc, const reg_t val) noexcept { timing = get_field(val, MCONTROL_TIMING); action = (triggers::action_t) get_field(val, MCONTROL_ACTION); chain = get_field(val, MCONTROL_CHAIN); - match = (triggers::mcontrol_t::match_t) get_field(val, MCONTROL_MATCH); + unsigned match_value = get_field(val, MCONTROL_MATCH); + switch (match_value) { + case MATCH_EQUAL: + case MATCH_NAPOT: + case MATCH_GE: + case MATCH_LT: + case MATCH_MASK_LOW: + case MATCH_MASK_HIGH: + match = (triggers::mcontrol_t::match_t) match_value; + break; + default: + match = MATCH_EQUAL; + break; + } m = get_field(val, MCONTROL_M); h = get_field(val, MCONTROL_H); s = get_field(val, MCONTROL_S); |