The Bit You Cannot Set
The claim is the mstatus SD summary rule as this machine shows it: SD reads 1 exactly when FS reads Dirty, and a forced write to bit 63 reads back 0. The run shows each side directly: FS Initial read back with SD 0, one fadd.d moved FS to Dirty with SD 1, FS Clean returned SD to 0, and the forced bit-63 write left SD 0 with FS unchanged.
No claim depends on how any core implements the SD summary. QEMU serves as a functional executor only; no pipeline or execution-unit behavior is asserted or measured, and the honest limit states the result is emulator-observed, not silicon-proved.
No firmware service takes part in the claim. The binary runs in M-mode on bare QEMU with no SBI or firmware calls; the behavior under test is the mstatus CSR's own summary rule.
No kernel code runs in the claim. The binary is a bare-metal M-mode program with no supervisor, no scheduler, and no system call path; the SD readback is a CSR operation, not a kernel mechanism.
The claim is one fixed sequence of FS writes, one floating point addition, and register readbacks, not a computation proved against an independent oracle. The results are shown as the consequence the SD summary rule forces, not as a verified algorithm.
Most status bits are switches: write 1 to set, write 0 to clear, and read back what you wrote. mstatus bit 63, SD, is not a switch. It is a summary, a single bit that reports whether the floating point state is dirty, and the only way to move it is to change the state it summarizes.
Measured on QEMU 8.2.2, bare metal in M-mode. At boot, mstatus read 0xa00000000, FS Off, SD 0. Writing FS Initial gave 0xa00004000, SD still 0: the floating point unit was enabled but not dirty. One fadd.d, 1.5 plus 2.25, left f0 holding 0x400e000000000000 (3.75) and mstatus at 0x8000000a00006000, FS Dirty, SD 1. Writing FS Clean gave 0xa00002000, SD back to 0. Forcing bit 63 with csrs left mstatus at 0xa00002000, SD still 0, FS unchanged. Restoring the boot word returned 0xa00000000 exactly. Fifteen checks, zero mismatches, traps 0, checksum 0xcd8421132251ca67, RESULT: PASS. [1]
The four moves, and what SD did after each:
csrs mstatus, t0 # FS = Initial: SD reads 0
fadd.d f0, f1, f2 # 1.5 + 2.25: FS = Dirty, SD reads 1
csrs mstatus, t1 # t1 = bit 63: SD still reads 0
# writing FS = Clean drops SD back to 0
Why the forced write cannot stick. SD is defined as a summary of FS, not as a bit of its own: it reads 1 exactly when FS reads Dirty. A write to bit 63 therefore has nothing to change, and the readback shows the state FS is actually in, not the value software offered. A stored copy would disagree the moment the state changed, so the architecture does not store one.
The bench habit: never test SD by writing it. Test it by dirtying the state and by cleaning it: write FS Initial, execute one floating point operation, read SD, write FS Clean, read SD again. If the first read is not 0, the unit was already dirty before your test. If the forced write sticks, your test is reading a stored bit, not a summary, and every conclusion drawn from it is suspect.
One sentence to carry away: a summary bit answers a question about state, and it is not a place to store an answer.
Diagram: hand-built by Chris Dillinger for this post
Sources
- 01src/mstatus-sd-summary: module PROOF.md and the QEMU runChris Dillinger
The QEMU 8.2.2 run behind the post, re-run firsthand for this post: boot mstatus 0xa00000000, FS Off, SD 0; FS Initial 0xa00004000, SD 0; after fadd.d mstatus 0x8000000a00006000, FS Dirty, SD 1, f0 bits 0x400e000000000000; FS Clean 0xa00002000, SD 0; forced bit-63 write read back 0xa00002000, SD 0, FS unchanged; restore 0xa00000000; traps 0; 15 checks, 0 mismatches, checksum 0xcd8421132251ca67; RESULT: PASS.