Repository navigation
Sdtrig issue fix - #3662
Open
YazanHussnain-10x wants to merge 15 commits into
Open
Sdtrig issue fix#3662YazanHussnain-10x wants to merge 15 commits into
YazanHussnain-10x wants to merge 15 commits into
Conversation
…in S mode while SIE is 0
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The Sdtrig trigger module does not follow the RISC-V Debug Specification in 13 cases. 7 cases have an open issue. The other 6 cases have no issue.
This PR corrects the 13 cases, with one commit for each case. Each correction applies to RV32 and RV64.
On
master, 3 more cases are in the load unit. Themaster_candidatebranch already corrects them, so they are not in this PR.Related issues
Closes #3618, closes #3619, closes #3620, closes #3622, closes #3624, closes #3646, closes #3647.
Changes
#3618: a write of 0 to tdata1 does not disable the trigger
Issue: on RV64, the write of 0 has no effect. A trigger of type 15 reads back as type 0.
RISC-V Debug Specification, section 5.7.2 (Trigger Data 1,
tdata1):Fix: a write of type 0, 15 or an unsupported type sets type 15, and type 15 reads back as 15.
#3622: tdata1 can hold dmode=0 with action=1
Issue: a write from M-mode clears
dmode, but keepsaction=1.RISC-V Debug Specification, section 5.2 (Actions), action 1:
Fix: the action is 1 only when the new
dmodeis 1. All other values give action 0.#3624: dcsr.cause is 3 for a trigger with action=1
Issue: a trigger and a halt request use the same internal cause.
RISC-V Debug Specification, section 4.9.1 (Debug Control and Status,
dcsr), fieldcause:Fix: a new internal cause
DEBUG_TRIGGERgivesdcsr.cause = 2.#3620: etrigger fires on an interrupt, and with no trap
Issue: the match does not use
ex_i.validor the interrupt bit of the cause.RISC-V Debug Specification, section 5.7.15 (Exception Trigger,
etrigger):Fix: the etrigger matches only on an exception trap, with one match flag for each trigger.
#3646: itrigger fires after the handler returns
Issue: the itrigger waits for an
mret, and the breakpoint writes the PC totval.RISC-V Debug Specification, section 5.7.14 (Interrupt Trigger,
itrigger):Fix: the itrigger uses the etrigger path and fires before the first handler instruction, with
tval = 0.#3647: icount reports a wrong mepc
Issue: the trap is raised when no valid instruction is at commit, and
count=0also fires.RISC-V Debug Specification, section 5.7.13 (Instruction Count,
icount):Fix:
pendingis set only whencountgoes to 0, and the trap is raised only on a valid instruction.#3619: icount counts in modes where it is not enabled
Issue:
countdecreases for all retired instructions, and stops after a trap untilmret.RISC-V Debug Specification, section 5.7.13 (Instruction Count,
icount):Fix:
countdecreases only for the instructions and traps of the enabled modes.etrigger and itrigger do not fire again when hit is set
Issue: after the first fire,
hit=1blocks the trigger until software clearshit.RISC-V Debug Specification, section 5.7.15 (Exception Trigger,
etrigger), fieldhit:Fix:
hitdoes not block the fire of an etrigger or an itrigger.mcontrol6 load and store triggers do not see lr and the AMOs correctly
Issue: all AMOs,
lrandscare stores for the trigger module. A load trigger does not match an AMO orlr, and a store trigger matcheslr.RISC-V Debug Specification, section 5.5.1 (A Extension):
Fix: the trigger module gets the LSU operation.
lris a load,scis a store, an AMO is both, and the store unit takes the action.The textra context match is not used
Issue:
build_config_pkgsetsSdtrigSupportTextrato 0. When it is 1,sselect=0blocks all matches andscontextis compared in S-mode only.RISC-V Debug Specification, section 5.7.17 (Trigger Extra,
textra32), fieldsselect:Fix:
build_config_pkgkeeps the option,sselect=0ignoressvalue, the match applies in all modes, andsselectis 0 or 1.A trigger with action=0 fires in its own trap handler
Issue: there is no reentrancy rule. An action=0 trigger fires in an M-mode trap handler and overwrites
mepcandmcause.RISC-V Debug Specification, section 5.4 (Native Triggers):
Fix: the trigger module gets
mstatus.MIE,mstatus.SIEandmedeleg[3], and blocks the action=0 triggers as the spec says.A write to tinfo causes an illegal instruction exception
Issue:
tinfohas no write case incsr_regfile. A write causes an illegal instruction exception.RISC-V Privileged Specification, section 2.1 (CSR Address Mapping Conventions):
Fix: a write to
tinfois ignored when Sdtrig is enabled.tinfo shows trigger types that the configuration does not have
Issue:
tinfo.infois a constant. It shows types 3, 4, 5 and 6 also when the configuration disables them.RISC-V Debug Specification, section 5.7.5 (Trigger Info,
tinfo), fieldinfo:Fix:
tinfo.infogets the type bits fromSdtrigIcount,SdtrigItrigger,SdtrigEtriggerandSdtrigMcontrol6.Fixed on
master_candidateThese 3 cases are on
master. The new load unit onmaster_candidatecorrects them.A load address trigger stops the hart
Issue: the load unit cancels the load one cycle after the match. The load has then left
lsu_ctrl_i, so the exception goes to a wrong transaction id and the hart waits for ever.Fixed on
master_candidateby4146ee8db(Stop a load matching a load address trigger before it reaches memory).Failing ACT4 tests on
masterwithout it: FAIL_LA_PLACEHOLDERA load data trigger reports HARDWARE_ERROR
Issue: the load unit sets the cause to
HARDWARE_ERRORfor each load response, also when the response has no error. This cause replaces the cause of a load data trigger.Fixed on
master_candidatebye0f1ef8d5(port: Turn a cache error on a load into an exception). The cause isHARDWARE_ERRORonly when the load response has an error.Failing ACT4 tests on
masterwithout it: FAIL_LDCAUSE_PLACEHOLDERA load data trigger stops the hart
Issue: the trigger module compares the load data after the LSU pipeline registers, without
load_valid. The load unit marks the exception one cycle before, so the trigger does not fire, and the old data keeps the load unit stalled.Fixed on
master_candidatebyaf5972146(Compare the load data trigger after the load output register).Failing ACT4 tests on
masterwithout it: FAIL_LD_PLACEHOLDEROpen case
A load data trigger does not see the data of lr
Issue:
lrgets its data at commit from the AMO response. The trigger module compares only the load write back, so a load data trigger never matcheslr. This case is also onmaster_candidate, wheresdtrig_load_data_oisload_result_o.RISC-V Debug Specification, section 5.5.1 (A Extension):
This PR does not correct it. The correction needs the load data trigger of
af5972146and the deferred break of56cfe006d(Take a deferred load data break on the next valid instruction). It is easier to make it on top ofmaster_candidate: compare thelrdata at commit, and take the trigger action on the next valid instruction.Failing ACT4 tests:
SdtrigSm_lrsc_data,SdtrigS_lrsc_data,SdtrigU_lrsc_data.