code wiki / _hdl_build / _k_r2_001d_nvme_gate.nx
_k_r2_001d_nvme_gate.nx
buildroot/runtime/_hdl_build/_k_r2_001d_nvme_gate.nx
about
_k_r2_001d_nvme_gate.nx -- the X-DRV-W1 STAGE B gate (the 2nd-device-class round-trip + the
new-kind/TAMPER proof, resting on PROOF-1 the no-floating foundation).
PROOF-1 (FOUNDATION -- judged FIRST, per no-floating): the device-AGNOSTIC shape library
(nx_driver_shapes) re-emits the virtio-blk driver byte-identically and the existing SECTGATE
sector-data round-trip still runs GREEN on the SOVEREIGN rv64 emu THROUGH the generic shape
path. Three lanes (round-trip / byte-identical / virtio-tamper) -- the stage-A regression guard.
PROOF-2 (2nd device class -- only claimed after PROOF-1 GREEN): the SAME shape library, driven
by knowledge/specs/nvme_admin_enable_virt.spec alone, has the emitter ORGAN (nx_drvgen) AUTHOR
an NVMe-class controller bring-up image; the SOVEREIGN rv64 emu (+ the new NVMe device model)
runs it; the driver completes CC.EN->poll-CSTS.RDY, binds ASQ/ACQ, lays the 64-byte SQE, rings
the SQ-Tail doorbell, the device posts the phase-tagged CQE, the driver polls the CQE phase bit
+ reads NvmeCqPeek back == cqpeek_expected. Transcript must CONTAIN "VIO-NVME EN RDY ASQ SQE
CQ\n" AND a clean SiFive-finisher halt (BOOTSOV verdict=GREEN).
TAMPER (no-false-green): bump cqpeek_expected by ONE in the SPEC, re-emit via nx_drvgen, re-run.
The CqPeek read-back verify branches past the last stage -> the transcript loses ONLY its " CQ"
canary (the "...ASQ SQE" tail survives) -> the KAT goes RED. The PROOF-2 GREEN is gated on
tamper_bites==1, so the green is a REAL run, not an assertion.
DISTINCTNESS (refutes "virtio-disguised"): (1) STRUCTURAL -- the NVMe image CONTAINS a backward
branch (a poll loop: negative B-type immediate => instruction-word bit31 set on a 0x63 opcode),
and the virtio image contains NONE (its handshake is straight-line forward-only; constant-
lifting cannot add a loop -- the eoe/X-AUT-006d argument). (2) BYTE-DISTINCT -- the NVMe image
bytes != the virtio image bytes AND the goldens differ.
Every verdict comes from a PRINTED marker off a REAL run, never an asserted GREEN; raw bytes are
read SOVEREIGNLY (sys_read in the organ; a PowerShell pipe would corrupt a raw byte read). NO
qemu / gcc / openssl / python anywhere -- the sovereign emu IS the runtime; NVMe/PCI is a last-
mile interop probe + measuring stick to EXCEED, never a substrate. Marker -> knowledge/status/
virtio_blk.log (NVMEGATE row). Overall verdict=GREEN iff PROOF-1 GREEN AND PROOF-2 GREEN AND
TAMPER bites AND distinctness holds. Sovereign orchestration (fork/dup3/execve/wait4).
license_tier: ORIGINAL
dependencies 1 imports · 0 importers
imports: nx_syscalls.nx
imported by: nobody (leaf or entry point)
call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown
structs
| none |
consts
| none |
functions
| 34 | func ng_p(s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(1,s,n); return 0 } |
| 35 | func ng_fp(fd: i64, s: *u8) -> i64 { var n: i64=0; while s[n]!=(0 as u8){n=n+1} sys_write(fd,s,n); return 0 } |
| 36 | func ng_fn(fd: i64, v: i64) -> i64 { let bb: *u8=sys_mmap(28); var m: i64=v; if m<0{m=0-m}; let t: *u8=sys_mmap(28); var k: i64=0; if m==0{t[0]=48;k=1}; while m>0{t[k]=(48+(m%10)) as u8;m=m/10;k=k+1}; var i: i64=0; while i<k{bb[i]=t[k-1-i];i=i+1}; sys_write(fd,bb,k); return 0 } |
| 39 | func ng_run_virtio_emit(spec: *u8) -> i64 |
| 60 | func ng_run_drvgen(spec: *u8) -> i64 |
| 81 | func ng_run_sov(binpath: *u8, outpath: *u8) -> i64 |
| 102 | func ng_read(path: *u8, buf: *u8, cap: i64) -> i64 |
| 113 | func ng_buf_has(buf: *u8, n: i64, pat: *u8, pl: i64) -> i64 called by 1: main |
| 126 | func ng_strlen(s: *u8) -> i64 { var n: i64 = 0; while s[n] != (0 as u8) { n = n + 1 } return n } called by 1: main |
| 129 | func ng_bytes_equal(a: *u8, na: i64, b: *u8, nb: i64) -> i64 called by 1: main |
| 137 | func ng_w32(buf: *u8, o: i64) -> i64 |
| 148 | func ng_count_backward_branches(buf: *u8, n: i64) -> i64 |
| 159 | func main() -> i64 |