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

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

wants to merge 2 commits into from

Conversation

sunnyzhu-learning
Copy link

Reference release specification (https://github.com/riscv/riscv-debug-spec/blob/release/riscv-debug-release.pdf), in section 5.2.9 introduce maskmx:
A value of 0 indicates that only exact value matches are supported (one byte range).

so. when tdata1.type=2 and napot is unsupported, try_setup_single_match_trigger should skip match=1 .

Change-Id: Ib22f6ba3bdd4a5acfbbb4ac630eb420ae1f8bd78
Signed-off-by: Songhe Zhu <[email protected]>
Co-authored-by: Fei Gao <[email protected]>
@sunnyzhu-learning sunnyzhu-learning marked this pull request as ready for review September 2, 2024 05:23
Copy link
Collaborator

@en-sc en-sc left a comment

Choose a reason for hiding this comment

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

AFAIU, the approach suggested in the commit will not be suitable for some HW configurations (please, see the comment on riscv_enumerate_triggers()).

I'd suggest to look at set_trigger() instead.
In particular, tdata1_config_denied can reflect that the value in mcontrol.maskmax fits the requested range.
e.g.:

  1. Rename trigger_request_info::tdata1_ignore_mask -> trigger_request_info::maskmax.
  2. Add the something like the following to set_trigger():
const uint32_t type = get_field(tdata1, CSR_TDATA1_TYPE(riscv_xlen(target)));
if (type == CSR_TDATA1_TYPE_MCONTROL &&
		(get_field(tdata1, CSR_MCONTROL_MATCH) == CSR_MCONTROL_MATCH_NAPOT))
		tdata1_config_denied |= get_field(tdata1_rb, CSR_MCONTROL_MASKMAX) < (get_least_significant_zero_index(tdata2) + 1).
}

(get_least_significant_zero_index() is not yet implemented).

@@ -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.

@sunnyzhu-learning
Copy link
Author

thanks a lot, I will create new PR addressed this question

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants