The Bouncer on the Stopwatch
matters at ISA because the verified property is the privileged ISA's own rule: mcounteren.CY is the M-level gate on U-mode cycle reads, and the module proves both directions, reads succeed when the bit is set and the same read traps with scause 2 when it is clear.
not at Microarch because the gate is an architectural access rule, and the observed outcomes, a trap versus two increasing samples, are identical on any pipeline, cache, or predictor that implements the privileged spec: the proof asserts nothing about how the read is implemented, only whether it is permitted.
matters at Firmware because M-mode firmware owns mcounteren, and the experiment is written as that firmware: it sets and clears CY itself and performs the real M to S to U drops, so the gate is the firmware's own policy for exposing the cycle counter to user mode.
not at Kernel because the verified property is the M-level hardware gate on a counter read, and the S-mode code exists only to reach U-mode where the gate bites: no supervisor timing or scheduling policy is under test, and the same gate would bite under any kernel.
not at Algorithm because no computational mechanism is under test: the claim is an access-control invariant, one bit deciding whether a read is permitted, and the converse-pair experiment design is a testing method, not an algorithm.
At boot, mcounteren reads back 0x0: user mode may see nothing, and nobody granted it. The experiment sets bit 0, CY, then drops from M-mode through S-mode down to user mode and reads the cycle counter twice: no trap, two strictly increasing samples, the door open. Then it clears that one bit, drops to user mode again, and runs the same instruction. This time the machine traps with scause 2, illegal instruction, sepc pointing exactly at the rdcycle site, and the destination register still holding its 0xdeadbeefdeadbeef sentinel, proof the read never happened. Twenty-two checks, zero mismatches, three byte-identical runs under QEMU 8.2.2. One bit decides whether a user process may know what time it is.
Why would a machine hide the time from its own programs? The unprivileged manual says it plainly: "Some execution environments might prohibit access to counters to impede timing side-channel attacks." A cycle counter is an oracle. Diffing two timestamps around someone else's code measures what that code did, and that trick has a published attack literature behind it: keystroke intervals, memory access patterns, the Spectre-era classics. So the privileged ISA puts the bouncer in M-mode. The obvious alternative is to hand back a zero or a clamped value, but a silent zero is a lie the program cannot detect, so the ISA refuses it: a clear CY bit raises illegal instruction, the architectural equivalent of the door staying shut. The manual is careful about what hiding is and is not. "The settings in this register only control accessibility. The act of reading or writing this register does not affect the underlying counters, which continue to increment even when not accessible." The clock still ticks; you simply may not ask it the time. An earlier module proved the brake pedal, mcountinhibit, which stops the clock. This one proves the bouncer, which bars the door. Stopping versus hiding: two different promises, same family.
The experiment earns its verdict one gate at a time. Two gates sit in series on the road from user code to the cycle counter, the M-level mcounteren and the S-level scounteren, so the module pins the S-level gate open, held set and read back as 0x1 before each phase, and wiggles only the M-level one. A mirror-image module did the reverse, holding the M-level gate open while toggling the S-level one. A single experiment can only blame one gate when the other is nailed open, so the two arrive as a converse pair. And the failure carries its own proof inside the success. The phase-B payload loads the destination register with a sentinel before attempting the read, so a completed read would have overwritten it. The trap alone says the instruction faulted; the untouched register says the read never happened:
li t0, 0xdeadbeefdeadbeef
rdcycle t0
Scope, honestly held: this verifies QEMU 8.2.2's model of the gate, not silicon, and the gate only bites below M-mode, which is why both phases run through two real privilege drops, M to S to U, instead of asserting anything from the top. One sentence to carry away: time is a hardware resource, and one bit in one register is the bouncer who decides which rings of privilege get to see it.
Code: src/mcounteren-cy-u-read