diff options
author | Tim Newsome <tim@casualhacker.net> | 2024-08-12 09:13:38 -0700 |
---|---|---|
committer | Tim Newsome <tim@casualhacker.net> | 2024-08-19 09:43:41 -0700 |
commit | 1a15805b946c2110cda279a4b7d84a382d0065b9 (patch) | |
tree | bd336030110f1e11d907c9e0033f24c2fe909fa0 | |
parent | 6f28e4bee53b3c49d6b3b06db5989bc5ec7933f4 (diff) | |
download | riscv-isa-sim-1a15805b946c2110cda279a4b7d84a382d0065b9.zip riscv-isa-sim-1a15805b946c2110cda279a4b7d84a382d0065b9.tar.gz riscv-isa-sim-1a15805b946c2110cda279a4b7d84a382d0065b9.tar.bz2 |
Fix mcontrol6 mask low/high operations.
I doubt this code was ever tested, and this change isn't tested either,
because OpenOCD doesn't use this trigger type.
This problem was reported in
https://github.com/riscv/riscv-debug-spec/issues/1057
-rw-r--r-- | riscv/triggers.cc | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/riscv/triggers.cc b/riscv/triggers.cc index de3da40..9eac968 100644 --- a/riscv/triggers.cc +++ b/riscv/triggers.cc @@ -195,13 +195,17 @@ bool mcontrol_common_t::simple_match(unsigned xlen, reg_t value) const { return value < tdata2; case MATCH_MASK_LOW: { - reg_t mask = tdata2 >> (xlen/2); - return (value & mask) == (tdata2 & mask); + reg_t tdata2_high = tdata2 >> (xlen/2); + reg_t tdata2_low = tdata2 & ((reg_t(1) << (xlen/2)) - 1); + reg_t value_low = value & ((reg_t(1) << (xlen/2)) - 1); + return (value_low & tdata2_high) == tdata2_low; } case MATCH_MASK_HIGH: { - reg_t mask = tdata2 >> (xlen/2); - return ((value >> (xlen/2)) & mask) == (tdata2 & mask); + reg_t tdata2_high = tdata2 >> (xlen/2); + reg_t tdata2_low = tdata2 & ((reg_t(1) << (xlen/2)) - 1); + reg_t value_high = value >> (xlen/2); + return (value_high & tdata2_high) == tdata2_low; } } assert(0); |