aienux
Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.
Brought by drakestapleton
aienux / native / disk / OMEGA_NVME_READ.md
| 1 | # Seeded Omega NVMe read protocol and Path 3 qualification |
| 2 | |
| 3 | ## Status and boundary |
| 4 | |
| 5 | IMPLEMENTED and EXERCISED on host fixtures and a disposable QEMU NVMe namespace. |
| 6 | PHYSICAL NOT_RUN. Native kernel/VFIO execution NOT_RUN. This is not a TRUST-1 Gate 7 |
| 7 | pass, a bootable native storage stack, or a replacement for the existing kernel |
| 8 | binding. Nothing in this work opens a live block device, resets a physical |
| 9 | controller, binds VFIO, mounts a filesystem, or touches 18091. |
| 10 | |
| 11 | The protocol engine is `omega_nvme.om`. `omega_nvme_main.om` exposes only bounded |
| 12 | reads. `omega_nvme_transport.om` is an explicitly hosted verification transport: |
| 13 | 24-byte little-endian byte-access RPCs on stdin/stdout. The existing C reference |
| 14 | and QEMU are verification oracles, not a C implementation hidden behind an Omega |
| 15 | API. Queue construction, completion polling/correlation, Identify parsing, |
| 16 | identity/extent approval, PRPs and successful copy-out are all Omega code. |
| 17 | The C relay translates memory/register accesses, not NVMe operations. Its C model |
| 18 | contains writes for adversarial verification, but the normal Omega entrypoint |
| 19 | cannot submit them. Host and emulator results establish neither DMA coherence nor |
| 20 | SSD latency/throughput on the Spark. |
| 21 | |
| 22 | ## Reuse search and ownership |
| 23 | |
| 24 | Before implementing, searched `*.om` for case-insensitive `nvme` or `submission queue`: |
| 25 | all 5,321 fetched advertised branch refs in all 106 aien-dev repositories, and |
| 26 | 190,008 committed-ref instances in 1,933 local common stores under `work`, |
| 27 | `workspace` and `/tmp` (discovery depth four). No matching existing implementation |
| 28 | was found. All twelve no-ref working copies and the current OwnDriver, aienux and |
| 29 | synapse working-copy scopes were searched separately. Three stale alternate-object |
| 30 | stores were resolved through successful redundant scans and an environment-only |
| 31 | existing object directory for their two otherwise-unscanned commits. |
| 32 | `tests/omega_nvme_reuse_search.txt` records exact coverage, branch inventory and |
| 33 | the limits of that finding; the raw command evidence remains with the operator. |
| 34 | |
| 35 | The disk crumb's historical lane11/PR190 is not an active `.om` migration claim. |
| 36 | BOARD assigns this isolated `native/disk` candidate to QualNvmeOm; the GPU |
| 37 | access/lifecycle work remains in its existing driver lane. Synapse #54 owns the |
| 38 | R1/J1 raw-store consumer, not this hardware protocol engine. This change does not |
| 39 | replace or claim the System Store journal or that consumer. |
| 40 | |
| 41 | ## Pins and reproducible acceptance |
| 42 | |
| 43 | - Compiler: the omega-mv commit and seeded omc SHA-256 in the repository's `PIN`, read by |
| 44 | `tests/omega_nvme_test.sh` and `tests/gates/run.sh`. The first pin was the existing |
| 45 | omega-gpu-driver `feat/vfio-dma-bar` pin (omega-mv 397e6704), not an invented profile; the |
| 46 | historical receipt `tests/omega_nvme_receipt.txt` records that build. |
| 47 | - Existing C reference: `disk_nvme.c`; existing model: `tests/nvme_test.c`. |
| 48 | Their exact hashes and the compiled candidate hash are in |
| 49 | `tests/omega_nvme_receipt.txt`. They were not modified by this change. |
| 50 | - Verification dependencies: GCC 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04.1), |
| 51 | QEMU 8.2.2 (Debian 1:8.2.2+ds-0ubuntu1.18), POSIX shell and ordinary host tools. |
| 52 | These are read-only verification oracles/orchestration, not production runtime |
| 53 | dependencies or an adopted replacement language implementation. |
| 54 | |
| 55 | From the repository root on this Spark: |
| 56 | |
| 57 | ```sh |
| 58 | AIEN_OMC=/home/drakestapleton/work/OwnDriver/omega-gpu-driver/build/omc \ |
| 59 | OMEGA_NVME_EVIDENCE=/home/drakestapleton/handoffs/spark-five-20261028/QualNvmeOm/replay \ |
| 60 | sh native/disk/tests/omega_nvme_test.sh |
| 61 | ``` |
| 62 | |
| 63 | The gate checks omc's independent hash before compilation. It creates a new, |
| 64 | regular namespace image under a private `/tmp/omega-nvme-*` directory; there is |
| 65 | no block-device filename option. QEMU uses TCG, a stopped CPU, 64 MiB guest RAM, |
| 66 | no network, and no host device passthrough. The verifier alone assigns the emulated |
| 67 | PCI BAR and enables that emulated PCI function. The Omega engine then configures |
| 68 | NVMe admin/IO queues and reads the namespace. Cleanup terminates only its own |
| 69 | QEMU process and removes only its disposable image/socket/log directory. |
| 70 | |
| 71 | The filed receipt has 37 passing host cases, seven killed guard-removal mutants, |
| 72 | and ten passing QEMU cases. Successful payloads are byte-identical to |
| 73 | `nvme_read` through the existing C reference. Both supported LBA sizes (512 and |
| 74 | 4096 bytes), one/two PRP pages, repeated IO wrap and repeated admin wrap are |
| 75 | exercised. Refusals cover identity, approval, NSID, extent, request range/count, |
| 76 | metadata, format, queue entry sizes, controller capability, completion CID/SQID/ |
| 77 | SQ-head/phase, timeout, CFS and unsuccessful status. The no-write hostile caller |
| 78 | attempts IO Flush, Write, Write Zeroes, Dataset Management, Format and Sanitize |
| 79 | opcodes, plus administrative Format; all are refused before submission. Removing |
| 80 | the opcode guard makes the existing model observe an IO Write command and kills |
| 81 | the mutant. Removing CID, SQID, SQ-head, status, failed-reopen or retained-DMA |
| 82 | checks also kills their respective mutants. |
| 83 | |
| 84 | The C model does not populate serial/firmware Identify fields. The verifier |
| 85 | supplies those two raw identity fields from the explicit synthetic fixture; |
| 86 | it does not alter queue or data behavior. QEMU supplies its own Identify data. |
| 87 | An inactive NSID is refused differently: the C fixture rejects it against NN |
| 88 | (code 24), while QEMU 8.2.2 returns a zero-size Identify Namespace (code 25). |
| 89 | The initial test expected identical refusal codes; the original failed receipt |
| 90 | is retained in the handoff directory. The final test encodes both independent |
| 91 | controller behaviors and still requires no IO/copy-out. No guard was weakened. |
| 92 | |
| 93 | ## Approved identity manifest |
| 94 | |
| 95 | The normal entrypoint reads exactly 80 bytes before performing any operation. |
| 96 | Integer fields are little endian; identity fields are exact space-padded NVMe |
| 97 | Identify bytes, not trimmed string prefixes. The approval word must equal one; |
| 98 | it binds an already reviewed fixture/manifest, and does not grant device access |
| 99 | or replace operator authorization. Blank serial/firmware is refused. The final |
| 100 | reserved word must be zero in the normal read entrypoint. |
| 101 | |
| 102 | | Offset | Bytes | Meaning | |
| 103 | | --- | --- | --- | |
| 104 | | 0 | 20 | Exact approved controller serial (Identify bytes 4..23) | |
| 105 | | 20 | 8 | Exact approved firmware revision (Identify bytes 64..71) | |
| 106 | | 28 | 4 | Explicit NSID; no first-namespace discovery or fallback | |
| 107 | | 32 | 8 | Approved extent start LBA | |
| 108 | | 40 | 8 | Approved extent block count | |
| 109 | | 48 | 8 | Requested start LBA | |
| 110 | | 56 | 4 | Requested block count | |
| 111 | | 60 | 4 | Repetitions, 1..64 | |
| 112 | | 64 | 4 | Reviewed manifest approval marker, exactly 1 | |
| 113 | | 68 | 4 | Reserved, exactly 0 | |
| 114 | | 72 | 8 | Device-visible base of the transport-owned DMA pool | |
| 115 | |
| 116 | The synthetic fixture binds serial `OMEGA-FIXTURE-000001 `, firmware `8.2.2 `, |
| 117 | NSID 1 and extent [8,72). It requests LBA 8, 16 blocks, 40 repetitions for the |
| 118 | 512-byte fixture. The 4096-byte host fixture requests two blocks. The DMA IOVA is |
| 119 | `0x123456000` in the C model (tests high address dwords) and `0x40000000` in QEMU. |
| 120 | These are guest/model addresses, never host pointer addresses or approved |
| 121 | physical addresses. The host probe entrypoints under `tests/` are never composed |
| 122 | into the normal read entrypoint. |
| 123 | |
| 124 | ## Engine invariants and limits |
| 125 | |
| 126 | - One admin queue and one IO queue, each depth 16; one command outstanding. |
| 127 | SQ tail and CQ head wrap independently; CQ phase starts at one after zeroing. |
| 128 | - The only admin opcodes admitted by the central submit guard are Identify, |
| 129 | Create IO CQ and Create IO SQ. Only Read (2) is admitted on the IO queue. |
| 130 | - Completion phase, CID, SQID, consumed SQ head and success status must all match. |
| 131 | Failed status never copies bounce data to the caller. Wrong correlation or |
| 132 | exhausted poll budget latches failure and retains ownership of DMA storage. |
| 133 | Subsequent reads and reinitialization are refused, without a reset or reuse. |
| 134 | Queue backing is marked retained before CC.EN; readiness timeout/CFS also keeps |
| 135 | it retained. Only a successful ready observation clears that activation marker. |
| 136 | - A 32 KiB transport-owned DMA pool holds ASQ at +0, ACQ +4096, Identify +8192, |
| 137 | IOSQ +12288, IOCQ +16384, one unused page, and bounce pages +24576/+28672. |
| 138 | No PRP list exists. Only aligned, at-most-two-page transfers are admitted. |
| 139 | - CAP must support NVM, 4 KiB minimum pages and at least 16 queue entries; major |
| 140 | VS must be one or two. DSTRD is honored through 12; larger strides are refused |
| 141 | before initialization because the transport's mapped register window is 64 KiB. |
| 142 | SQES/CQES must support 64/16-byte entries. |
| 143 | - Namespace capacity and format are parsed. Only 512/4096-byte LBAs with no |
| 144 | metadata or protection information are accepted. Extent and request bounds are |
| 145 | checked by subtraction before arithmetic; namespace capacity must cover them. |
| 146 | - MDTS zero means no advertised limit. With MPSMIN zero, every nonzero MDTS |
| 147 | permits at least two pages; the fixed 8192-byte software limit cannot exceed it. |
| 148 | - Controller-ready and command waits are bounded to 256 transport polls. This is |
| 149 | a hosted, bounded attempt budget, not a claim of milliseconds or hardware |
| 150 | timeout qualification. Blocking RPCs also have the verifier's wall-clock guard. |
| 151 | Queue/DMA storage stays alive until the verifier tears down its controller. |
| 152 | |
| 153 | ## Native transport integration contract (not exercised) |
| 154 | |
| 155 | The existing compiler pin already supplies `vfiomapw`, width-checked |
| 156 | `mapget/mapset` with DSB SY, and checked `IOMMU_MAP_DMA/UNMAP_DMA`; this change does |
| 157 | not claim those words are missing. A native adapter must reuse the existing |
| 158 | omega-gpu-driver device-ownership setup, rather than reimplement it in C or let a |
| 159 | manifest select arbitrary host physical memory. The exact seam is: |
| 160 | |
| 161 | - `load32/load64(addr)`, `store32/store64(addr,value)`: translate the fixed engine |
| 162 | BAR window or the explicitly owned DMA IOVA range into distinct live mapping |
| 163 | handles; one correctly sized aligned access, bounds checked. No integer-to-CPU |
| 164 | pointer conversion. Preserve ordered SQ writes before doorbell and completion |
| 165 | observation before DMA copy-out. |
| 166 | - `zero_dma`, `fetchid`, `fetchdata`, `publish`: operate only on the owned pinned |
| 167 | DMA pool/caller storage. The IOVA is not the CPU map address. Require documented |
| 168 | coherent-DMA support or implement/qualify the required cache-maintenance profile; |
| 169 | DSB alone is not evidence of cache coherence. |
| 170 | - Retain mappings, pinned pages, container and confinement on uncertain completion. |
| 171 | Do not implement a process-exit/error cleanup that silently drops DMA mappings. |
| 172 | Reclaim only after a separately proven controller-quiescence/IOMMU teardown. |
| 173 | - Replace transport-poll timing with a qualified monotonic deadline and a bounded |
| 174 | poll envelope; report timeout together with retained resources. Add raw command |
| 175 | submit/completion/copy timestamps without tuning queue depth, transfer size, |
| 176 | affinity, scheduler, clocks, firmware settings or cache state. |
| 177 | |
| 178 | The host RPC transport is not this adapter. The kernel boot/effects ABI and |
| 179 | coherency/retention proof need a concrete driver-owned integration before the |
| 180 | physical procedure below is executable. In particular, using the existing C |
| 181 | `nvme_bind.c` as a shortcut is forbidden: it reaches the write/flush/restore probe. |
| 182 | No physical command is supplied that pretends an unimplemented native adapter |
| 183 | already exists. |
| 184 | |
| 185 | ## Exact physical qualification procedure: measurement first |
| 186 | |
| 187 | ### Target and authority |
| 188 | |
| 189 | Current read-only sysfs observation (not a block-device open): controller |
| 190 | `0004:01:00.0`, model `SAMSUNG MZALC4T0HBL1-00B07`, serial `S8C2NG0Y801377`, firmware |
| 191 | `NXHB202Q`. This is the live root NVMe, not a disposable namespace. These facts are |
| 192 | identity observations, NOT an approved physical manifest or permission to reset it. |
| 193 | Sysfs `nvme0/nvme0n1/nsid` is `1`; its `queue/logical_block_size` is `512`. |
| 194 | These are kernel metadata reads only, not Identify commands sent by this candidate. |
| 195 | |
| 196 | The proposed read-only baseline manifest targets **that controller, NSID 1, |
| 197 | extent [0,64) logical blocks**, request start LBA 0, maximum 8192 bytes per command, |
| 198 | 64 repetitions. Actual Identify must first confirm NSID, capacity, firmware and |
| 199 | 512/4096-byte geometry against Drake's signed-off exact manifest. Use 16 blocks per |
| 200 | command for 512-byte LBAs, or two for 4096-byte LBAs. The sample is deliberately a |
| 201 | fixed repeated read of the initial 8192 bytes, not a sequential-bandwidth or |
| 202 | cold-cache maximum-performance claim. No writes or scratch extent on the NVMe are |
| 203 | needed for these reads. A separate medium is needed for the candidate image and |
| 204 | durable evidence; neither shrinking root nor carving a partition is authorized. |
| 205 | If Drake prefers a scratch NVMe instead, its complete BDF/serial/firmware/NSID and |
| 206 | extent require a new manifest and separate approval; never substitute silently. |
| 207 | |
| 208 | The exact manifest, candidate hash, boot medium and physical action must be |
| 209 | approved afresh by Drake through the parent. Historical issue #336 permission or |
| 210 | backup progress is not authorization today. TRUST-1 Gate 7 prerequisites, including |
| 211 | applicable earlier gates, backup and tested recovery, must be satisfied separately. |
| 212 | A read-only NVMe opcode does not make controller reset, PCI ownership changes or |
| 213 | raw DMA safe while Linux is using the controller. |
| 214 | |
| 215 | ### Recovery and 18091 |
| 216 | |
| 217 | The existing recovery USB is **read-only and must be preserved**: Generic Flash |
| 218 | Disk serial `5D0344B4`, PARTUUID `f227357c-1e80-4fd0-a55e-2efbef1dd25c`, label |
| 219 | `AIENOSRECOV`, currently firmware entry **Boot0002**. Parent evidence records an |
| 220 | attended recovery boot on 2026-09-25 with NVMe root/ESP mounted read-only and |
| 221 | `RECOVERY_BOOT_GATE: PASS`; it has not been rebooted for this work. Do not overwrite, |
| 222 | format, mount read/write or repartition it. Do not use obsolete Boot0004 numbering. |
| 223 | A separate blank boot medium for the candidate has not yet been supplied. |
| 224 | |
| 225 | All host/QEMU work in this receipt leaves resident 18091 alone. A native boot on |
| 226 | this sole-root-disk machine necessarily interrupts Linux and 18091; it requires an |
| 227 | explicit downtime/restore window through the parent. Never infer permission to |
| 228 | stop 18091, reboot, unbind root NVMe, bind VFIO, reset, or change firmware entries |
| 229 | from permission for read-only telemetry. A separate authorized scratch controller |
| 230 | could avoid the root-disk reboot, but none is currently approved. |
| 231 | |
| 232 | ### Ordered operator run (all steps below NOT_RUN) |
| 233 | |
| 234 | 1. Finish and exercise the native transport contract above in disposable emulation. |
| 235 | Freeze compiler/candidate/manifest hashes and the unoptimized baseline policy. |
| 236 | Verify recovery evidence and separate candidate/evidence medium with the parent. |
| 237 | Confirm backup/recovery and the precise downtime/restore authorization. Stop if |
| 238 | any prerequisite or exact identity differs. |
| 239 | 2. Parent executes only the separately approved boot/image procedure. Never boot |
| 240 | Boot0000 ALLEN.EFI or Boot0005 CORE.EFI: existing paths include a write probe. |
| 241 | Do not reuse the normal C NVMe binder. Do not touch ESP, BootNext or firmware |
| 242 | entries as part of this read qualification. The approved candidate must own the |
| 243 | NVMe exclusively, with bounded DMA confinement, before queue initialization. |
| 244 | 3. Print candidate and manifest hashes, PCI identity, raw serial/firmware, |
| 245 | namespace geometry, IOVA pool bounds, fixed queue depth 16, one outstanding |
| 246 | command, PRP limit, deadline and repetition count. Require exact matches before |
| 247 | issuing reads. Record controller-ready/Identify outcomes separately from reads. |
| 248 | 4. **Measure before changing anything.** With the fixed baseline above, preserve |
| 249 | every raw `submit_ns`, `complete_ns`, `copy_done_ns`, LBA, byte count, CID, SQID, |
| 250 | SQ/CQ position/phase and status for all 64 reads. Report both controller |
| 251 | completion and end-to-caller timings and observed bytes. Record cache state as |
| 252 | uncontrolled/repeated-read, not a claimed cold-device workload. No tuning, |
| 253 | warmup suppression, queue-depth experiments, prefetch, affinity or clock changes |
| 254 | precede this immutable baseline receipt. A timeout/error stops the run, with no |
| 255 | reset/retry or DMA reclamation, and produces a retained-resource record. |
| 256 | 5. Save raw records to the separately authorized evidence medium, not NVMe. Have |
| 257 | Wolfram evaluate latency distribution and aggregate throughput from those exact |
| 258 | records, quoting query/result and units; never infer numbers from QEMU timings. |
| 259 | Example query shape uses measured integer-nanosecond lists `submit`, `complete`, |
| 260 | `copied` and measured integer byte counts `bytes`: |
| 261 | `With[{d=complete-submit}, {Min[d],Median[d],Quantile[d,95/100],Max[d]}]` in ns; |
| 262 | `Total[bytes]/((Last[copied]-First[submit])/10^9)` in bytes/s. These are procedure |
| 263 | queries only: **NOT_RUN, no fabricated physical result**. Keep controller and |
| 264 | copy-inclusive statistics distinct. Record SSD/model service impact separately. |
| 265 | 6. Release DMA/controller ownership only after the native quiescence proof succeeds. |
| 266 | If it fails, retain confinement/pages and use the preapproved attended recovery |
| 267 | route; do not try a reset/rebind loop. Parent returns via the authorized boot |
| 268 | path, verifies normal Linux root and 18091 health, and records restoration. |
| 269 | 7. Freeze the baseline receipt as measured, even if slow or failed. Only a later, |
| 270 | separately approved tuning experiment may compare configurations. Do not rewrite |
| 271 | historical atomicity failures, recovery receipts or this NOT_RUN status as PASS. |
| 272 | |
| 273 | ### Checked arithmetic and references |
| 274 | |
| 275 | WolframLanguageEvaluator: |
| 276 | `{6*4096+8192,16*64,16*16,BitOr[6*2^16,4*2^20,1],BitOr[15*2^16,15],8192/512,4096/512}` |
| 277 | returned `{32768,1024,256,4587521,983055,16,8}` (byte counts where applicable). |
| 278 | `{2^64-32769,BitOr[1,15*2^16],8*512,64*512,(8+64)*512,8+64-1,Mod[44,16],Mod[40,16],16^^123456000}` |
| 279 | returned `{18446744073709518847,983041,4096,32768,36864,71,12,8,4886716416}`. |
| 280 | `Table[{d,4096+3*4*2^d+4,4096+3*4*2^d+4<=65536},{d,12,13}]` |
| 281 | returned `{{12,53252,True},{13,102404,False}}` (byte window upper endpoints). |
| 282 | These are layout/bounds calculations, not measured device performance. |
| 283 | |
| 284 | - [aienux #31](https://github.com/aien-dev/aienux/issues/31), forward seeded Omega driver. |
| 285 | - [aienux #336](https://github.com/aien-dev/aienux/issues/336), single SSD/backup/recovery decisions. |
| 286 | - [synapse #54](https://github.com/aien-dev/synapse/issues/54), store work, not a queue implementation. |
| 287 | - Existing `disk_nvme.c`, `tests/nvme_test.c` and `scripts/qemu_native_nvme_test.sh` remain oracles. |
| 288 | - [QEMU QTest protocol](https://www.qemu.org/docs/master/devel/testing/qtest.html), |
| 289 | byte-access request/response semantics. No QTest socket exists in production. |
| 290 | - [NVM Express Base Specification 2.0c](https://www.nvmexpress.org/wp-content/uploads/NVM-Express-Base-Specification-2.0c-2022.10.04-Ratified.pdf), |
| 291 | sections 3.3.3.2/3.3.3.2.2 and Figure 275. © 2008 to 2022 NVM Express, Inc. |
| 292 | ALL RIGHTS RESERVED. Used as a reference, not copied implementation code. |
| 293 | - omega-mv at the pin above, `seed/host/MAPPING.md`, exact VFIO/map access contracts. |