toggle quoted messageShow quoted text
What you describe sounds very implementation dependent; I had always imagined that mtime would not be broadcast, but an mtime count enable bit would be, to keep the local copy synched.
That has its own issues of course (synching at reset, whenever mtime is written, and whenever stoptime is released) - though they're all the same mechanism, and can reuse whatever is used for reading mtime.
On Mon, Dec 20, 2021 at 6:35 PM Greg Favor <gfavor@...
I'm cc'ing Paul Donahue (vice-chair of the Debug TG). He was involved with distilling out of the enormous amount of optionality in the Debug spec, what would be suitable to require in OS-A platforms. So he can comment about this debug-related OS-A platform requirement, and in particular the stoptime requirement (Paul, see the email thread included down below):
dcsr.stopcount and dcsr.stoptime must be supported and the reset value of each must be 1
Btw, I don't see resync of time with mtime as more than a relatively trivial exercise on debug mode exit. Outside of debug mode mtime is being broadcast to all harts and each hart's time CSR updates with the latest time value that it receives. In debug mode, if stoptime=1, then the time flops are simply inhibited from updating with any new received mtime values. Then when debug mode is exited and the inhibit goes away, the time flops naturally go back to getting updated with the latest and/or new received mtime values.
On Mon, Dec 20, 2021 at 3:19 PM Beeman Strong <beeman@...
Thanks, I definitely misunderstood the intent. So the expectation is that, in Debug Mode, reads to mtime will see time continue to progress, but reads to the time CSR will see a frozen value. Reads of the time CSR by software running outside debug mode should not be impacted, and will see a value synchronized with mtime.
I suppose I can imagine usages where keeping the time CSR frozen has value to a debugger, but it does add complexity and latency in requiring a resync with mtime on debug mode exit. Does the value really rise to the level of being a platform requirement? Is there some important debug functionality that breaks if we keep it simple and let the time CSR keep running in debug mode?
On Mon, Dec 20, 2021 at 2:05 PM Andrew Waterman <andrew@...
On Mon, Dec 20, 2021 at 3:42 PM Greg Favor <gfavor@...
I think there's a little bit of confusion going on. The 'stoptime' bit is defined as "Don’t increment any hart-local timers while in
Debug Mode." I take this to clearly not be referring to MTIME, but to the local time CSR.
I fully agree that expecting a debug action on a core to have to reach out to wherever in a system MTIME may be, is inappropriate. Which also affects other still active harts - which is probably very inappropriate (i.e. debugging just one hart shouldn't inherently affect operation of all harts).
Oops, it has been a while since I've read this spec. I withdraw my comment, if it's indeed the case that shared implementations of mtime need not be affected by stoptime.
Whereas stopping the local time CSR for the duration of being in Debug mode would be easy to implement, i.e. in_debug_mode inhibits the time CSR from advancing. Presumably, once the hart exits Debug mode, the time CSR effectively immediately catches back up with the current time value that has been broadcast to it from MTIME.
On Mon, Dec 20, 2021 at 1:19 PM Andrew Waterman <andrew@...
On Mon, Dec 20, 2021 at 12:11 PM Beeman Strong <beeman@...
In the OS-A platform spec I see the following requirement:
• dcsr.stopcount and dcsr.stoptime must be supported and the reset value of each must be 1
◦ Rationale: The architecture has strict requirements on minstret which may be perturbed by an external debugger in a way that’s visible to software. The default should allow code that’s sensitive to these requirements to be debugged.
The rationale justifies the requirement for stopcount=1, but I don't see any rationale for stoptime=1.
The debug spec refers to stoptime=1 stopping "timers", which I interpret to mean the mtime counter. This timer is expected to by synchronized across harts in a system ("The real-time clocks of all harts in a single user application should be synchronized to within one tick of the real-time clock.") In a system with multiple harts, where a subset of harts may be halted at a given time, this stoptime=1 requirement risks violating this ISA requirement and confusing software by causing wall-clock time to get out of sync.
Can we remove "and dcsr.stoptime" from this platform requirement?
FWIW, although I appreciate the motivation behind this requirement, I also support removing it. For the case that mtime is centrally implemented, this requirement is quite onerous to implement. For the case that mtime is decentralized, this requirement is easy to satisfy, but is differently problematic, as the spec mentions ("risks violating this ISA requirement"). I dislike disadvantaging the centralized-mtime implementations for a feature we've already admitted is problematic at the ISA level.