Skip to content

Commit

Permalink
target/riscv: Mismatch napot when mcontrol.maskmax is zero
Browse files Browse the repository at this point in the history
Change-Id: Ib22f6ba3bdd4a5acfbbb4ac630eb420ae1f8bd78
Signed-off-by: Songhe Zhu <[email protected]>
Co-authored-by: Fei Gao <[email protected]>
  • Loading branch information
Songhe Zhu and GaoFei-ESWIN committed Sep 2, 2024
1 parent 8ea44aa commit 9bd38e6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/target/riscv/riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,10 @@ static int try_setup_single_match_trigger(struct target *target,
for (unsigned int idx = 0;
find_next_free_trigger(target, trigger_type, false, &idx) == ERROR_OK;
++idx) {
if (trigger_type == CSR_TDATA1_TYPE_MCONTROL
&& (get_field(trig_info.tdata1, CSR_MCONTROL_MATCH) == CSR_MCONTROL_MATCH_NAPOT)
&& r->trigger_maskmax[idx] == 0)
continue;
ret = try_use_trigger_and_cache_result(target, idx, trig_info.tdata1, trig_info.tdata2,
trig_info.tdata1_ignore_mask);

Expand Down Expand Up @@ -5729,6 +5733,11 @@ int riscv_enumerate_triggers(struct target *target)
riscv_reg_t tdata1;
if (riscv_reg_get(target, &tdata1, GDB_REGNO_TDATA1) != ERROR_OK)
return ERROR_FAIL;
int type = get_field(tdata1, CSR_TDATA1_TYPE(riscv_xlen(target)));
if (type == CSR_TDATA1_TYPE_MCONTROL) {
r->trigger_maskmax[t] = get_field(tdata1,
CSR_MCONTROL_MASKMAX(riscv_xlen(target)));
}

result = get_trigger_types(target, &r->trigger_tinfo[t], tdata1);
if (result == ERROR_FAIL)
Expand Down
3 changes: 3 additions & 0 deletions src/target/riscv/riscv.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ struct riscv_info {
/* record the tinfo of each trigger */
unsigned int trigger_tinfo[RISCV_MAX_TRIGGERS];

/* record the tdata1.maskmax of each trigger */
unsigned int trigger_maskmax[RISCV_MAX_TRIGGERS];

/* For each physical trigger contains:
* -1: the hwbp is available
* -4: The trigger is used by the itrigger command
Expand Down

0 comments on commit 9bd38e6

Please sign in to comment.