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

TriggerDmode case fail,when accessing 8-9 trigger #551

Open
zhajio1988 opened this issue Apr 22, 2024 · 2 comments
Open

TriggerDmode case fail,when accessing 8-9 trigger #551

zhajio1988 opened this issue Apr 22, 2024 · 2 comments
Assignees

Comments

@zhajio1988
Copy link

zhajio1988 commented Apr 22, 2024

our riscv core vendor specify that tselect.index 0-7 can only be mcontrol, 8-9 can only be one of icount/ietrigger.
TriggerDmode case trigger.S traverses the index from 0-9, and the type selected is 2, at this time, icount and itrigger, etrigger can only be accessed when the type is equal to 3,4,5, which leads to an error at tselect.index 8. How to deal with the situation?
Shouldn't we read the value of tinfo when we write tselect and then decide the value of a0?
li a0, (2<<60) | (2<<28) | (1<<6) | (1<<1)

@aap-sc aap-sc self-assigned this May 1, 2024
@en-sc
Copy link
Collaborator

en-sc commented Jul 1, 2024

icount and itrigger, etrigger can only be accessed when the type is equal to 3,4,5, which leads to an error at tselect.index 8.

Do you mean writing tdata1 with tdata1.type == 2 while tselect is 8 causes an illegal instruction exception on your HW?
This behavior is prohibited by the spec, namely [Chapter 5. Sdtrig (ISA Extension)] (The RISC-V Debug
Specification, Version 1.0.0-rc3):

M-Mode and Debug Mode accesses to trigger CSRs that are used by any of the implemented triggers must succeed, regardless of the current type of the currently selected trigger.

However, the implementation of write_store_trigger has some flaws, e.g. write_triggers should disable the trigger by writing tdata1 = 0 before writing tdata2 (see [5.7. Trigger Module Registers]).

write_triggers:
// a0: value to write to each tdata1
// a1: value to write to each tdata2
li t0, 0
2:
csrw CSR_TSELECT, t0
csrr t1, CSR_TSELECT
bne t0, t1, 1f
addi t0, t0, 1
csrw CSR_TDATA2, a1
csrw CSR_TDATA1, a0
j 2b
1: ret

@zhajio1988
Copy link
Author

@en-sc
Do you mean writing tdata1 with tdata1.type == 2 while tselect is 8 causes an illegal instruction exception on your HW?
Yes, it is.

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

No branches or pull requests

3 participants