omega-gpu-driver
aien-dev/omega-gpu-driver
Brought by drakestapleton
omega-gpu-driver / DESIGN.md
| 1 | # omega-gpu-driver design notes |
| 2 | |
| 3 | Status: sections 1-3 are **PROPOSED**. Sections 4 and 8 are **IMPLEMENTED and EXERCISED on the host only**; sections 5-7 retain their individually stated evidence boundaries. |
| 4 | Nothing here has run on GB10 hardware; hardware qualification is **NOT_RUN**. |
| 5 | |
| 6 | The bring-up design (GSP boot chain, RPC surface, the `ogd` launcher and manifest, the D2 window) is in the |
| 7 | lane's design document and is summarised in `README.md` and `window/README.md`. This file holds the design |
| 8 | decisions for the driver's isolation model and its userspace interface. |
| 9 | |
| 10 | Source: an accel-driver survey of 2026-10-27 (lessons 1-3). It read the two Linux accel NPU drivers at |
| 11 | torvalds/linux `d135ab453a740`. All `drivers/accel/...` and `include/uapi/...` cites below are file:line in |
| 12 | that tree. `NV:` cites are NVIDIA open-gpu-kernel-modules 580.173.02, `src/common/sdk/nvidia/inc/class/`. |
| 13 | |
| 14 | ## 1. Isolation: one private GPU address space per client, no pushbuffer parser |
| 15 | |
| 16 | **The two Linux models.** The two drivers protect the device in different ways: |
| 17 | |
| 18 | - **ethosu has no MMU**, so the kernel checks every command stream. |
| 19 | - It copies the stream into a buffer object marked no-mmap (`ethosu_drv.c:130`, enforced at |
| 20 | `ethosu_gem.c:26-27`), so userspace cannot change it after the check. |
| 21 | - It replays the stream in an interpreter (`ethosu_gem_cmdstream_copy_and_validate`, `ethosu_gem.c:385-707`). |
| 22 | - Submit refuses a region that does not fit its buffer (`ethosu_job.c:398-496`). |
| 23 | - **rocket has an MMU** and never parses commands. |
| 24 | - `rocket_open` gives each open file its own IOMMU paging domain (`rocket_drv.c:72,89`; created at 38-56). |
| 25 | - Buffers are mapped into that domain (`rocket_gem.c:96`). |
| 26 | - The domain is attached to the core for each job and detached afterwards (`rocket_job.c:348`, 382, 406). |
| 27 | |
| 28 | **What OwnDriver adopts.** The GB10 translates GPU virtual addresses through its GMMU, so OwnDriver follows rocket: |
| 29 | |
| 30 | - Every client gets its own GPU VA space (FERMI_VASPACE_A). That client's page tables come from local GMMU |
| 31 | code (`chan/gmmu.om`) and are installed with SET_PAGE_DIRECTORY. |
| 32 | - A client's buffers are mapped only into its own VA space. |
| 33 | - The driver does **not** parse or check pushbuffers or GPFIFO contents. Its job is address-space setup, |
| 34 | buffer bounds, fences and teardown. |
| 35 | |
| 36 | **Paths the GMMU may not translate.** On these paths ethosu-style copy-then-check still applies. The paths |
| 37 | come from the docs and none has been checked on the chip (UNVERIFIED): |
| 38 | |
| 39 | 1. **Copy-engine physical mode.** Ampere's copy class has `LAUNCH_DMA_SRC_TYPE_PHYSICAL` and |
| 40 | `DST_TYPE_PHYSICAL` (`NV:clc7b5.h:121-126`). The published Blackwell copy headers (`NV:clc9b5.h`, |
| 41 | `NV:clcab5.h`) list too few methods to say whether the mode still exists. |
| 42 | 2. **Structures the GPU reads by bus address.** |
| 43 | - These are the instance block, RAMFC, USERD and the GPFIFO ring, whose IOVAs travel in the channel alloc |
| 44 | RPC (lane design §3). |
| 45 | - ogd allocates and writes them itself; a client never supplies their contents. That is the copy-then-check |
| 46 | rule applied at allocation. |
| 47 | 3. **The SMMU.** It translates every device access (`iommu.passthrough=0`; the GPU is alone in IOMMU group 20). |
| 48 | But one VFIO container gives the whole device a single IOMMU domain. A physical-mode access is therefore |
| 49 | bounded by the union of all clients' DMA mappings, not by one client's mappings [INFERENCE]. Until (1) is |
| 50 | settled, either refuse physical-mode copy methods, or run only one client at a time. |
| 51 | |
| 52 | **Scope in v1.** In v1 the workload inherits the VFIO device fd (lane design §4), so it has BAR0 read/write |
| 53 | access. v1 therefore has one trusted workload per `ogd` session and claims no isolation between clients. The |
| 54 | per-client VA space model starts to protect something only once `ogd` serves more than one client and the |
| 55 | workload no longer holds the VFIO fd. That is v2: a request pipe, plus a mapping of only the doorbell and |
| 56 | USERD pages. |
| 57 | |
| 58 | ## 2. Submit ABI |
| 59 | |
| 60 | The rules come from ethosu's job path and rocket's uapi. Each one is required from the first version of the ABI: |
| 61 | |
| 62 | - **Per-buffer read/write flags; the write fence goes only on outputs.** |
| 63 | - ethosu takes an implicit dependency for every buffer, marked as a write only for output regions |
| 64 | (`ethosu_job.c:91-99`). |
| 65 | - It attaches the done fence with `DMA_RESV_USAGE_WRITE` only to outputs (`ethosu_job.c:102-114`). |
| 66 | - It locks all buffers as one group (`drm_gem_lock_reservations`, `ethosu_job.c:122-142`). |
| 67 | - Each submit buffer entry in my ABI carries `READ`, `WRITE` or both. A read-only input never waits on |
| 68 | another reader. |
| 69 | - **A watchdog that checks progress before resetting.** |
| 70 | - ethosu runs one job in flight (`credit_limit = 1`, `ethosu_job.c:327`). |
| 71 | - Its timeout handler reads the queue read pointer (`NPU_REG_QREAD`, `ethosu_job.c:280`). If the pointer |
| 72 | still moves, it lets the job run on (`ethosu_job.c:287-292`) and resets only after that (`ethosu_job.c:305`). |
| 73 | - My counterpart is GPGet in USERD and the semaphore sequence. The watchdog reads one of them before it |
| 74 | tears a channel down. A timeout with that counter still advancing is not a hang. |
| 75 | - **Reserved, pad and flags fields must be zero.** Refuse the call otherwise: ethosu `ethosu_drv.c:125`; |
| 76 | rocket `rocket_gem.c:143`, `rocket_gem.c:174` and `rocket_job.c:643`. An unknown flag bit is refused, never |
| 77 | ignored. |
| 78 | - **Self-sized structs.** |
| 79 | - rocket's submit carries `job_struct_size` and `task_struct_size` (`rocket_accel.h:142-145`, 177-180). |
| 80 | - The kernel refuses sizes smaller than the struct it knows (`rocket_job.c:77`, 638-639) and steps through |
| 81 | the arrays by the size the caller declared (`rocket_job.c:95`, 656). |
| 82 | - My records start with a byte size and a version. The ABI can then grow at the tail without breaking old |
| 83 | callers. |
| 84 | |
| 85 | ## 3. Ordering and cache sync: fences, not cache-maintenance calls |
| 86 | |
| 87 | rocket brackets CPU access with explicit calls: |
| 88 | |
| 89 | - `PREP_BO` waits for the write fence with a timeout, then calls `dma_sync_sgtable_for_cpu` |
| 90 | (`rocket_gem.c:152-161`). |
| 91 | - `FINI_BO` calls `dma_sync_sgtable_for_device` (`rocket_gem.c:186`). |
| 92 | |
| 93 | rocket needs these because the RK3588 NPU's DMA is not cache-coherent. That is the reason given in review; it |
| 94 | was not checked against RK3588 documentation here. ethosu syncs implicitly when a buffer is waited on or mapped. |
| 95 | |
| 96 | The GB10 is a self-hosted part with a coherent C2C link. NVIDIA's RM treats it as such: |
| 97 | |
| 98 | - Local EGM is set up only when `gpuIsSelfHosted(pGpu)` and `PDB_PROP_KBIF_IS_C2C_LINK_UP` hold |
| 99 | (`NV2:mem_mgr.c:4022-4023`, with the comment "EGM can be enabled only in C2C path"). |
| 100 | - When `kbusIsBar1Disabled` (`NV2:mem_mgr_gm107.c:619`), BAR1 is reported as size 0, with the comment "When |
| 101 | coherent C2C path is enabled, BAR1 is disabled" (`NV2:mem_mgr_gm107.c:688-694`). |
| 102 | |
| 103 | `NV2:` is `src/nvidia/src/kernel/gpu/mem_mgr/` (with `arch/maxwell/` for the gm107 file) in the same |
| 104 | 580.173.02 tree. Neither function has been run on my chip. The lines say how RM treats a self-hosted C2C |
| 105 | GPU, not that every GB10 access path is coherent. |
| 106 | |
| 107 | What this design takes from that: |
| 108 | |
| 109 | 1. **The proposed ordering model is fences plus memory ordering, not a coherency proof.** |
| 110 | - The CPU reads an output only after that job's write fence (§2) has signalled. |
| 111 | - The submit path keeps its barriers: ring write, `dsb sy`, GPPut, `dsb sy`, doorbell. |
| 112 | - Completion is a semaphore release that the CPU reads after the fence. |
| 113 | - `prep`/`fini` cannot yet be declared GB10 no-ops. NVIDIA 580.173.02 |
| 114 | `src/common/sdk/nvidia/inc/nvos.h:1117-1125` explicitly warns that GPU-cached system memory is |
| 115 | not coherent with direct CPU mappings. A coherent C2C link alone does not settle GPU-cache policy. |
| 116 | 2. **No BAR1 VRAM mapping.** BAR1 is off on this chip: RM reports it as size 0 (above), and sysfs shows BAR0 |
| 117 | only (lane design §1). |
| 118 | - All buffers are sysmem: pinned pages, VFIO MAP_DMA, and GMMU PTEs with the snooped sysmem aperture. |
| 119 | - The CPU's view of a buffer is the CPU's own mapping of those pages. |
| 120 | |
| 121 | ## 4. Owned userspace DMA window |
| 122 | |
| 123 | `chan/gmmu.om` no longer presents the simulator's global `mmwin` array as hardware DMA backing. |
| 124 | `mmwinit` selects that array explicitly. `mmwalloc(iova, size)` instead owns one shared anonymous |
| 125 | read/write `mapnew` handle. CPU access uses that live handle plus a checked offset through |
| 126 | `mmrd32/64`, `mmwr8/32/64` and `mmzero`. The compiler's ordered word operations are used for aligned |
| 127 | 32/64-bit accesses; zeroing handles byte tails separately. `mmwb` is an IOVA, `mmwcpu` is an |
| 128 | informational CPU virtual base, and a buffer's `gmbva` is its independent GPU VA. They are not aliases. |
| 129 | |
| 130 | This is a Linux **userspace VFIO** backend, not an Omega Linux kernel module or replacement for |
| 131 | Linux's DMA/IOMMU implementation. It neither opens nor closes a VFIO fd, adopts a container, resets |
| 132 | a device, or changes authorization. The caller must already have sole lifecycle ownership of the |
| 133 | authorized container. No fork, fd close/reuse, concurrent caller, or process restart may invalidate |
| 134 | the recorded tuple while it is retained. The process-local quarantine latch is not crash-safe |
| 135 | containment and is not permission to run hardware. |
| 136 | |
| 137 | The immutable live tuple is `(mmwgen, mmwh, mmws, mmwb, mmwfd)`: epoch, owned handle, whole length, |
| 138 | IOVA and container fd. `mmwgen` never wraps. Address-space, buffer and channel operations validate |
| 139 | their recorded window epoch; an old slot cannot become live merely because a new window exists. |
| 140 | |
| 141 | | State | Allowed transition | |
| 142 | |---|---| |
| 143 | | NONE | `mmwalloc` -> OWN only after backing allocation succeeds | |
| 144 | | OWN | `mmwdmap(epoch, fd)` -> DMA only after whole-window MAP_DMA succeeds | |
| 145 | | DMA | `mmwpublish(epoch)` -> PUB **before** exposing any IOVA through boot args, mailbox, RPC, channel bind or page-directory register | |
| 146 | | OWN or DMA, never published | `mmwclose(epoch)` -> NONE; DMA requires successful full exact UNMAP_DMA before `mapdrop` | |
| 147 | | PUB | No reclaim/reset/reuse API; uncertain completion -> QUAR | |
| 148 | | QUAR | No reclaim/reset/reuse API, including after a modelled idle or successful TLB invalidation | |
| 149 | |
| 150 | `chan/dma.om` reconstructs the request for every attempt: compiler `397e6704` replaces the vaddr |
| 151 | handle with the CPU base even when the ioctl fails. Only EBADF is classified as proven no-target |
| 152 | and remains OWN; other mapping errors retain uncertain ownership in QUAR without speculative |
| 153 | UNMAP_DMA. Failed unmap, zero/partial/oversized returned extent, or failed drop retain the handle. |
| 154 | The entire recorded range must be returned by UNMAP_DMA before drop. An unmap failure is never |
| 155 | converted into reclamation. |
| 156 | |
| 157 | Publication is sticky even if the following operation fails. Page-table root publication latches |
| 158 | PUB before register writes; timeout latches QUAR. Owned page-table/allocator reset, mutation and |
| 159 | published-buffer reuse are refused. Simulator channel ops explicitly refuse owned backing rather |
| 160 | than walking the unrelated `mmwin` array. The boot/RPC caller must invoke `mmwpublish` before |
| 161 | serializing any DMA reference and `mmwquar` on uncertain post-publication completion. This backend |
| 162 | does not supply those GSP callsites or invent an idle proof. No documented, exercised GB10 idle |
| 163 | protocol exists here; published or quarantined memory therefore remains retained. |
| 164 | |
| 165 | Sources: Linux `include/uapi/linux/vfio.h:1544-1615` (whole mapping and actual returned unmap size), |
| 166 | NVIDIA 580.173.02 `nvos.h:1117-1125` (cache policy warning), and |
| 167 | omega-mv `397e67040fb74853c6814097fe02ae4e1ebd6f66`, `seed/host/MAPPING.md:27-45,84-98`. |
| 168 | Pinned omc sha256: `bcfa582892afca8f65e551fe56867d918d86e84540c7381be8fa9ef18d0cf0f6` |
| 169 | (pending omega-mv#890 stacked on #878, not main). |
| 170 | |
| 171 | Host evidence: `OMC=/path/to/pinned/omc sh tests/dma_host.sh` exercises anonymous memory, a real |
| 172 | invalid-fd refusal/retry, 23 explicit replay/boundary cases and 11 compiling negative-control mutants. |
| 173 | The replay transport is test-only link-time substitution, not a runtime fallback or DMA evidence. |
| 174 | `tests/chan_diff.sh` preserves the simulator's 391-line byte-identical C-reference trace. |
| 175 | Observed exit 0 for both gates. Replay binary sha256: |
| 176 | `06f290ccc82f33cfa2ae14b8a0604ba722988b93e6ff7299259b8779cc7a9575`; |
| 177 | production invalid-fd check binary sha256: |
| 178 | `e2dfe13d77b4ae92b91b2ae6751eb1f107420754547b4da5fddf56058697ec60`. |
| 179 | The gate emits source-file and binary checksums on each run; those are compiler/host evidence only. |
| 180 | No VFIO device was opened and no MMIO, DMA, reset, driver or service action was performed. |
| 181 | Hardware and Linux-kernel execution: **NOT_RUN**. |
| 182 | |
| 183 | ## 5. Unified memory page tables (2026-11-05) |
| 184 | |
| 185 | Status: **IMPLEMENTED and HOST_EXERCISED**. Hardware qualification is **NOT_RUN**. This section does |
| 186 | not change sections 1-4 and does not install a page table on a device. |
| 187 | |
| 188 | `uvm/fmt.om`, `uvm/pt.om` and `uvm/fault.om` build Blackwell VER3 page tables, allocate a 2^28-byte |
| 189 | window at VA 2^32, map and unmap 4 KiB, 64 KiB and 2 MiB pages, and decode one NVC369 32-byte fault |
| 190 | packet. Field positions are cited from open-gpu-kernel-modules 580.173.02 (`dev_mmu.h` |
| 191 | `NV_MMU_VER3_*`, `dev_fault.h` `NV_PFAULT_FAULT_TYPE_*`, `clc369.h` `NVC369_BUF_ENTRY_*`). No NVIDIA |
| 192 | source is copied. `chan/gmmu.om` remains the channel port. These units use the `uv` prefix and must |
| 193 | not be concatenated with `chan/`. |
| 194 | |
| 195 | The page-table pool is 16 pages of 4096 bytes at physical address 2^31. A leaf PTE sets bit 0. A |
| 196 | page-directory entry leaves bit 0 clear and stores aperture SYS (2) at bits 2:1 and PCF 2 at bits |
| 197 | 5:3. The physical address is bits 51:12, except a 64 KiB PDE, whose address is bits 51:8. The PD0 |
| 198 | entry is 16 bytes: word 0 is the 64 KiB table or a 2 MiB PTE, word 1 is the 4 KiB table. A set valid |
| 199 | bit in word 0 is a 2 MiB leaf, not a pointer. |
| 200 | |
| 201 | Constants, WolframLanguageEvaluator: `2^12 -> 4096`, `2^16 -> 65536`, `2^21 -> 2097152`, |
| 202 | `2^31 -> 2147483648`, `16*4096 -> 65536`, `2^32 -> 4294967296`, `2^28 -> 268435456`, |
| 203 | `2^57 -> 144115188075855872`, `2^52 -> 4503599627370496`, |
| 204 | `BitAnd[2^52-1, BitNot[2^12-1]] -> 4503599627366400`, |
| 205 | `BitAnd[2^52-1, BitNot[2^8-1]] -> 4503599627370240`. |
| 206 | |
| 207 | Fault service is a policy, not a device action. An invalid packet is ignored. A disabled packet, a |
| 208 | non-replayable packet, or fault type 3 or above is fatal. A replayable fault whose VA has no |
| 209 | reservation, or whose reservation has no physical page, is cancelled. A write to a read-only |
| 210 | reservation is fatal. Otherwise the missing page is mapped from the reservation and the action is |
| 211 | replay. A second fault on a page that replay already mapped does not write the table again. |
| 212 | |
| 213 | Host evidence is `tests/uvm_diff.sh` and `tests/mutants-uvm.sh`, both exit 0 on 2026-11-05, compiled |
| 214 | with omc sha256 `2c82480596bbdc50cda9626866209ef662d5834f278f839ff4ce0250c495029f`. The checker walks |
| 215 | the dumped bytes itself. Overlap, misalignment, an out-of-window VA, a pool alias, a read-only |
| 216 | write, an invalid packet and a non-replayable fault are refused. Five single-line mutants are |
| 217 | killed, and one flipped dump nibble is refused. |
| 218 | |
| 219 | Chip runbook. Do not run a device command from this unit. It has no device words and no |
| 220 | SET_PAGE_DIRECTORY path. Blocked on an exclusive Drake-authorized window and on a qualified |
| 221 | instance-MMU install path in this driver. Until both exist, the chip tier stays **NOT_RUN**. The |
| 222 | host commands that must stay green before that window are: |
| 223 | |
| 224 | taskset -c 10-14 nice -n 10 sh tests/uvm_diff.sh |
| 225 | taskset -c 10-14 nice -n 10 sh tests/mutants-uvm.sh |
| 226 | |
| 227 | A future window, after that install path exists, compares one 32-byte fault-buffer entry from the |
| 228 | instance with the decode in `tests/uvm_check.py`. That comparison has no command yet, because |
| 229 | writing one that opens `/dev/nvidia*` would be a false runbook. Do not take |
| 230 | `/tmp/aien-gb10.lock`. Host PASS is not chip qualification. |
| 231 | |
| 232 | ## 6. Bounded UVM service (host model) |
| 233 | |
| 234 | This first-party seeded Omega service builds on section 5, not NVIDIA implementation code. |
| 235 | It is not a kernel module, a Linux ioctl endpoint, or a hardware queue producer. The chip tier remains |
| 236 | **NOT_RUN**. All implementation is `.om`; Python 3.12.3 and Ubuntu cc 13.3.0 are verification |
| 237 | oracles only, never linked into the service. The local model queue is first-party Omega from draft |
| 238 | #11 at `b06b3f9a3dd1e74a3099350760cb3d26a3f33577`, stacked on #9. This service branch is |
| 239 | stacked on #10 at `4917e4e218e392526351e05b9169bd00679ac724`. |
| 240 | |
| 241 | ### Entry points and bounded ownership |
| 242 | |
| 243 | One isolated service instance owns one VA space and one serialized producer/consumer pair. |
| 244 | `screate`/`sdestroy` create/destroy that space; destroy refuses a nonempty range tree or pending |
| 245 | fault/command records. Removal refuses unconsumed command records before touching PTEs. A space |
| 246 | cannot be reused with stale faults. There is no concurrency, process-exit reclamation or physical |
| 247 | completion proof in this model. |
| 248 | |
| 249 | Callers clear `sen` before each top-level batch/notification to own the bounded event output; the |
| 250 | trace harness does so for every request. The ring indices, overflow latch and queue indices persist. |
| 251 | |
| 252 | `sadd(va,size,pa,policy)`, `ssplit(va)`, `smerge(base)` and `sremove(base,size)` maintain up to |
| 253 | 64 sorted, nonoverlapping ranges. `sfind(va)` traverses their implicit balanced binary-search tree. |
| 254 | The array representation needs no allocator or pointer ownership. Split preserves policy and |
| 255 | physical offset. Merge requires adjacent VA and PA intervals and identical policy. Remove requires |
| 256 | the exact interval; callers split first for subrange removal. Removal unmaps installed 4K PTEs and |
| 257 | clears residency/counter state. The section-5 16-page page-table pool is bounded and never reclaimed |
| 258 | piecemeal; a new empty space resets it. This service uses 4K pages; section 5 separately supports |
| 259 | 64K/2M pages. |
| 260 | |
| 261 | Policy bits: 0 preferred location (CPU=0, GPU=1), 2:1 accessed-by mask (CPU=1, GPU=2), |
| 262 | 3 read duplication, 4 read-only, 5 cancel-on-fault. Other bits are refused. All addresses and sizes |
| 263 | must be 4K-aligned and fit section 5's VA/PA windows; overlap returns UVEBUSY=3, misalignment |
| 264 | UVEALIGN=2, capacity UVENOM=4, missing interval UVENOENT=5, bounds UVERANGE=6. The physical |
| 265 | page-table pool cannot be aliased. A zero backing PA denotes an unbacked reservation and cancels |
| 266 | faults rather than inventing physical memory. |
| 267 | |
| 268 | ### Fault ring, pipeline and queue records |
| 269 | |
| 270 | `uvpkt` is the caller's 32-byte packet staging buffer. `fbpush` preserves every byte and advances |
| 271 | monotonic PUT only if one of 16 entries is free. Full returns UVENOM and latches overflow; |
| 272 | `fbrecover` clears it only after GET catches PUT. PUT wrap is refused. `fbbatch` stops at an |
| 273 | invalid head without advancing GET; valid consumption clears the valid bit and advances GET. |
| 274 | It deduplicates benign replayable faults by (4K VA page, access type), not fatal/nonreplayable |
| 275 | packets. Queue pressure leaves the head intact for a later explicit retry. It does not silently |
| 276 | discard queued faults when overflow occurs. |
| 277 | |
| 278 | `sservice` decodes using section 5's `fault.om`: disabled, nonreplayable, malformed-access or fatal |
| 279 | faults yield UVFATAL=11. Missing/unbacked/cancel-policy ranges yield UVCANCEL=10. Read-only |
| 280 | write/atomic faults are fatal. Successful faults build or update an actual section-5 PTE, update a |
| 281 | 128-entry residency ledger, emit invalidate then replay, and return UVREPLAY=9. A per-batch event |
| 282 | contains six LE u64s: VA page, access, decision, PA, the actual installed PTE bytes, residency mask. |
| 283 | Nonmapping decisions zero the final three fields. |
| 284 | |
| 285 | The connected #11 `iqcommand(op,seq,va,pa,flags)` format is five LE u64s (40 bytes), capacity 8: |
| 286 | op=2 local invalidate descriptor, then op=1 local replay descriptor. Flags are the CPU/GPU residency |
| 287 | mask. Sequence is nonzero and strictly increasing. These are deliberately **not** NVIDIA physical |
| 288 | RPC IDs. `iqctake` captures an immutable consumer item and `iqcack(exact-sequence)` advances once. |
| 289 | The service reserves two free slots and sequence/producer headroom before changing any PTE. It |
| 290 | requires model mode and live state. A failed publication after a PTE change sets sticky `sqbad` and |
| 291 | fatally refuses later faults; no rollback pretends the device never observed a mapping. There is no |
| 292 | hardware effect adapter. Consuming/ACKing a record is not a TLB/replay completion receipt. |
| 293 | |
| 294 | ### GB10 shared physical memory and access counters |
| 295 | |
| 296 | GB10 CPU and GPU share physical memory. Here migration changes the mapping permissions, logical |
| 297 | residency and required coherence descriptors, **never copies data or changes backing PA**. A GPU |
| 298 | write/atomic makes logical ownership GPU-only; CPU mappings must be invalidated by a future effect |
| 299 | adapter before real replay. A read keeps CPU access for CPU-preferred/accessed-by-CPU/read-duplicate |
| 300 | policy; otherwise GPU-only. Read duplication installs a read-only GPU PTE; a later write changes |
| 301 | permissions on the same PA and drops CPU ownership. Permanent read-only policy never upgrades. |
| 302 | These are model transitions, not measured cache coherency. No behavior is claimed for a discrete |
| 303 | GPU needing physical migration/copies. |
| 304 | |
| 305 | `scnotify(limit)` consumes one NVC365 notification from `uvpkt`. It requires limit 1..65535, |
| 306 | valid=1, virtual address type and coherent system aperture. Invalid entries are ignored; physical or |
| 307 | unsupported-aperture entries are refused, not guessed. Decoded fields are page VA, 16-bit absolute |
| 308 | count, CPU/GPU type and 20-bit tag. Unmapped/unresident pages return UVENOENT. It records the |
| 309 | latest count; counts below the inclusive threshold are ignored. At/above threshold it runs the same |
| 310 | read-fault pipeline; a CPU notification does not move a GPU-preferred page. This is an explicit |
| 311 | threshold policy, not an assertion about hardware counter reset, sampling or scheduling semantics. |
| 312 | |
| 313 | ### Server-side ioctl ABI |
| 314 | |
| 315 | `sidispatch(cmd,size)` reads `siab` and returns local UV status, `siolen`, and `siob` output bytes. |
| 316 | It copies the exact-size input into output, modifies defined output fields, and writes `rmStatus`. |
| 317 | Unknown commands or any wrong byte length return UVEINVAL with zero output length. No ioctl |
| 318 | system call executes. One instance admits one registered GPU/VA-space pair. Initialization cannot |
| 319 | repeat; flags 0 and 1 are supported, other flags are refused. UUID, client and nonnegative fd are |
| 320 | validated as model identity, not as real RM authority. |
| 321 | |
| 322 | `siobject(handle,pa,size)` is the server's explicit trusted backing-capability input. External allocation |
| 323 | mapping requires such a capability, registered GPU and VA space, matching client/fd/UUID, bounded |
| 324 | offset and default mapping/cache/format attributes. An RM handle is never reinterpreted as a PA. |
| 325 | No real RM object resolver is implemented or implied. FREE removes an exact range; GPU unregister |
| 326 | refuses live ranges. Range groups issue monotonic IDs; no group-membership ioctl is in this scope. |
| 327 | PAGEABLE_MEM_ACCESS reports this model's supported pageable policy, not the installed Linux driver's |
| 328 | capability. Local errors map to NV_ERR_INVALID_ARGUMENT=31, INVALID_STATE=64 for permission, |
| 329 | and IN_USE=23 for busy; success is NV_OK=0. |
| 330 | |
| 331 | All header references below are read-only NVIDIA open-gpu-kernel-modules **580.173.02**, |
| 332 | commit `20e4e6e19cc26ba47b5cbe23130a396be100c427`. Only positions/numbers were used: |
| 333 | |
| 334 | | Command | Number | Host measured size/status offset | Source path:line | |
| 335 | |---|---:|---|---| |
| 336 | | UVM_INITIALIZE | 805306369 | 16 / 8 | `kernel-open/nvidia-uvm/uvm_linux_ioctl.h:28-38` | |
| 337 | | UVM_REGISTER_GPU | 37 | 40 / 36 | `kernel-open/nvidia-uvm/uvm_ioctl.h:532-543` | |
| 338 | | UVM_UNREGISTER_GPU | 38 | 20 / 16 | `kernel-open/nvidia-uvm/uvm_ioctl.h:548-554` | |
| 339 | | UVM_CREATE_RANGE_GROUP | 23 | 16 / 8 | `kernel-open/nvidia-uvm/uvm_ioctl.h:381-387` | |
| 340 | | UVM_MAP_EXTERNAL_ALLOCATION | 33 | 9264 / 9260 | `kernel-open/nvidia-uvm/uvm_ioctl.h:491-504` | |
| 341 | | UVM_FREE | 34 | 24 / 16 | `kernel-open/nvidia-uvm/uvm_ioctl.h:509-515` | |
| 342 | | UVM_REGISTER_GPU_VASPACE | 25 | 32 / 28 | `kernel-open/nvidia-uvm/uvm_ioctl.h:400-409` | |
| 343 | | UVM_PAGEABLE_MEM_ACCESS | 39 | 8 / 4 | `kernel-open/nvidia-uvm/uvm_ioctl.h:556-562` | |
| 344 | |
| 345 | `uvm_ioctl.h:37-40` defines the Linux command encoding. `uvm_types.h:69-71,84-94` defines flags |
| 346 | and mapping attributes. `src/common/sdk/nvidia/inc/class/clc365.h:36-41,59-79` defines the access |
| 347 | counter type/address/aperture/address/tag/count/valid positions. Section 5 pins NVC369 fault fields. |
| 348 | All ABI sizes and offsets are measured **only by host cc sizeof/offsetof** in |
| 349 | `tests/uvms_offsets.c`; `tests/uvms-abi.txt` is its byte-exact fixture and the gate remeasures it. |
| 350 | No vendor implementation code is copied. |
| 351 | |
| 352 | ### Host acceptance and chip runbook |
| 353 | |
| 354 | Run `taskset -c 10-14 nice -n 10 python3 -u tests/uvms_check.py --mutants`. |
| 355 | The Python oracle uses declarative interval lists and dictionary PTE/residency state rather than |
| 356 | porting Omega's row shifts, page-table walk or binary search. It compares every output byte: |
| 357 | ranges, fault decisions, installed PTE records, complete command ring, fault ring, monotonic indices, |
| 358 | residency ledger, decoded access-counter fields and ioctl output. Fixed-seed 20261105 fuzz performs |
| 359 | 10,000 range operations; focused traces cover wrap/overflow/invalid-head/dedup, queue reservation and |
| 360 | retry, permission changes, cancellation/fatal faults, thresholds and backing-capability refusals. |
| 361 | Separate capacity traces exercise the range and page-table limits. Each ioctl has a positive case |
| 362 | and bad-size negative; unknown-command and double-init are negative. Two compiling, terminating |
| 363 | behavior mutants per new unit must produce byte differences. A flipped-output control must be |
| 364 | rejected by the checker. The receipt is `tests/uvms-host-receipt.txt`. |
| 365 | |
| 366 | Derived sizing constants are recorded with their calculator source: |
| 367 | WolframLanguageEvaluator `{16*32,16*40,2^30,2^31,2^32-1,2^20-1,FromDigits["30000001",16], |
| 368 | BitOr[1,BitShiftLeft[2,1]],64*8*8}` -> `{512,640,1073741824,2147483648,4294967295,1048575, |
| 369 | 805306369,5,4096}`; and |
| 370 | `{BitAnd[2^32-1,BitNot[2^12-1]],2^31+16*4096,2^64-3,2^16-1,64*8,128*3,16*6,256*36+48}` |
| 371 | -> `{4294963200,2147549184,18446744073709551613,65535,512,384,96,9264}`. |
| 372 | The independent cc result, not the final arithmetic expression, is authoritative for ioctl sizes. |
| 373 | |
| 374 | Chip runbook verdict: **NOT_RUN**. No window is authorized. Before a later run, the operator must |
| 375 | authorize an exclusive window, a real kernel/instance install path, ownership of an isolated test |
| 376 | VA space and a physical invalidate/replay adapter with completion and CPU/GPU coherence proof. |
| 377 | The run would: |
| 378 | |
| 379 | 1. Capture raw live NVC369 entries and GET/PUT/valid/overflow state without racing producer ownership. |
| 380 | Compare every decoded field and consumed index against the same immutable bytes in this decoder. |
| 381 | 2. Induce a missing 4K mapping, install the expected same-PA PTE and issue the real invalidate. |
| 382 | Compare pre-invalidate stale translation versus post-completion translation and read/write |
| 383 | permissions. A deliberately omitted invalidate is a negative control, not a successful run. |
| 384 | 3. Compare actual replay/cancel outcomes with the model, including a read-duplicate to write upgrade, |
| 385 | CPU/GPU visibility after coherence completion, and NVC365 threshold notifications. Verify backing |
| 386 | contents/PA are unchanged by modeled migration. |
| 387 | 4. Retain raw packet bytes, old/new PTEs, invalidate/replay completion evidence and negative-control |
| 388 | results. A submitted or ACKed model record alone cannot pass this tier. |
| 389 | |
| 390 | There is intentionally no command that opens a device or takes the GPU lock in this runbook. |
| 391 | Linux kernel replacement, interrupt handling, hardware queue/cache effects, process isolation and |
| 392 | GB10 qualification remain external integration/authorization gates; host parity does not satisfy them. |
| 393 | |
| 394 | ## 7. Per-open CUSE endpoint (stacked on the UVM service) |
| 395 | |
| 396 | `uvm/endpoint.om` is the Linux-process transport, not a kernel module. All production |
| 397 | transport and dispatch code is seeded Omega: no libfuse, C daemon, Python server, |
| 398 | or arbitrary ioctl/syscall shim is adopted. Linux CUSE remains an explicit host |
| 399 | dependency. `tests/uvme_offsets.c` and `tests/uvme_kernel.c` are verification oracles |
| 400 | and consumers only, never linked into the endpoint. |
| 401 | |
| 402 | The stack is #10 (`4917e4e2`) → #12 (`e7aa07f34f5156b0ae129378f4aa46df6be11375`) |
| 403 | → `feat/uvm-endpoint`. The service's frozen compiler and receipts remain unchanged. |
| 404 | The endpoint additionally requires the first-party `eventfd` host word from draft |
| 405 | omega-mv#1045, source `78122a72a7bb7129271088b30093e8b3b9b52f8d`, compiler SHA256 |
| 406 | `734bf4f3f858d56288902700cf581cdbaa4a24d1b3254a2beea014aaccf0fa38`. |
| 407 | Its only new effect is host eventfd creation; no `vfioirq`, VFIO registration, |
| 408 | MMIO, NVIDIA device, GPU lock or physical queue operation is called. The model |
| 409 | queue remains pinned to #11 as described in section 6. |
| 410 | |
| 411 | ### Namespace and authority |
| 412 | |
| 413 | Each independent OPEN forks a pristine worker. The parent never calls `sidispatch` |
| 414 | or `siobject`, so initialization, GPU/VA-space identities, range groups, ranges, |
| 415 | PTEs, residency and command/fault queues are private process state. There are at |
| 416 | most eight live opens. A monotonic, connection-local `fh` routes requests; released |
| 417 | handles are revoked before teardown and never reused. Unknown/stale handles |
| 418 | return `-EBADF`, worker failure returns `-EIO` and revokes only that worker. |
| 419 | |
| 420 | The isolation unit is the **open file description**, not the header PID. Threads |
| 421 | can issue ioctls on the same fd; Linux may send RELEASE without caller credentials. |
| 422 | `dup`, fork inheritance or intentional fd transfer shares that namespace. A second |
| 423 | open, even with identical UUID, RM handle and VA, cannot access the first open's |
| 424 | state. The kernel owns the `fh` mapping; users cannot choose it through ioctl |
| 425 | payloads. A deliberately forged fake-kernel packet is not an authenticated client. |
| 426 | This follows the protocol review's decisive constraint: “use live fh as namespace |
| 427 | capability; do not treat header PID as process ownership.” |
| 428 | |
| 429 | Before fork, Omega makes a private Unix stream pair using a random abstract |
| 430 | listener and verifies the accepted peer's kernel PID equals the creating process. |
| 431 | The listener is then closed. Children close the CUSE/fake-kernel channel and every |
| 432 | sibling endpoint. The private channel carries three LE u64 words `(cmd, size, |
| 433 | request-unique)` followed by argument bytes; its response is `(local-UV-status, |
| 434 | size, same-unique)` plus output bytes. Stream operations accumulate partial I/O, |
| 435 | use a bounded in-flight deadline, and never retry an uncertain dispatched request. |
| 436 | `send` supplies `MSG_NOSIGNAL`: a dead worker must not SIGPIPE-kill other clients. |
| 437 | Idle opens have no timeout. RELEASE closes the private channel, terminates and |
| 438 | reaps the exact worker; connection EOF does the same for all remaining workers. |
| 439 | A session is explicitly bounded to 999,999 CUSE records, then drains and exits. |
| 440 | There is no automatic reconnect, retry or state restoration. |
| 441 | |
| 442 | `--fake` uses inherited SOCK_SEQPACKET fd 0/1 and explicitly installs a test |
| 443 | backing capability **inside each child after fork**. It is not a client import |
| 444 | command. `--cuse` opens only `/dev/cuse` and installs no backing capability. |
| 445 | Consequently production MAP_EXTERNAL_ALLOCATION must refuse until a trusted |
| 446 | per-client RM object resolver supplies ownership and bounds. Registering a UUID |
| 447 | or passing a numeric RM handle does not supply physical-memory authority. |
| 448 | Worker/process isolation here is not physical-memory or hardware teardown proof. |
| 449 | |
| 450 | ### CUSE wire contract |
| 451 | |
| 452 | The ABI is measured by host `cc sizeof/offsetof`, not inferred from struct packing: |
| 453 | `linux/fuse.h:745-775` (open/release/flush), `879-898` (CUSE init), `914-975` |
| 454 | (ioctl, iovecs, headers), from `/usr/include/linux/fuse.h`, SHA256 |
| 455 | `e51bdccbf4bc43b60353eb367a3aa4d25b31cafb23b06d3bd7ebb2e5bde8c75d`. |
| 456 | The Linux v6.19 reference implementation's `fs/fuse/cuse.c:cuse_send_init`, |
| 457 | `cuse_process_init_reply`, `cuse_open` and `cuse_file_ioctl` were read to check the |
| 458 | negotiation. This is a reference pin, not a claim about the running kernel. |
| 459 | |
| 460 | The endpoint negotiates major 7, minor 16–39, and CUSE_UNRESTRICTED_IOCTL, rejects |
| 461 | extensions/compat/32-bit/X32/unknown flags, and advertises only the isolated node |
| 462 | `omega-uvm-test`. A request must have an exact whole-record length and nonzero |
| 463 | unique. Each of the eight UVM commands uses the exact whitelist size in section 6, |
| 464 | never `_IOC_SIZE`. An initial IOCTL requests one input and one output iovec for |
| 465 | the kernel-owned user pointer. The retry reply sets FUSE_IOCTL_RETRY; the next |
| 466 | request retains only FUSE_IOCTL_UNRESTRICTED and may have a different unique. |
| 467 | Copied input/output sizes and the full frame length must exactly match the |
| 468 | whitelist. Null, wrapping and out-of-contract user pointer ranges refuse without |
| 469 | dereferencing them; actual access checking and copyin/copyout belong to Linux. |
| 470 | Abandoned copyin retries hold no global pending state. There is no rollback or |
| 471 | automatic replay after a possible copyout fault. |
| 472 | |
| 473 | Semantic UVM refusal is returned in the argument's `rmStatus` with outer ioctl |
| 474 | result zero, preserving every output byte from `sidispatch`. Transport/protocol |
| 475 | errors use negative errno in the FUSE header. Kernel copy failures, caller memory |
| 476 | permissions, node ownership and real Linux ioctl dispatch are not established by |
| 477 | the fake-kernel gate. |
| 478 | |
| 479 | ### Typed fault notification |
| 480 | |
| 481 | `uvm/notify.om` defines nominal `unirq`, constructor `unirqmk`, `unpost`, `unpump` |
| 482 | and `unclose`. A worker owns one eventfd. `unpost(cap)` first admits `uvpkt` into |
| 483 | the existing bounded ring and only then publishes a wake; rejected full-ring |
| 484 | entries do not generate wakes. `unpump` drains the coalesced eight-byte count and |
| 485 | calls `fbbatch`, preserving its dedup/overflow/GET policy. Closed tokens refuse |
| 486 | and cannot be reopened as a new generation. Composition lifts the nominal type |
| 487 | declaration before the first function, as required by OM-2. |
| 488 | |
| 489 | This is an explicitly **MODEL** fault-buffer wake binding. It does not attach a |
| 490 | VFIO IRQ, capture a live DMA buffer, execute an invalidate/replay command or prove |
| 491 | MMU completion. `unpump` may be called by a future owned snapshot producer; no |
| 492 | public ioctl can inject a fault or mint the nominal token. The service emits the |
| 493 | same #11 typed-model queue records; notification is never their completion ACK. |
| 494 | |
| 495 | ### Host acceptance and remaining kernel hop |
| 496 | |
| 497 | Run, without opening any device: |
| 498 | |
| 499 | ``` |
| 500 | taskset -c 10-14 nice -n 10 python3 -u tests/uvme_check.py --mutants \ |
| 501 | --emit-dir /tmp/omega-uvm-endpoint |
| 502 | ``` |
| 503 | |
| 504 | The independent fake kernel exchanges whole CUSE packets with the real Omega ELF. |
| 505 | Two client processes concurrently open independent descriptions and issue all |
| 506 | eight commands. The interval/dictionary service oracle checks every ioctl output |
| 507 | byte. Tests use identical UUIDs/handles/VAs, peer-VA removal refusals, one client's |
| 508 | free while the other's mapping remains busy, independent group IDs, double init, |
| 509 | all bad sizes/flags/commands, stale handles, credential-free RELEASE, abandoned |
| 510 | copyin, worker death, fd inheritance, capacity, reaping and connection EOF. |
| 511 | The eventfd fixture exercises real host wake/coalescing, empty readiness, overflow, |
| 512 | dedup and closed-token refusal without VFIO. Compiling behavior mutants cover |
| 513 | each new Omega unit; an output-byte corruption uses the same live comparator. |
| 514 | The real ioctl consumer is compiled, not executed. Receipt: |
| 515 | `tests/uvme-host-receipt.txt`. |
| 516 | |
| 517 | Observed host result: **PASS**, 192 fake-CUSE records and 53,919 reply bytes, |
| 518 | two concurrent actual client processes, typed eventfd through PTE plus model |
| 519 | invalidate/replay consumption, output-corruption control rejected, and all seven |
| 520 | new-unit mutants killed. The C kernel consumer built with warnings as errors; |
| 521 | its execution remains NOT_RUN. `tests/uvme-regression-receipt.txt` records the |
| 522 | unchanged service's 10,000-operation fixed-seed range fuzz and ten mutants, |
| 523 | the 503-line independent PTE walk and five original page-table/fault mutants; |
| 524 | all commands returned zero. These are host results only. |
| 525 | |
| 526 | **Real CUSE kernel hop: NOT_RUN.** `/dev/cuse` is absent on this host; no node was |
| 527 | created and no module/permission was changed. After the operator explicitly |
| 528 | authorizes and prepares an isolated CUSE node, the runbook is: |
| 529 | |
| 530 | 1. Run the host gate above, retaining its binaries. Inspect the pin and hashes. |
| 531 | 2. Under that separate authority, launch the retained `endpoint --cuse` on the |
| 532 | allowed CPU cores. It requests only `/dev/omega-uvm-test`, never the NVIDIA node. |
| 533 | Confirm node identity and access rights before allowing test consumers. |
| 534 | 3. Run retained `kernel-client /dev/omega-uvm-test` on cores 10–14. It forks two |
| 535 | actual ioctl callers, covers all eight transports, independent initialization |
| 536 | and group IDs, unknown-command refusal and null-pointer EFAULT. MAP and FREE |
| 537 | intentionally refuse in this tier because no trusted real backing was imported. |
| 538 | 4. Compare the real replies with the fake-kernel byte oracle, exercise invalid |
| 539 | nonnull user mappings/copyout failures, and capture kernel/daemon exit status, |
| 540 | exact argument bytes and reaping. Stopping the explicitly owned daemon removes |
| 541 | only this test node. Do not restart/replay uncertain requests. |
| 542 | |
| 543 | **Chip: NOT_RUN.** The live NVC369 versus decoder and before/after TLB-effect |
| 544 | comparisons in section 6 remain required. Physical IRQ snapshot ownership, |
| 545 | trusted RM backing resolution, mapped page-table installation, real invalidate/ |
| 546 | replay completion, CPU/GPU visibility and hardware-safe client teardown remain |
| 547 | separate gates. This endpoint does not close the ROADMAP nvidia-uvm.ko replacement |
| 548 | row or claim deployment. |
| 549 | |
| 550 | Sizing record: WolframLanguageEvaluator |
| 551 | `{40+32+9264,16+16+9264,16+72+StringLength["DEVNAME=omega-uvm-test"]+1,8*5,2^48, |
| 552 | 2^32-22,2^32-9,2^32-5,2^32-38,2^32-71,1073741824+8*268435456}` |
| 553 | → `{9336,9296,111,40,281474976710656,4294967274,4294967287,4294967291, |
| 554 | 4294967258,4294967225,3221225472}`. Host-cc measurement remains authoritative |
| 555 | for struct sizes and offsets. |
| 556 | |
| 557 | The fake backing fixture starts above `UVBASE` rather than crossing the page-table |
| 558 | pool on the fourth open. It is installed after fork and is never a client-supplied |
| 559 | physical import. WolframLanguageEvaluator |
| 560 | `{2^19+1,2^19+2,2^32+1000000*2^28+2^28<2^52,5.1*10^9>5000000000}` |
| 561 | → `{524289,524290,True,True}` verifies the host open flags, the bounded fixture's |
| 562 | PA ceiling and the idle test exceeding the in-flight deadline. |
| 563 | |
| 564 | The worker-death negative control waits on that exact worker's pidfd before |
| 565 | sending another request. Its descriptors must already be closed, with SIGPIPE |
| 566 | default and unblocked in the endpoint. This follows the review finding that an |
| 567 | “immediate post-kill request” may write before the worker has exited. The |
| 568 | write-instead-of-send mutant must specifically terminate with SIGPIPE (`rc=-13`); |
| 569 | an unrelated setup failure is not accepted as this mutant's kill. The baseline |
| 570 | must survive and continue servicing the other open. The eventfd fixture also |
| 571 | asserts the mapped PTE and consumes invalidate then replay from the model queue; |
| 572 | this is still not physical completion. |
| 573 | |
| 574 | |
| 575 | ## 8. RM escape endpoint and explicit HOST_MODEL serving (stacked on #14) |
| 576 | |
| 577 | **IMPLEMENTED / EXERCISED in the host model. QUALIFIED: NOT_RUN. MERGED: no. DEPLOYED: no.** |
| 578 | The implementation is `rm/ioctl.om`, `rm/handles.om`, `rm/memory.om`, |
| 579 | `rm/model.om`, `rm/uvmclient.om`, `rm/import.om`, `rm/dispatch.om` and |
| 580 | `rm/endpoint.om`. No C, Python, vendor binary or foreign runtime is in the |
| 581 | endpoint execution path. Python and C below are independent test/fake-kernel |
| 582 | oracles, compiled or executed only inside a device-hiding `bwrap`. |
| 583 | |
| 584 | ### Sources and ABI |
| 585 | |
| 586 | The client source is CUDApp #293, `origin/feat/c4-streams-submit` |
| 587 | `16f11c47fa9587349b607d5ed174113b6fc9b504`: `nvrm/nvrm.c` and |
| 588 | `native/nvrm/transport.om`. The independent layout source is NVIDIA |
| 589 | open-gpu-kernel-modules 580.173.02 at |
| 590 | `20e4e6e19cc26ba47b5cbe23130a396be100c427`: `nvos.h`, `nv-ioctl.h`, |
| 591 | `nv-ioctl-numbers.h`, `nv_escape.h`, and |
| 592 | `nv-unix-nvos-params-wrappers.h`. `tests/rme_offsets.c` compiles those headers; |
| 593 | it measures sizeof, pointer/size/status offsets, escape numbers and NV statuses. |
| 594 | In particular, NVOS32 status is at **20**, not 16; the cc oracle caught that |
| 595 | initial implementation error before the passing receipt. |
| 596 | |
| 597 | | Escape | Number | Exact outer size | NV status offset | |
| 598 | |---|---:|---:|---:| |
| 599 | | RM_ALLOC (NVOS21) | 43 | 32 | 28 | |
| 600 | | RM_CONTROL (NVOS54) | 42 | 32 | 28 | |
| 601 | | RM_FREE (NVOS00) | 41 | 16 | 12 | |
| 602 | | RM_MAP_MEMORY (NVOS33 with fd) | 78 | 56 | 40 | |
| 603 | | RM_UNMAP_MEMORY (NVOS34) | 79 | 32 | 24 | |
| 604 | | RM_MAP_MEMORY_DMA (NVOS46) | 87 | 64 | 56 | |
| 605 | | RM_UNMAP_MEMORY_DMA (NVOS47) | 88 | 48 | 40 | |
| 606 | | RM_VID_HEAP_CONTROL (NVOS32) | 74 | 184 | 20 | |
| 607 | | CARD_INFO (64 entries) | 200 | 4608 | errno refusal | |
| 608 | | REGISTER_FD | 201 | 4 | errno refusal | |
| 609 | | ALLOC_OS_EVENT / FREE_OS_EVENT | 206 / 207 | 16 | 12 | |
| 610 | | CHECK_VERSION_STR | 210 | 72 | errno refusal | |
| 611 | |
| 612 | Both NVIDIA control/device files use the same `_IOC(READ|WRITE,'F',nr,size)` |
| 613 | encoding. This candidate exposes only the separate `omega-rm-test` CUSE test |
| 614 | node, not either NVIDIA device name. Any other type, direction, number, outer |
| 615 | size or oversized parameter payload returns `-EINVAL`. No xfer command |
| 616 | indirection is admitted. ALLOC/CONTROL accept at most 4096 pointed bytes, gathered |
| 617 | by a second FUSE_IOCTL_RETRY containing precisely the outer and pointed input/ |
| 618 | output iovecs. Noncanonical/null required pointers return `-EFAULT`; the daemon |
| 619 | never dereferences a caller address. Zero-sized parameters require a null pointer. |
| 620 | Unexpected flags, inconsistent frame/input/output lengths and reused closed fh |
| 621 | tokens are refused before dispatch. |
| 622 | |
| 623 | ### Namespace and model routing |
| 624 | |
| 625 | Every independent OPEN gets a forked worker and fresh namespace. At most eight |
| 626 | descriptions are live. Each fh is an unpredictable, nonzero positive int token, |
| 627 | issued from `random`, checked against every token previously issued in the bounded |
| 628 | session (at most 1000), and never reused. REGISTER_FD consumes a valid live token, |
| 629 | not an arbitrary host integer fd. It imports only into an unused destination; |
| 630 | used/reserved destinations, self-import, forged and closed tokens refuse. |
| 631 | Imported descriptions share the source worker, namespace, allocator and mappings. |
| 632 | Closing one alias revokes only its token; the last alias closes/kills/reaps that |
| 633 | exact owned worker. Independent workers own stderr plus their private channel |
| 634 | only. EOF drains them. In-flight I/O has a deadline; idle workers do not expire. |
| 635 | The fake kernel translates process-local fds to endpoint-issued tokens exactly |
| 636 | where the kernel-facing import ABI expects one. This is not a production fd broker. |
| 637 | |
| 638 | Each worker has a caller-owned 4096-word state array, no new globals. It consumes |
| 639 | at most 64 object slots monotonically. Each record holds liveness, handle, client, |
| 640 | parent and class; tombstones deliberately refuse numerical handle reuse until |
| 641 | close, even after free. Root-client handles are generated by the server. |
| 642 | Device objects require a root parent, subdevice/VAS/TSG require device, |
| 643 | context-share/GPFIFO require TSG, and compute requires GPFIFO. Namespace lookup |
| 644 | includes the client. Context-share VAS and GPFIFO context-share references also |
| 645 | require the same owning device/TSG, respectively. Nonzero FIFO memory references |
| 646 | are refused until real backing import exists. Free checks the exact direct |
| 647 | parent and removes the full descendant closure; double free and stale use fail. |
| 648 | Capacity counts consumed slots, not only live objects. |
| 649 | |
| 650 | Supported model allocations include ROOT_CLIENT (65), DEVICE_0 (128), |
| 651 | SUBDEVICE_0 (8320), FERMI_VASPACE_A (37105), CHANNEL_GROUP_A (41068), |
| 652 | CONTEXT_SHARE_A (36967), BLACKWELL_CHANNEL_GPFIFO_A (51567), |
| 653 | BLACKWELL_COMPUTE_B (52928), MEMORY_SYSTEM (62), MEMORY_LOCAL_USER (64), |
| 654 | MEMORY_VIRTUAL (112), and USERMODE_A/B (50017/50785), at exact parameter sizes. |
| 655 | Supported model controls are GPFIFO_SCHEDULE (`0xa06c0101`, three bytes) and |
| 656 | GET_WORK_SUBMIT_TOKEN (`0xc36f0108`, four bytes), on their correct object classes. |
| 657 | The token is explicitly the model's channel-handle token, not a physical doorbell. |
| 658 | |
| 659 | ALLOC/CONTROL use the `chan/params.om` parameter image (`pabuf`/`palen`); |
| 660 | ROOT_CLIENT and scheduling use its existing encoders. Other accepted records |
| 661 | are copied verbatim after exact-class-size checks, matching the existing GSP |
| 662 | RM payload contract. `gsp/rpc.om` builds the real framed RM_ALLOC (103), |
| 663 | RM_CONTROL (76), or RM_FREE (10) request into its explicitly linked **host-memory |
| 664 | peer**. No physical queue or boot state is imported. The model returns its own |
| 665 | policy result; publication is **not** a GSP reply or firmware completion. |
| 666 | Handle changes commit only after successful model routing. The separate |
| 667 | `tests/rme_trace.om` observes the exact root-client RPC payload and injects a |
| 668 | model allocation refusal to prove that no handle/slot is published on failure. |
| 669 | |
| 670 | Local invalid-argument/stale-handle/wrong-parent/duplicate/capacity/unsupported |
| 671 | categories map to vendor NV statuses 31/51/54/52/81/86, measured from headers. |
| 672 | Malformed transports use negative errno; valid but unserved RM requests carry |
| 673 | NV_ERR_NOT_SUPPORTED at their measured status offset. |
| 674 | |
| 675 | ### Per-call serving and provenance |
| 676 | |
| 677 | The executable requires `--fake --host-model FIXTURE` (or separately authorized |
| 678 | `--cuse --host-model FIXTURE`). Missing explicit mode, wrong fixture length, |
| 679 | missing `HOST_MODEL` provenance or an invalid/corrupt GSP frame refuses startup. |
| 680 | `rm/host-model.fixture` is synthetic, deterministically generated by the **test |
| 681 | oracle** `tests/rms_fixture.py`. It is not a hardware capture. Its PCI identity, |
| 682 | GPU ID 1, UUID `HOST_MODEL_UUID1`, SM version and class list are modeled inputs. |
| 683 | The returned driver identity is `ogd HOST_MODEL/1`, never the NVIDIA version. |
| 684 | |
| 685 | Vendor routes below are from OGKM 580.173.02 at the source pin above. Local vendor |
| 686 | calls must not be assigned invented RPC IDs. Public GR_GET_INFO reads a static |
| 687 | cache: `kernel_graphics.c:1227-1247` obtains |
| 688 | `INTERNAL_STATIC_KGR_GET_INFO` (`0x20800a2a`) through **GSP_RM_CONTROL (76)**; |
| 689 | `kernel_graphics.c:2782-2834` serves public indices from that cache. |
| 690 | `ctrl2080internal.h:408-426` defines its 8-engine, 58-record response; |
| 691 | `generated/g_rpc-structures.h:1506-1518` defines the 40-byte control envelope. |
| 692 | `rpc.c:10870` is the vendor serializer. `rmfxrpc` publishes that actual RPC |
| 693 | through `gsp/rpc.om`, then validates the fixture's full queue reply: queue/RPC |
| 694 | sequence, signature, version, aligned checksum, RPC function/result, command and |
| 695 | body size. Only the decoded modeled SM record reaches the client. |
| 696 | |
| 697 | | Call | Verdict | Derivation / limit | |
| 698 | |---|---|---| |
| 699 | | CARD_INFO | SERVED_HOST_MODEL | Fixture card; vendor `kernel-open/nvidia/nv.c:2523` reads local inventory, no per-call RPC | |
| 700 | | ROOT GET_ID_INFO_V2 | SERVED_HOST_MODEL | Fixture; `gpu_mgr/gpu_mgr.c:2527` local manager data, no RPC | |
| 701 | | DEVICE GET_CLASSLIST | SERVED_HOST_MODEL | Fixture count and third-iovec list; `gpu/device_ctrl.c:56` local class table, no RPC | |
| 702 | | SUBDEVICE GR_GET_INFO | SERVED_HOST_MODEL | One SM_VERSION record, decoded from the modeled static GSP control response above; unsupported indices refuse | |
| 703 | | SUBDEVICE GET_GID_INFO | SERVED_HOST_MODEL | Fixture binary UUID; `gpu/gpu.c:5036` uses cached UUID, no per-call RPC | |
| 704 | | MEMORY_SYSTEM / LOCAL_USER / USERMODE | SERVED_HOST_MODEL | Bounded first-fit 1024-page pool; owner and parent checks; USERMODE reserves 64 KiB, never a real doorbell | |
| 705 | | MEMORY_VIRTUAL | SERVED_HOST_MODEL | Logical mapping namespace only, no physical pages | |
| 706 | | CPU MAP / UNMAP | SERVED_HOST_MODEL | Memory bounds, page alignment, overlap checks, exact remove, live map-fd capability | |
| 707 | | DMA MAP / UNMAP | SERVED_HOST_MODEL | Same bounds plus owning virtual-memory object; no IOMMU or device effects | |
| 708 | | VID_HEAP_CONTROL | SERVED_HOST_MODEL | INFO only, shared 4 MiB modeled pool accounting; other functions refuse | |
| 709 | | REGISTER_FD | SERVED_HOST_MODEL | Endpoint-issued live token imports shared namespace; stale/forged/busy/self import refused | |
| 710 | | CHECK_VERSION_STR | SERVED_HOST_MODEL | Explicit ogd identity, no NVIDIA module compatibility claim | |
| 711 | | ALLOC_OS_EVENT / FREE_OS_EVENT | REFUSED | NV_ERR_NOT_SUPPORTED; no IRQ/event subscription | |
| 712 | | Client UVM init/register/range/map/free/unregister | SERVED_HOST_MODEL | Bounded per-namespace range adapter, fixture UUID, imported RM capability, matching modeled DMA map; MM_INITIALIZE refused as tolerated by the unmodified client | |
| 713 | | Physical backing, mmap through a real device, page pinning, doorbells, real CUSE/RM/GSP, VFIO and chip | NOT_RUN | No authorization, no device access; no hardware truth inferred | |
| 714 | |
| 715 | `rm/memory.om` records size, contiguous page ownership and handle-plus-map |
| 716 | refcounts, with 64 bounded mapping records. Cascading free first removes maps |
| 717 | whose object/virtual namespace died, decrements refs, then releases every owned |
| 718 | page. Partial/duplicate unmap, out-of-bounds and overlapping maps refuse. |
| 719 | `rm/uvmclient.om` reuses `uvm/range.om`'s half-open bounded interval convention; |
| 720 | it does not publish real UVM PTEs. The fake CUSE kernel uses anonymous CPU memory |
| 721 | for the unmodified client's CPU reads/writes; it is **test transport**, not a |
| 722 | first-party implementation of real RM backing. |
| 723 | |
| 724 | ### Host acceptance and NOT_RUN runbook |
| 725 | |
| 726 | Run the device-hiding command in README. `tests/rme_check.py --mutants` exercises |
| 727 | the cc layout oracle, dictionary/tree differential, deliberate red comparison, |
| 728 | randomized and capacity/stale/cascade cases, exact command/size/flag/address |
| 729 | refusals, isolated opens, closed fh tokens, descriptor inheritance, dead-worker |
| 730 | survival, model RPC publication and rollback. It compiles and **runs** |
| 731 | `tests/rme_consumer.c`, using vendor C structs and the CUDApp structural |
| 732 | root/device/subdevice/VAS/TSG/context/GPFIFO/compute/control/free ordering. |
| 733 | It uses no FIFO/notifier backing and performs no GPU launch. Ten compiling |
| 734 | behavior mutants cover stale handle, wrong parent, size off-by-one, cascade |
| 735 | skip, status mapping, cross-client lookup, unknown escape, double free, |
| 736 | oversized payload and control-object class. Shared params/RPC/channel host |
| 737 | gates remain separate, with their original compiler and reference pins. |
| 738 | |
| 739 | `tests/rms_check.py --mutants --client /tmp/ogd-cudapp-client` adds the independent |
| 740 | page/mapping Python differential, an intentionally wrong expected result, |
| 741 | provenance/checksum/missing-mode controls, local/usermode CPU map/unmap and ten |
| 742 | compiling killed mutants: ownership, overlap, range limit, stale handle, |
| 743 | double free, cascading page reclamation, token forgery, cross-client lookup, |
| 744 | partial unmap and UVM collection. An RM backing or VAS free invalidates dependent |
| 745 | UVM ranges; the gate proves address reuse and rejects creation through a freed |
| 746 | VAS. Its C test kernel includes `nvrm.c` from a detached, unmodified |
| 747 | checkout at the CUDApp pin above, with the client's checked Omega policy enabled. |
| 748 | Only OS transport is interposed (`CUDAPP_NVRM_TEST_TRANSPORT=1`); the client runs |
| 749 | open, alloc, control, CPU/DMA/UVM map, byte roundtrip, free and close. No compute |
| 750 | submission or doorbell is exercised. The new receipt is `tests/rms-host-receipt.txt`; |
| 751 | the older `rme-*-receipt.txt` files remain immutable historical evidence. |
| 752 | |
| 753 | **Real CUSE kernel hop, live RM, VFIO and chip: NOT_RUN.** No `/dev/cuse`, |
| 754 | `/dev/nvidia*` or `/dev/vfio` was opened and no node/module/service was changed. |
| 755 | Future operator procedure, requiring fresh explicit authority: |
| 756 | |
| 757 | 1. Reproduce all boxed host gates on the exact candidate and retain source, |
| 758 | compiler and binary hashes. Keep the live model, watchdog and GPU lock untouched. |
| 759 | 2. In an isolated authorized host environment, provision CUSE independently. |
| 760 | Review `--cuse` node identity (`omega-rm-test` only), CPU affinity and access |
| 761 | permissions before registration. Never redirect existing NVIDIA device names. |
| 762 | 3. Exercise actual kernel ioctl copyin/copyout, nested-pointer retry faults, |
| 763 | independent/duplicated descriptors, release and exact-worker death using a |
| 764 | dedicated authorized kernel consumer. The existing C consumer is explicitly |
| 765 | a fake kernel and is not proof of that hop. |
| 766 | 4. Before any chip test, implement and review authenticated inventory/fd/backing |
| 767 | import, GSP boot/readiness/correlated replies, UVM association and completion/ |
| 768 | teardown ownership. Run the boxed gates and their red controls again. |
| 769 | 5. Only in a separately authorized exclusive GPU window, follow `window/README.md` |
| 770 | for the exact device and rollback plan, then collect the live RM traces, |
| 771 | mapping visibility, channel scheduling, completion and teardown negative |
| 772 | controls. Do not infer permission to stop a service or unbind a module from |
| 773 | this document. Host success is not chip qualification or deployment. |
| 774 | |
| 775 | Sizing record: WolframLanguageEvaluator |
| 776 | `{64*5,40+32+32+4096,16+16+32+4096,16+72+StringLength["DEVNAME=omega-rm-test"]+1, |
| 777 | BitOr[BitShiftLeft[3,30],BitShiftLeft[4608,16],BitShiftLeft[70,8],200],2^32-95}` |
| 778 | → `{320,4200,4160,110,3523233480,4294967201}`. Vendor cc measurements, not |
| 779 | these transport calculations, determine the ABI layouts. |
| 780 |