Skip to content

Clarify action=1 (enter Debug Mode) with dmode=0#501

Merged
Tim Newsome (timsifive) merged 3 commits into
masterfrom
dmode
Jan 6, 2020
Merged

Clarify action=1 (enter Debug Mode) with dmode=0#501
Tim Newsome (timsifive) merged 3 commits into
masterfrom
dmode

Conversation

@timsifive

Copy link
Copy Markdown
Contributor

Otherwise you might end up in a situation where regular software can
control when to enter debug mode.

Otherwise you might end up in a situation where regular software can
control when to enter debug mode.
Comment thread trigger.tex Outdated

This action is only legal when the trigger's \FcsrTdataOneDmode is 1.
Hardware should ignore triggers which have this action configured without
having \FcsrTdataOneDmode set. \\

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Would it be better to say that hardware must not accept a write to mcontrol with dmode=0 and action=1. rocket-chip forces action to 0 if dmode is being written with 0.

@allenjbaum

Copy link
Copy Markdown

@allenjbaum

Copy link
Copy Markdown

@timsifive

Copy link
Copy Markdown
Contributor Author

A debugger (or software) should never write an illegal value. Hardware may choose to protect itself in case it does. I have no strong feelings if that happens by changing the value as it's written to something legal, or by ignoring the illegal trigger. Should I just mention both, or just say something vague like "hardware should ensure not to enter Debug Mode through a trigger where dmode=0?"

@pdonahue-ventana

Copy link
Copy Markdown
Collaborator

There are 4 possible scenarios (in what I think is the most complex to the simplest HW implementation order):

  • ignore the write and return an error code

How does an error code get returned on a CSR write?

  • clear the action bit

Note that the action field is 4 or 6 bits (depending on the type of trigger). Would this mandate a specific WARL behavior that action=1 gets mapped to action=0 in this case (rather than allowing hardware to set action to some other value)? It makes sense to me to map it to 0 rather than something related to trace or a currently reserved encoding but I think that the fact that action is more than one bit must be considered.

  • allow the write, but inhibit the trigger

Does this mean that the state is allowed to contain action=1 and dmode=0 but that while this situation exists the type field is treated by the logic (for all purposes other than CSR read) as being 0 regardless of the actual value?

  • clear the output of the action bit, but not the action bit state

Is this a mixture of the two above cases where the state is allowed to contain the illegal state but that while this situation exists the action that the logic uses (for all purposes other than CSR reads) is 0?

After reading this, I think that another alternative is to say that type!=0 && action==1 && dmode==0 is illegal and let implementations do whatever WARL behavior they want (clear the type field, clear the action field, set action to some arbitrary legal value other than 1, keep dmode set, etc.). I'm not a particularly big fan of this but it does seem more RISC-V-like.

@ernie-sifive

Copy link
Copy Markdown
Collaborator

I think the hardware should never be allowed to have an illegal value in a register. It should alter the register value in some way to make the value legal. In this case, attempting to change dmode from 1 to 0 could either leave dmode at 1 or change action to 0.

@pdonahue-ventana

Copy link
Copy Markdown
Collaborator

I think the hardware should never be allowed to have an illegal value in a register. It should alter the register value in some way to make the value legal. In this case, attempting to change dmode from 1 to 0 could either leave dmode at 1 or change action to 0.

Or I think it could set type==0 to disable the trigger so dmode and action are irrelevant.

I agree that having illegal values in registers is potentially confusing and goes against the spirit (and probably also the letter) of WARL. I'm OK with any of the 3 proposals (fixing up dmode or action or type).

@allenjbaum

Copy link
Copy Markdown

@allenjbaum

Copy link
Copy Markdown

@pdonahue-ventana

Copy link
Copy Markdown
Collaborator
  • I thought I followed up with a subsequent email that the error code only makes sense for an external debugger

If the external debugger does the CSR write via the program buffer then I think that there's no way to return an error code (unless there's some additional error bit introduced into a CSR and then the debugger would have to sample that after every write but that's ugly and slow).

  • yea, I know action a 4bit (or 6bit!) field, but only 1 bit is RW in our implementation because that's all the spec defines so in general, map the halt action to break action, which is just clearing the LSB

I'm just saying that if the spec imposes a specific behavior now then we should consider the future and not make a choice that somehow prevents flexibility in defining new actions in the future. We shouldn't paint ourselves into a corner (not that I think that the proposal to clear action does that but I am inviting others to make sure that I'm not wrong).

@timsifive

Copy link
Copy Markdown
Contributor Author

Paul makes an excellent point that these registers are all WARL, so as Ernie says, the registers should never contain an illegal value. I'll update the PR.

Hopefully I found some language that makes sense when csrci is used to
clear just dmode, as well as writing a brand new value, and only changes
action if it's actually necessary.
@timsifive Tim Newsome (timsifive) changed the title Recommend clearing action when dmode is cleared. Clarify action=1 (enter Debug Mode) with dmode=0 Nov 25, 2019
@timsifive
Tim Newsome (timsifive) merged commit efc0143 into master Jan 6, 2020
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.

4 participants