--
You received this message because you are subscribed to the Google Groups "RISC-V Debug Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+unsubscribe@groups.riscv.org.
The trace actions are completely orthogonal to the debug exception/enter debug mode actions. Since there is a separate trace working group, I suggest leaving the priority (if any) of those actions up to that group.That just leaves "breakpoint exception" and "enter debug mode." These actions could both be taken by making all changes required to take a breakpoint exception, not executing any instructions there, and then entering Debug Mode. If that's too much to expect from the hardware, I'd like "enter debug mode" to take precedence, so that a running program cannot affect debugging.Hardware designers, what do you think?Tim
On Fri, Jun 8, 2018 at 12:27 PM, Deepak Panwar <panwar...@gmail.com> wrote:
Hi,Each trigger has an action associated with it which is specified in the mcontrol register (like going to debug mode or taking a breakpoint exception). However, it isn't specified what should happen if two or more triggers hit simultaneously and they have different actions. Should that be considered an illegal case or trigger module should follow a specific priority in that case? Will be nice to add clarify this case in the debug spec.Thanks,Deepak
--
You received this message because you are subscribed to the Google Groups "RISC-V Debug Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+un...@groups.riscv.org.
On Mon, Jun 11, 2018 at 9:52 AM, Deepak Panwar <panwar...@gmail.com> wrote:
I think both implementation are acceptable from the hardware perspective. It's probably better to give higher priority to one though (debug mode). Should this be added to the debug spec?
If they’re both acceptable, I much prefer both actions to happen. That way the debugger still has control, but a trigger that software is expecting to fire still gets to fire. I’m thinking:
When a trigger with the “enter Debug Mode” action and another trigger with
“raise a breakpoint exception” action fire at the same time, both actions are
taken. It is implementation-dependent which of the two happens first. What
happens with trace actions in such a case is left to the trace spec.
Tim
To unsubscribe from this group and stop receiving emails from it, send an email to debug+unsubscribe@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/cb6a7568-1c9a-42be-a96d-e17c95956ce7%40groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/cb6a7568-1c9a-42be-a96d-e17c95956ce7%40groups.riscv.org.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+unsubscribe@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/dce3a020-af27-43ec-a15e-762efe61975e%40groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/dce3a020-af27-43ec-a15e-762efe61975e%40groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/55f20d0f-d65b-4335-b04d-74b5690b0015%40groups.riscv.org.
Hi Tim,
Once the core takes a breakpoint exception due to trigger, it will be nice to have a mechanism to disable all the triggers till the core is in the exception handler. There might be cases when we don't want to hit any triggers while in the exception handler (this is especially true with icount trigger). One way to do it is to have a trigger enable/disable bit in one of the CSR registers. Hardware can set this bit when it takes the breakpoint exception. Software can reset the bit at the end of the handler. Any other solution is also fine as long as we can control triggers inside the exception.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+unsubscribe@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/55f20d0f-d65b-4335-b04d-74b5690b0015%40groups.riscv.org.
Deepac,
I’m a bit confused. 4.1 of the spec says about Debug Mode:
2. All interrupts (including NMI) are masked.
3. Exceptions don't update any registers. That includes cause, epc, tval, dpc, and mstatus.
They do end execution of the Program Buffer.
4. No action is taken if a trigger matches.
Doesn’t #4 resolve your question?
If the issue is the small amount of time between the trigger signal going true and the exception handler being entered, then hardware should lock out other triggers, exceptions, interrupts. It shouldn’t be a user-programmable choice (IMO).
If this is a case of wanting to “debug the debugger” I think the code running at the debug level has to be written correctly and doesn’t need to be debugged.
--- Bruce
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/55f20d0f-d65b-4335-b04d-74b5690b0015%40groups.riscv.org.
--
You received this message because you are subscribed to the Google Groups "RISC-V Debug Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+un...@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/CAGDihe%3DD%2B0y1kyjbY_EaS2m2nckbFrso4kSpToGGtv7k85M6Tg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/55f20d0f-d65b-4335-b04d-74b5690b0015%40groups.riscv.org.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+unsubscribe@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/c5b00f2c-2375-4c87-abc8-f3d84a93a9fd%40groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/c5b00f2c-2375-4c87-abc8-f3d84a93a9fd%40groups.riscv.org.
Hi Deepak,Thanks for explaining again. I know understand the problem. Specifically you're worried about something like this:1. 2 triggers are set2. Trigger 1 fires, and causes a debug exception.
3. The debug exception code runs a bit, presumably saving registers.
4. Trigger 2 fires, causing another debug exception.Now the original PC where Trigger 1 fired is lost, and it's likely not possible to restore the registers that were already saved as well.
I don't have an answer for this with the current spec, aside from "be careful setting triggers." Avoiding the problem is doable, but it is a hassle and surely somebody will get bit by it.
Now I'm torn between pushing the ratification process forward, and adding one more feature. This feels like a bug, but it takes more than a tiny tweak to solve it. What does everybody else think?
Tim
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/c5b00f2c-2375-4c87-abc8-f3d84a93a9fd%40groups.riscv.org.
--
You received this message because you are subscribed to the Google Groups "RISC-V Debug Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+un...@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/CAGDihekm_XcMh3VtgpM%2BMi4bnxtDjH8%3Dtzuhf0rZx7ZvykSP4A%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/6a799e4f-ec54-4b76-acf7-0ac8eab24fdf%40groups.riscv.org.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+unsubscribe@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/6a799e4f-ec54-4b76-acf7-0ac8eab24fdf%40groups.riscv.org.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/6a799e4f-ec54-4b76-acf7-0ac8eab24fdf%40groups.riscv.org.
--Megan A. WachsEngineer | SiFive, Inc
To unsubscribe from this group and stop receiving emails from it, send an email to debug+unsubscribe@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/6a799e4f-ec54-4b76-acf7-0ac8eab24fdf%40groups.riscv.org.
--Megan A. WachsEngineer | SiFive, Inc
I think everybody understands the problem at this point.
Megan’s solution sounds sensible to me:
Instead of having a trigger action cause a debug exception, instead have it cause a debug interrupt. There is no such thing as a debug interrupt currently, but it would behave the same as any other interrupt that traps to machine mode. The regular interrupt handler would save registers, look at possible interrupt sources (now including triggers), and handle them appropriately.
This is a change we would have to make to the Debug Specification.
So in the scenario Joe just outlined:
Before the trigger is tripped, we encounter an external interrupt.
The external interrupt handler tries to save the mepc register to memory. The mepc happens to have 0x8000000 in it. This trips the store trigger, which raises an interrupt, but interrupts are already disabled because we’re in an interrupt handler. When interrupts become enabled (I think) the interrupt will be taken at that time. (I’m not 100% sure how RISC-V handles interrupts that fire during an interrupt handler, but presumably it’s reasonable behavior, and the same would apply here.)
Tim
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/6a799e4f-ec54-4b76-acf7-0ac8eab24fdf%40groups.riscv.org.
--Megan A. WachsEngineer | SiFive, Inc
--Megan A. WachsEngineer | SiFive, Inc
--
You received this message because you are subscribed to the Google Groups "RISC-V Debug Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+unsubscribe@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/CAPQuH8S9%2B89XM%3Ds4myic-m%2BPHd8U%2BbcWOA_G361%3DByn1Zk5HfA%40mail.gmail.com.
I think everybody understands the problem at this point.
Megan’s solution sounds sensible to me:
Instead of having a trigger action cause a debug exception, instead have it cause a debug interrupt. There is no such thing as a debug interrupt currently, but it would behave the same as any other interrupt that traps to machine mode. The regular interrupt handler would save registers, look at possible interrupt sources (now including triggers), and handle them appropriately.This is a change we would have to make to the Debug Specification.
So in the scenario Joe just outlined:
- Software defines a store data debug trigger with an equality match, a “before” timing, and a target value of 0x80000000 (if a store tries to write 0x80000000, we want a breakpoint exception).
Before the trigger is tripped, we encounter an external interrupt.
The external interrupt handler tries to save the mepc register to memory. The mepc happens to have 0x8000000 in it. This trips the store trigger, which raises an interrupt, but interrupts are already disabled because we’re in an interrupt handler. When interrupts become enabled (I think) the interrupt will be taken at that time. (I’m not 100% sure how RISC-V handles interrupts that fire during an interrupt handler, but presumably it’s reasonable behavior, and the same would apply here.)
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/CAPQuH8S9%2B89XM%3Ds4myic-m%2BPHd8U%2BbcWOA_G361%3DByn1Zk5HfA%40mail.gmail.com.
On Thu, Jun 28, 2018 at 4:02 PM, Megan Wachs <me...@sifive.com> wrote:
On Thu, Jun 28, 2018 at 15:25 Tim Newsome <t...@sifive.com> wrote:I think everybody understands the problem at this point.
Megan’s solution sounds sensible to me:
Instead of having a trigger action cause a debug exception, instead have it cause a debug interrupt. There is no such thing as a debug interrupt currently, but it would behave the same as any other interrupt that traps to machine mode. The regular interrupt handler would save registers, look at possible interrupt sources (now including triggers), and handle them appropriately.This is a change we would have to make to the Debug Specification.
So in the scenario Joe just outlined:
- Software defines a store data debug trigger with an equality match, a “before” timing, and a target value of 0x80000000 (if a store tries to write 0x80000000, we want a breakpoint exception).
Before the trigger is tripped, we encounter an external interrupt.
The external interrupt handler tries to save the mepc register to memory. The mepc happens to have 0x8000000 in it. This trips the store trigger, which raises an interrupt, but interrupts are already disabled because we’re in an interrupt handler. When interrupts become enabled (I think) the interrupt will be taken at that time. (I’m not 100% sure how RISC-V handles interrupts that fire during an interrupt handler, but presumably it’s reasonable behavior, and the same would apply here.)
It’s sort of reasonable but probably not what you want... most interrupt inputs to mip are expected to be level interrupts (once set, they stay set until cleared by SW writes to various other registers). So the trigger unit would have to have the same level behavior, which means we would ALSO have to define a way to clear it down if you wanted the trigger interrupt to be taken later. But it seems like you would not want it taken later, if you did, the analogy to an interrupt doesn’t hold because the mepc that would be recorded would be whatever the instruction was after you enabled triggers again, not the actual triggered pc from before.
The interrupt level could be controlled by the hit bits in each trigger. (While hit is set, the interrupt is high.) That gets you level semantics without really much change, and an existing way to clear the interrupt.
You do have an issue that you lose the PC at the time that the interrupt fired. I don’t really see any way around that short of adding another pc register. I doubt that’s worth it, since this is really only a problem in harts that only support M mode, which presumably are trying to be tiny.
An interrupt handler would look like:
hit
in every triggermret
Steps 3 and 4 might cause triggers to fire, depending on what triggers are set. In that case the interrupt handler will be started again immediately after step 5, and this cycle could continue forever. That sounds terrible, on the other hand, users shouldn’t set triggers like that. In an M mode only system, programs can also access memory anywhere and cause a system to hang that way.
This problem could be avoided altogether by requiring that triggers whose action=0 don’t fire at all when the interrupt they would cause is currently disabled. (Triggers that are used by an external debugger still would fire, so that interrupt handlers can be debugged that way.)
Tim
Tim
--
You received this message because you are subscribed to the Google Groups "RISC-V Debug Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to debug+un...@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/CAGDihemvissXZ_Pd16%2BcEY3gwhRRx1%2Bnu5StwiP85h%3DTvQ4vLg%40mail.gmail.com.
Tim
To unsubscribe from this group and stop receiving emails from it, send an email to debug+unsubscribe@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/CAGDihemvissXZ_Pd16%2BcEY3gwhRRx1%2Bnu5StwiP85h%3DTvQ4vLg%40mail.gmail.com.
Here’s a real example: setting a memory access trigger on the address just below the stack, to catch programs that blow through their stack. If a program is right on the edge when an interrupt fires, this trigger might fire when registers are saved/restored by the interrupt handler, which leads to exactly the problem I detailed. It will be rare, but this discussion is not entirely academic.
Having the trigger logic depend on mie/mstatus is a bit awkward, but the trigger logic already knows the current execution mode. This doesn’t feel terribly different. How else could we fix this? I think the crux is that we want to re-enable triggers when mret
is executed. A CSR that we write 0 to to enable triggers could work. That way the CSR can be written as the last instruction before mret
, so unless the trigger fires on execution of mret
there will be no problem.
Tim
Tim
To unsubscribe from this group and stop receiving emails from it, send an email to debug+un...@groups.riscv.org.
To post to this group, send email to de...@groups.riscv.org.
Visit this group at https://groups.google.com/a/groups.riscv.org/group/debug/.
To view this discussion on the web visit https://groups.google.com/a/groups.riscv.org/d/msgid/debug/CAGDihemvissXZ_Pd16%2BcEY3gwhRRx1%2Bnu5StwiP85h%3DTvQ4vLg%40mail.gmail.com.