Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

target/riscv: Mismatch napot when mcontrol.maskmax is zero #1124

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Collaborator

@en-sc en-sc Sep 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if the trigger supports multiple types and is disabled at the moment of enumeration?
AFAIU, you it will not be possible to use such trigger for a NAPOT match.

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
Loading