omega-mv
Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.
Brought by drakestapleton
omega-mv / seed / host / MAPPING.md
| 1 | # Native mapped memory and checked device calls |
| 2 | |
| 3 | This extends the existing native-host compiler. It supports the strict Omega |
| 4 | 27B experiment's memory prerequisite. It does not yet implement a GPU launcher, |
| 5 | model execution, complete state rollback or a hardware performance comparison. |
| 6 | The seed compiler and added tests are handwritten Omega. The existing shell |
| 7 | bootstrap and test orchestration remain disclosed development tools. |
| 8 | |
| 9 | | Expression | Result and contract | |
| 10 | | --- | --- | |
| 11 | | `devctl fd request A off n` | Signed Linux ioctl result. `fd` is int; `request` is a literal uint; `A` is writable bytes; offsets/counts are ulong. Exact encoded size, checked range. Accepts FIONREAD, the existing encoded read/write NVRM F requests, or the five exact aien-gpu ABI1 A requests below. | |
| 12 | | `mapnew fd offset bytes access mode` | Positive long handle or negative Linux errno. fd is int, offset/bytes ulong, access/mode literal ints. Access 1 means read, 3 read/write. Modes 1/2 mean shared/private file; 33/34 shared/private anonymous. Anonymous mappings require fd -1 and offset zero. | |
| 13 | | `mapdrop handle` | Unmap the entire owned mapping. Zero on success or negative errno. Retires the slot on success; the next mapping gets a different generation. | |
| 14 | | `mapread handle offset A off n` | Copy n bytes from the mapping into writable byte array A. Return n as long. | |
| 15 | | `mapwrite handle offset A off n` | Copy n bytes from byte array A into a writable mapping. Return n as long. Read-only source views/text are accepted. | |
| 16 | | `devcall fd request H hoff 32 P poff n` | RM_ALLOC or RM_CONTROL only. Binds a checked writable parameter span in a private header, sets its length, and copies back non-pointer fields. Caller pointer bytes must be zero; header and parameter spans must not overlap. Parameter length is at most 1048576 bytes (1 MiB); larger lengths trap 3 (exit 103). | |
| 17 | | `uvmctl fd command A off n` | Literal Linux UVM request from the explicit ABI580.173.02 allowlist, with its exact writable payload length. | |
| 18 | | `vfioctl fd request A off n` | Literal VFIO request from the allowlist below, with its exact byte count. Signed Linux ioctl result. `fd` is int; `request` a literal uint; `A` uchar bytes. | |
| 19 | | `vfiomap fd A off 32` | Read-only shared mapping of one VFIO region. `A off 32` is the `vfio_region_info` returned by `DEVICE_GET_REGION_INFO`; its flags must contain READ and MMAP, and the compiler maps exactly its size at its offset. Returns a mapping handle or negative errno. `mapset`/`mapwrite` through the handle trap. | |
| 20 | | `vfiomapw fd A off 32` | As `vfiomap`, but the region flags must contain READ, WRITE and MMAP and the mapping is shared read/write, so `mapget`/`mapset` drive device registers (one aligned access each, DSB SY on both sides). | |
| 21 | | `eventfd initial` | `initial` is uint. Creates Linux eventfd2 with CLOEXEC and NONBLOCK, no semaphore mode; returns long fd or negative errno. Use existing `read`/`write` with exactly eight bytes, `waitio`/`pollfds` for readiness, and `fclose` for close. | |
| 22 | | `vfioirq fd request A off n` | `fd` is int acquired by successful `vfioctl GROUP_GET_DEVICE_FD`; request is literal uint15213 (GET_IRQ_INFO) or15214 (SET_IRQS). A is writable uchar bytes, offsets/counts ulong. Checks exact caller-supplied argsz and the bounded IRQ contract below. Returns signed Linux ioctl result. | |
| 23 | | `mapaddr handle` | The owned live mapping's base address as ulong, for driver address serialization. Does not permit access through an arbitrary integer address. Works on reservations. | |
| 24 | | `mapget handle offset width` | Aligned uint32 or uint64 load, returned as ulong; width is literal int4 or8. Exactly one load, bracketed by DSB SY on AArch64 or MFENCE on x86-64. Requires readable memory. | |
| 25 | | `mapset handle offset width value` | Aligned uint32 or uint64 store from ulong, returning long0; width is literal int4 or8. A uint32 store refuses truncation. Exactly one store, bracketed by DSB SY on AArch64 or MFENCE on x86-64. Requires writable memory. | |
| 26 | | `maphold address bytes` | Reserve an unused, page-aligned span with PROT_NONE and MAP_FIXED_NOREPLACE. Address is at least64KiB and the whole span is below1TiB. Return an owned handle or errno. A kernel that ignores NOREPLACE is detected by checking the returned address; an unexpected result is unmapped and returns -95. | |
| 27 | | `mapbind handle fd offset access` | Bind a shared file/device mapping to the entire owned reservation, with literal access1 or3. No existing data mapping may be replaced. Return long0 or errno. Failed bind with successful cleanup retires the handle. Function-mode double failure quarantines it for cleanup only (below). | |
| 28 | | `cpufence` | Statement, keyword 199: a standalone host CPU publication barrier, AArch64 `DSB SY`, x86-64 `MFENCE`. It orders ordinary stores, for example `mapwrite` or plain array stores, before a later `mapset` doorbell or flag. A `mapget`/`mapset` access already carries its own barriers. See OMEGESE ยง10, "Host CPU ordering words". Proof: `seed/host/cpufence.sh`. | |
| 29 | | `cpurelax` | Statement, keyword 200: spin-wait hint for a bounded `mapget` poll loop, AArch64 `YIELD`, x86-64 `PAUSE`. It gives no ordering. Proof: `seed/host/cpufence.sh`. | |
| 30 | |
| 31 | ### Draft aien-gpu ABI1 ioctl admission |
| 32 | |
| 33 | **Trust-surface extension: Drake must approve this contract before merge.** The |
| 34 | shared AArch64/x86-Linux `devctl` allowlist additionally admits exactly: |
| 35 | |
| 36 | | Request | Full Linux number | Direction | Writable payload bytes | |
| 37 | | --- | --- | --- | --- | |
| 38 | | `AGPU_IOCTL_INFO` | `0x80704110` (`2154840336`) | READ | 112 | |
| 39 | | `AGPU_IOCTL_MEM_ALLOC` | `0xc0304121` (`3224387873`) | READ/WRITE | 48 | |
| 40 | | `AGPU_IOCTL_MEM_FREE` | `0xc0184122` (`3222815010`) | READ/WRITE | 24 | |
| 41 | | `AGPU_IOCTL_CHAN_CREATE` | `0xc0484123` (`3225960739`) | READ/WRITE | 72 | |
| 42 | | `AGPU_IOCTL_CHAN_DESTROY` | `0xc0184124` (`3222815012`) | READ/WRITE | 24 | |
| 43 | |
| 44 | Source: `aien-dev/aien-gpu`, the ABI1 UAPI imported in CUDApp at |
| 45 | `third_party/aien-gpu-abi1/aien_gpu_uapi.h`, last changed by |
| 46 | `200015e6011d3c517803968fcccab52554c671be`, file SHA-256 |
| 47 | `1071e2a1338d258a654dc96f8c6d637db0e06fb4c47329cd73dc69fdf443eda7`. |
| 48 | Linux `asm-generic/ioctl.h` defines direction at bit30, type at bit8, |
| 49 | number at bit0 and size at bit16. READ=2 and WRITE=1. The aligned struct |
| 50 | layouts and `_IOC` encoding are recomputed through Wolfram; the exact |
| 51 | queries, results, UAPI pin and refusal matrix are recorded in |
| 52 | `aien-ioctl-matrix.json`. |
| 53 | |
| 54 | Equality is over the **whole request**, not its type/number alone. Nonliteral |
| 55 | requests, changed encoded sizes/directions/types, neighbours, `BOOT`, |
| 56 | `ARENA_READ` and `RM_INIT` remain compiler error9 unless independently admitted |
| 57 | by the unchanged FIONREAD/NVRM boundary. Even an admitted request traps3 when |
| 58 | the writable view count is shorter or longer than its exact encoded size. |
| 59 | An exact-length call reaches ioctl and returns the signed Linux result. |
| 60 | The driver and caller still validate device identity, ABI version, reserved |
| 61 | fields, flags, handles, address values and state. Admission is not a payload |
| 62 | validator or authorization to open a GPU. |
| 63 | |
| 64 | CPU-only qualification is the handwritten Omega `aien-ioctl.om`: five exact |
| 65 | requests, shorter/longer views, thirty encoded refusals and nonliteral |
| 66 | refusals; native AArch64 execution, x86-Linux execution under QEMU, and |
| 67 | AArch64 function-mode admission/refusal. Every executed ioctl uses fd-1, |
| 68 | so no driver or device is opened. Native AArch64 expects EBADF (-9). |
| 69 | QEMU 8.2.2 intercepts these unknown x86 requests before checking fd and |
| 70 | returns ENOTTY (-25); the fixture requires that exact emulated result, |
| 71 | not an EBADF/ENOTTY alternative. Its trace must show the five exact request |
| 72 | numbers, no ioctl on short/long refusal, and an ioctl after the x86 guard |
| 73 | mutant. This qualifies emitted admission and length guards, not x86 kernel |
| 74 | or driver admission. Native x86, hardware and real driver integration are |
| 75 | NOT_RUN. Four compiler mutants widen or narrow the allowlist or remove either |
| 76 | backend's exact-length guard. A mutation counts as killed only at its intended |
| 77 | admission or short-length assertion, never for an unrelated child/compiler failure. |
| 78 | Only the last line is the verdict: `AIEN-IOCTL PASS ...` with exit 0. While a |
| 79 | mutant runs, the case it breaks prints `AIEN-IOCTL expected mutant failure N` |
| 80 | followed by `AIEN-IOCTL mutant killed M`; a FAIL line appears only for the |
| 81 | unmutated compiler. Each mutant is located textually in `seed/omc/omc.om` (the |
| 82 | `mfrom`/`mto` texts); a compiler change that respells or moves an anchor makes |
| 83 | the step exit 92 with `AIEN-IOCTL INVALID mutant anchor ... (mutant not |
| 84 | applied; not a compiler verdict)` naming the mutant and its occurrence count, |
| 85 | before any case runs. Respell the anchor in the same change. An existing scratch |
| 86 | directory (it must not exist) or an unbuildable mutated compiler exits 91, named. |
| 87 | |
| 88 | |
| 89 | ### Function and program mapping contexts |
| 90 | |
| 91 | `cpufence` and `cpurelax` are accepted in every function unit. An OM-2 function unit |
| 92 | (first line `om2`, no `fn main`) may also use `devctl`, `mapnew`, `mapdrop`, `mapread`, |
| 93 | `mapwrite`, `devcall`, `uvmctl`, `mapaddr`, `mapget`, `mapset`, `maphold` and `mapbind`. |
| 94 | These words are supported on AArch64 Linux and `target x86linux`; they remain |
| 95 | error9 in OM-1 function units and other targets (gate |
| 96 | `seed/omc/om2/fnhost/fnhost.cases`). A handle is a long; `mapaddr` exposes only its |
| 97 | owned live address, not general integer-pointer access. |
| 98 | |
| 99 | **Program mode remains unchanged:** its private raw128-slot table uses32-byte |
| 100 | slots (address, length, generation, access) and eight low handle bits for slot+1. |
| 101 | The129th live mapping returns-24 without calling mmap. |
| 102 | |
| 103 | **Function-mode context ABI (draft, Drake approval required before merge):** |
| 104 | entry31 of the caller's runtime table (`LDR` from `[x7,#248]` on AArch64; |
| 105 | `MOV` from `[r14+248]` on x86-64) is a data pointer |
| 106 | to four u64 header words: capacity, generation base, generation limit, zero-reserved; |
| 107 | then capacity32-byte slots. Capacity is1..4098. Handles use13 low bits for slot+1 |
| 108 | and50 generation bits; each slot starts at the caller's generation base and is |
| 109 | incremented only on successful allocation, never beyond the header's limit. |
| 110 | Slot exhaustion returns-24 without mmap. A caller must initialize the table, |
| 111 | keep it alive and serialize accesses. Missing/invalid pointers are not checked |
| 112 | stub calls and can fault; entry31 must really point at this format. |
| 113 | |
| 114 | The bridge gives each explicit context a distinct nonreused24-bit ID and26-bit |
| 115 | per-slot generations: base=`id<<26`, limit=`((id+1)<<26)-1`. This prevents a |
| 116 | foreign-context handle from aliasing a local generation. Default contextID1 has |
| 117 | 128 slots. Explicit contexts admit4098:4096 C NVRM allocation mappings, one |
| 118 | usermode mapping and one transient slot. GPU channel VA bookkeeping uses no |
| 119 | CPU mmap reservation. WolframLanguageEvaluator: |
| 120 | `{4096+1+1,2^13-1,2^26-1,2^24-1,2^50-1,32+4098*32}` |
| 121 | -> `{4098,8191,67108863,16777215,1125899906842623,131168}`. |
| 122 | The last value is the table byte size. Context creation/destruction and read-only |
| 123 | dispatch-table publication are the bridge compatibility ABI, not new Omega words. |
| 124 | The caller quiesces all users/waiters before destruction, which refuses live |
| 125 | slots; it also serializes whole multi-call transactions in a context. |
| 126 | |
| 127 | `mapbind` replaces only the whole live PROT_NONE reservation in this selected |
| 128 | table. Before cleanup, function mode changes access to4 (quarantined): bind, |
| 129 | read and write are refused but `mapaddr` and `mapdrop` retain ownership for |
| 130 | cleanup. If cleanup munmap fails, trap3 leaves that quarantined owner live and |
| 131 | the bridge returns nonzero status with outputs unchanged. Destroy must return36 |
| 132 | until a later `mapdrop` succeeds. If cleanup succeeds, the slot is fully retired |
| 133 | and the original mmap errno is returned normally. Linux may leave a gap after |
| 134 | MAP_FIXED failure: reservation preservation is not promised in either case. |
| 135 | No external munmap/mremap/fixed replacement may interfere with owned ranges. |
| 136 | This format supersedes the unmerged raw128-slot function-mode draft in#1040; |
| 137 | mixing those compiler/runtime formats is unsupported and the bridge rejects a |
| 138 | mapping unit with an incompatible compiler fingerprint. Program-mode tables |
| 139 | and handles are not changed by this context extension. |
| 140 | Mappings are between 1 byte and 64 GiB each. This bounds each extent, not the |
| 141 | total physical memory the OS permits. Closing a file descriptor does not close |
| 142 | its mapping. Close the mapping explicitly before reclaiming its backing object. |
| 143 | |
| 144 | Invalid/stale handles, range overflow, writes through read-only mappings, zero |
| 145 | or oversized extents, inaccessible reservations, misaligned word access and |
| 146 | malformed anonymous arguments trap with exit 103. |
| 147 | An array's normal bounds and mutability checks still apply. Empty copies are |
| 148 | allowed at the exact end of both spans, through a valid handle. Slot generation |
| 149 | never wraps: exhausted generations are retired permanently. File offset alignment |
| 150 | and device mapping permission errors come from Linux. Fixed-address binding is |
| 151 | limited to entire owned reservations. There is no executable map, arbitrary |
| 152 | syscall or access through an arbitrary integer address in this extension. |
| 153 | |
| 154 | These are process-local resource handles, not an authority or sandbox boundary. |
| 155 | Fork inherits independent tables and Linux's ordinary shared/private map behavior; |
| 156 | the new process must manage its copies. A successful file mapping does not verify |
| 157 | the file's contents, prevent truncation, guarantee residency, or suppress Linux |
| 158 | mapping faults. The owner must keep mapped files/device objects valid for the |
| 159 | mapping's full lifetime. The model runner must freeze and verify weight identities. |
| 160 | |
| 161 | Device calls use checked byte spans. `devcall` supplies one scoped parameter |
| 162 | pointer in a private32-byte NVOS21/NVOS54 header. It never copies that pointer |
| 163 | back. This work does not qualify arbitrary device commands. |
| 164 | The parameter cap is the default `RMAPI_PARAM_COPY_MAX_PARAMS_SIZE` in |
| 165 | [`param_copy.h`](https://github.com/NVIDIA/open-gpu-kernel-modules/blob/20e4e6e1/src/nvidia/inc/kernel/rmapi/param_copy.h#L63). |
| 166 | WolframLanguageEvaluator: `2^20` -> `1048576` bytes. |
| 167 | The runtime passes the already checked caller span directly; only the private |
| 168 | 32-byte header is allocated on the stack, independent of parameter length. |
| 169 | Large callers can use image-backed `global` arrays without a stack allocation. |
| 170 | This does not change `devctl`: its payload size remains encoded in the ioctl request. |
| 171 | GPU submission and mapped-device coherency require their separate existing |
| 172 | runtime qualifications. Tests here open ordinary files, anonymous memory and |
| 173 | pipes; compiler host tests do not open a GPU device or alter a running model. |
| 174 | |
| 175 | The UVM allowlist is INITIALIZE805306369/16bytes, MM_INITIALIZE75/8, |
| 176 | REGISTER_GPU37/40, UNREGISTER_GPU38/20, REGISTER_GPU_VASPACE25/32, |
| 177 | UNREGISTER_GPU_VASPACE26/20, REGISTER_CHANNEL27/56, UNREGISTER_CHANNEL28/28, |
| 178 | MAP_EXTERNAL_ALLOCATION33/9264, FREE34/24 and CREATE_EXTERNAL_RANGE73/24. |
| 179 | Only the Linux ABI from the pinned NVIDIA580.173.02 headers is covered. |
| 180 | Independent GCC header-layout and GNU assembler instruction oracles were used |
| 181 | while developing the runtime. They are not linked into the compiler or products. |
| 182 | |
| 183 | The VFIO allowlist (`_IO(';', 100+k)`, Linux `include/uapi/linux/vfio.h`) is |
| 184 | GET_API_VERSION15204/0, CHECK_EXTENSION15205/4, SET_IOMMU15206/4 (value must be |
| 185 | TYPE1v2 = 3), GROUP_GET_STATUS15207/8, GROUP_SET_CONTAINER15208/4, |
| 186 | GROUP_GET_DEVICE_FD15210 (nonempty device name without zero bytes, copied with a |
| 187 | terminator to private stack memory), DEVICE_GET_INFO15211/24, |
| 188 | DEVICE_GET_REGION_INFO15212/32, IOMMU_MAP_DMA15217/32 and IOMMU_UNMAP_DMA15218/24 |
| 189 | (both checked as described under DMA below). DEVICE_RESET15215 is refused: W0 is approved |
| 190 | without a device reset, so Omega code cannot request one. For spans of 8 bytes or |
| 191 | more the compiler writes `argsz = n` before the call, so the kernel copies at most |
| 192 | n bytes back. CHECK_EXTENSION and SET_IOMMU pass the 4-byte value read from the |
| 193 | span. Every other request, a non-literal request, a non-uchar span or library |
| 194 | mode is refused at compile time; a wrong count, a bad SET_IOMMU value or an empty |
| 195 | device name traps 3 at run time. IRQ requests use the separate `vfioirq` word |
| 196 | below; reset and migration remain excluded. Note that closing a vfio-pci device |
| 197 | fd lets Linux reset the function (FLR) or, when every reset method is disabled, |
| 198 | the bus (SBR); the allowlist cannot prevent that kernel behaviour. |
| 199 | |
| 200 | ### Typed IRQ and eventfd extension |
| 201 | |
| 202 | The original profile extended compiler base |
| 203 | `397e67040fb74853c6814097fe02ae4e1ebd6f66` (the historical driver pin). |
| 204 | Current-main integration assigns `vfioctl`228, `vfiomap`229, |
| 205 | `vfiomapw`230, `eventfd`231 and `vfioirq`232, preserving the existing |
| 206 | efi/qty/peername/fma words. It emits AArch64 Linux syscalls directly. |
| 207 | These additions are program-mode only; hosted x86 VFIO and function-mode |
| 208 | VFIO are not implemented. Neither hardware IRQ delivery nor a driver-pin |
| 209 | compatibility claim follows from host qualification. |
| 210 | |
| 211 | `vfioirq GET_IRQ_INFO` requires exactly16 bytes and an argsz field equal to16. |
| 212 | The caller supplies flags/index/count bytes; Linux validates the IRQ index and |
| 213 | reports capabilities. No capability chain beyond the fixed header is admitted. |
| 214 | `SET_IRQS` accepts only these exact forms (all fields are Linux little-endian): |
| 215 | |
| 216 | | flags | count and payload | |
| 217 | | --- | --- | |
| 218 | | DATA_EVENTFD \| ACTION_TRIGGER =36 | count1..64; n =20+4*count, argsz=n. Each signed32 payload fd is a live eventfd created by `eventfd`, or -1 to deassign that vector. | |
| 219 | | DATA_NONE \| ACTION_TRIGGER =33 | count0, start0, argsz=n=20; disables the selected IRQ index. | |
| 220 | | DATA_NONE \| ACTION_MASK =9 or ACTION_UNMASK =17 | count1..64, argsz=n=20; no payload. The driver must first check GET_IRQ_INFO's MASKABLE capability; Linux enforces the device's masking support. The compiler does not invent that capability. | |
| 221 | |
| 222 | For every SET form, start+count must fit uint32. Index selection and actual |
| 223 | device vector bounds remain kernel checks. Other flags, mismatched argsz, |
| 224 | oversized counts and malformed payload sizes trap3 (exit103) before ioctl. |
| 225 | Unlike older `vfioctl` records, `vfioirq` validates argsz rather than overwriting it. |
| 226 | There is no DATA_BOOL, userspace trigger-without-eventfd, arbitrary ioctl or |
| 227 | arbitrary syscall escape hatch. |
| 228 | |
| 229 | A separate private128-slot descriptor-kind table is keyed by the complete int |
| 230 | fd, not indexed by its numeric magnitude. GET_DEVICE_FD and eventfd reserve a |
| 231 | slot *before* their acquisition syscall; table exhaustion returns -24 without |
| 232 | acquiring or closing a resource. Only successful acquisitions get a kind tag. |
| 233 | `fclose` retires its tag before calling Linux, even when close returns an error. |
| 234 | A successful `dupfd` (dup3) retires the destination tag; failed duplication leaves |
| 235 | it unchanged. Duplication does not propagate tags. Helpers compiled before the |
| 236 | first acquisition use the same table. Fork inherits the table; exec creates a |
| 237 | new program table, and new eventfds have CLOEXEC. |
| 238 | |
| 239 | These are current-descriptor kind checks, not generation handles or an isolation |
| 240 | boundary. Kernel fd-number reuse can make a stale integer name a newly acquired |
| 241 | resource. Do not retain stale descriptors. Successful GET_DEVICE_FD is trusted |
| 242 | under Linux's VFIO group-fd contract, not an authentication proof for arbitrary |
| 243 | inherited descriptors or a malicious kernel. A raw/inherited device or eventfd |
| 244 | is not admitted by `vfioirq`. Closing an eventfd does not explicitly deassign |
| 245 | its VFIO IRQ registration: the driver must deassign/disable before closing the |
| 246 | eventfd and device, then observe its normal channel quiescence contract. |
| 247 | |
| 248 | NONBLOCK prevents an empty eventfd read from blocking indefinitely; EAGAIN is |
| 249 | returned unchanged. CLOEXEC prevents incidental eventfd inheritance across exec. |
| 250 | Readiness, eventfd write/read success and the host fixture are not GPU completion |
| 251 | or physical interrupt-delivery evidence. Kernel errors remain signed errno. |
| 252 | |
| 253 | Run `taskset -c 10-14 nice -n 10 sh seed/host/irq.sh` after the seed fixpoint. |
| 254 | The GCC UAPI layout oracle compares C and Omega serialized records byte for byte. |
| 255 | The ptrace fixture executes real ioctls against a memfd (ENOTTY); only the |
| 256 | GROUP_GET_DEVICE_FD return is replaced to exercise the admitted-kind path. |
| 257 | It checks actual syscall arguments and errno, descriptor invalidation, high |
| 258 | numeric fds and capacity before acquisition. It never opens a VFIO/NVIDIA device. |
| 259 | QEMU user-mode checks a VFIO-less refusal and translated eventfd behavior; it |
| 260 | is not system-emulator VFIO delivery or hardware qualification. Compiler mutants |
| 261 | must compile and execute and then be killed by the independent runtime oracle. |
| 262 | Real VFIO IRQ delivery is NOT_RUN until Drake authorizes a hardware window. |
| 263 | |
| 264 | |
| 265 | DMA: IOMMU_MAP_DMA15217/32 (`struct vfio_iommu_type1_dma_map`, vfio.h) never |
| 266 | takes an address from Omega code. The caller writes an Omega mapping handle into |
| 267 | the vaddr field (bytes 8..15) and the IOVA into bytes 16..23. The compiler checks |
| 268 | the handle exactly as `mapget` does (live slot, matching generation), requires a |
| 269 | read/write mapping and flags exactly READ|WRITE (3), then stores the mapping's own |
| 270 | base address into vaddr and its whole length into size before the call; any |
| 271 | failed check traps 3. So only a whole live mapping that the program owns can be |
| 272 | handed to the IOMMU, and the IOVA is the only free choice. IOMMU_UNMAP_DMA15218/24 |
| 273 | requires flags 0 (no dirty bitmap, no ALL, no VADDR). Request numbers are shared by |
| 274 | `_IO(';', 113/114)` with VFIO_DEVICE_PCI_HOT_RESET and VFIO_DEVICE_QUERY_GFX_PLANE on a |
| 275 | device fd: hot reset refuses any non-zero flags with EINVAL (Linux |
| 276 | drivers/vfio/pci/vfio_pci_core.c, `vfio_pci_ioctl_pci_hot_reset`, `hdr.flags` check), |
| 277 | and MAP_DMA always passes flags 3; vfio-pci does not implement QUERY_GFX_PLANE. |
| 278 | Unmapping or dropping an Omega mapping while it is DMA-mapped leaves the pages pinned |
| 279 | by the kernel until the container is closed; the driver must unmap before dropping. |
| 280 | `vfiomap` refuses a size of zero and region flags |
| 281 | without READ|MMAP; it never requests PROT_WRITE. `vfiomapw` additionally requires |
| 282 | WRITE and is the only VFIO word that maps device memory writable. Host tests use an |
| 283 | invalid fd and a memfd stand-in; the device path is exercised only in the QEMU bench |
| 284 | of aien-dev/omega-gpu-driver, not on hardware. |
| 285 | |
| 286 | Kernel constants/layouts are from Linux asm-generic/unistd.h, mman-common.h and |
| 287 | linux/mman.h. AArch64 encodings use seed/rung2/table.s2. The device request rule |
| 288 | comes from the reviewed L605 src/device/omc.om, source 0dee699. Existing host |
| 289 | source is f0499f415571bdd7496b6de391096915e78f7556. These device words are on |
| 290 | main: `hdevctl` is defined in seed/omc/omc.om (verified at main e5b32567). |
| 291 | |
| 292 | ## Hosted x86-64 Linux lowering |
| 293 | |
| 294 | Hosted and program-mode x86 calls share the existing emitter. Mapping uses Linux |
| 295 | `mmap` syscall9 and `munmap` syscall11; `devctl`, `devcall` and `uvmctl` use |
| 296 | `ioctl` syscall16. The argument registers are RDI, RSI, RDX, R10, R8 and R9; |
| 297 | RAX carries the signed result. No libc syscall wrapper is linked. Mapping flags |
| 298 | are unchanged: MAP_SHARED/PRIVATE with the existing anonymous options, |
| 299 | PROT_NONE|MAP_FIXED_NOREPLACE for `maphold`, and MAP_SHARED|MAP_FIXED for |
| 300 | `mapbind`. Copies (`mapread`/`mapwrite`) are byte copies, not ordered MMIO; |
| 301 | `mapaddr` only exports a checked owned address. |
| 302 | |
| 303 | The hosted admission set is the same as AArch64: the mapping/ioctl words above, |
| 304 | `fclose`, `fopen`, `fstat`, `stat`, `lstat`, `getuid`, `geteuid`, `getgid`, |
| 305 | `getegid`, `monons`, `realns` and `sleepns`, plus the existing basic input/output. |
| 306 | There is no new generic syscall or arbitrary-address operation. |
| 307 | |
| 308 | `mapget` and `mapset` each emit exactly one aligned load or store between two |
| 309 | MFENCE instructions. `cpufence` emits MFENCE and `cpurelax` PAUSE. Do not replace |
| 310 | these fences with a compiler barrier based on ordinary write-back TSO: mapped |
| 311 | device memory can be write-combining and weakly ordered. Intel SDM volume2B, |
| 312 | order253667-093US, September2026, **MFENCE**, page4-15, guarantees that preceding |
| 313 | loads and stores become globally visible before later loads or stores, and |
| 314 | explicitly discusses weakly ordered memory types. **SFENCE** orders stores but |
| 315 | not loads; MFENCE is the deliberately conservative common barrier for both |
| 316 | operations. Source: [Intel SDM volume2B](https://cdrdv2.intel.com/v1/dl/getContent/671241). |
| 317 | The compiler emits instructions in order without a host-language optimizer; |
| 318 | there is no separate C compiler-barrier substitution. CPU ordering does not prove |
| 319 | PCIe completion, GPU coherency or hardware suitability. |
| 320 | |
| 321 | The x86 emitter leaves R12 (native nonlocal return anchor), R14 (runtime table) |
| 322 | and R15 (stack floor) untouched. RBX anchors the saved slot snapshot; R13 scratch |
| 323 | is restored before returning. The ordinary program-mode initial argument stack |
| 324 | in R13 is therefore preserved too. |
| 325 | |
| 326 | The hosted compiler cases pin both targets' emitted bytes. Wrong-mmap-syscall and |
| 327 | missing-MFENCE compiler mutants must fail those byte checks; this is instruction |
| 328 | structure evidence, not a claim that QEMU reproduces WC reordering. The bridge |
| 329 | adds memfd/ioctl/C differential runtime fixtures under the x86 QEMU oracle. |
| 330 | |
| 331 | The draft ABI1 hosted-x86 superset stacks the #1046 lowerers and fixtures on |
| 332 | #1047's exact five-request allowlist. Its seed0-born compiler fingerprint is |
| 333 | `c5ac9979232afd0d750e1d5088af69692032997136f761e585a25aa9a1cfc87e`. |
| 334 | This is a new profile, not an in-place replacement of the frozen AArch64 |
| 335 | `b8f8f137...`, previous hosted-x86 `cf4fcbbb...` or pure-x86 `be8c5130...` |
| 336 | profiles. The bridge selects the new hosted-x86 fingerprint explicitly. |
| 337 | Program mode retains its128-slot contract; function-mode context layout and |
| 338 | ownership are unchanged. Drake must approve the draft compiler/bridge |
| 339 | contracts before merge. Native x86, driver/GPU behavior and WC timing remain |
| 340 | NOT_RUN unless separately qualified. |
| 341 | |
| 342 | The current-main landing rebuild of #1050 preserves every stack head, including |
| 343 | #1046's original commits, and produces compiler fingerprint |
| 344 | `96eda108a064e419a6cda9112d3bf56ab64f2265fb04f8bb62c08a0786569763`. |
| 345 | The full native-host qualification and `tests/gates/run.sh om-units` pass with |
| 346 | that compiler on Linux AArch64 under a device-hidden bwrap sandbox. This updates |
| 347 | active compiler-consumer pins, not frozen bridge profiles or hardware evidence. |
| 348 | |
| 349 | The subsequent #1045 VFIO integration births compiler |
| 350 | `b1d9cff6d765d85159e14d8346ed946704e32e9ca39554fb22a7c3f23fe0cca3` |
| 351 | from source |
| 352 | `5419943aad39c6205bb673c1ddb1be874b1877163cc2f143c07a742cf347456c`. |
| 353 | Its508 source functions fit the unchanged512-function om4 seed; |
| 354 | single-caller helper consolidation, not a seed-capacity change, provides the |
| 355 | space. Descriptor-kind bookkeeping is restricted to program mode, retaining |
| 356 | the existing function-mode host-word byte contracts. The full native-host |
| 357 | gate passes under the device-hidden sandbox, including the IRQ runtime |
| 358 | oracle and compiler mutants. This is host qualification, not hardware IRQ |
| 359 | delivery or authorization to repin a downstream driver's compiler. |
| 360 | |
| 361 | The x86efi anchor fix (branch `hive/omega-mv-x86efi-semhash`) births compiler |
| 362 | `5f90edea61bac241398df5036990d899361a5acd9decb37954ce088ec0f6f6df` |
| 363 | from source |
| 364 | `2c0fc44bdd607f9e84315e15c7c7ea263a5f0b6d83aa3f446fa6ed975e8ef34c`. |
| 365 | Since #1050, `xhbegin` anchors the slot snapshot in RBX, but `xefival` still |
| 366 | loaded the firmware ARG into RBX before reading the A and N slots and returned |
| 367 | through an unset R14, so every `efi` operation faulted. `xefival` now saves the |
| 368 | caller's R14 at snapshot offset 152, carries the anchor in firmware-preserved |
| 369 | R14 across the call, loads ARG last and restores R13 and R14 from the snapshot |
| 370 | tail. `tests/x86efi/run.sh` under QEMU/OVMF goes from 4/25 to 25/25; this is |
| 371 | emulated, not hardware evidence. |
| 372 | |
| 373 | The execenv 233 host word (branch `hive/execprog-env`) births compiler |
| 374 | `ee5fc83e357c7285e20ae9246d8129cdf8833b74f7205242e17fa62382334dfa` |
| 375 | from source |
| 376 | `062c9649af6a1d499b911e5b2f39b5419d7b75047616fe59fbcdc25f7b7b5b73`. |
| 377 | `execenv A off n B off m` is `execprog` with a private environment packet B, |
| 378 | decoded by a second `hpack`/`xhpack` pass; no function was added (508 of 512). |
| 379 | Every one of the 1357 tracked `.om` files compiles to the same bytes, exit |
| 380 | status and diagnostics under `5f90edea` and `cfd96b48`, so no existing unit's |
| 381 | emission changes. Gate: `seed/host/execenv/execenv.cases`. |
| 382 | |
| 383 | x86 types `fma` operands before its error 9 (branch `fix/x86-fma-order`, |
| 384 | OMEGESE.md 9.9) births compiler |
| 385 | `0f2de85153b07656f4b992d101272987fe6ed1eee471ef70b132a37f5ba6b02f` |
| 386 | from source |
| 387 | `7d8026837cfcafe53222228f076e4dab58279ae78a4b008440e6262f5b3c91ab`. |
| 388 | No host word changes and no function was added (508 of 512). Each of the 1485 |
| 389 | tracked `.om` files was compiled alone for AArch64 and for `target x86linux` |
| 390 | under `cfd96b48` and `0f2de851`: 2962 of the 2970 compiles give the same bytes, |
| 391 | exit status and diagnostics; the other 8 are the x86 compiles of the ill-typed |
| 392 | `seed/omc/tests/float/neg_fma_*` refusals, error 9 before and now the AArch64 |
| 393 | error 7 or 11. Gate: `seed/omc/gate8.sh` (`refuse_x86`). |
| 394 | |
| 395 | The prlimit 235 host word (branch `seed/prlimit-host-word`, now on main as |
| 396 | keyword 235 of `seed/omc/omc.om`; first born as `3c2817a5` on rad main `da8b7e66`, then merged with rad |
| 397 | main `408c76b7`) births compiler |
| 398 | `6d1b1cf5a44803389a831b67f750ea4cd1c9f53edfde9d6d9241d7352887f1f8` |
| 399 | from source |
| 400 | `7995e0e31bb3abcf9905fbb6257d56613b2dc67dd22be56f7396151fa84e7189`. |
| 401 | `prlimit pid res A off n` is Linux `prlimit64`: AArch64 syscall 261 (`hprlim`, |
| 402 | x0 pid, x1 res, x2 new, x3 old) and x86-64 syscall 302 (`xhprlim`, rdi pid, |
| 403 | rsi res, rdx new, r10 old). `n` 16 passes new = NULL and old = &A[off]; `n` 32 |
| 404 | passes new = &A[off] and old = &A[off+16]; any other `n` sets -22 and skips the |
| 405 | SVC/`syscall`. Two functions were added (510 of 512). Each of the 1496 tracked |
| 406 | `.om` files was compiled alone for AArch64 and for `target x86linux` under |
| 407 | `0f2de851` and `6d1b1cf5`: 2980 of the 2992 compiles give the same bytes, exit |
| 408 | status and diagnostics; the other 12 are the AArch64 and x86 compiles of the six |
| 409 | `seed/host/prlimit/` sources, which use the new word (error 3 before). Gate: |
| 410 | `seed/host/prlimit/prlimit.cases`. |
| 411 | Names of up to 63 bytes (branch `omc/long-names`, OMEGESE.md 9.2) birth compiler |
| 412 | `3e46f1d9bdfd9c00ebdd1abb615d038d6db998e596b58482a6bdcc131f9af5c6` |
| 413 | from source |
| 414 | `4da2fd20f0c40d1d7aa85ddbd45a70cc5c35c5feaa925d34907b1a3ca7bc7416`. |
| 415 | No host word changes and no function was added (508 of 512). Each of the 1485 |
| 416 | tracked `.om` files was compiled alone for AArch64 and for `target x86linux` |
| 417 | under `cfd96b48` and `3e46f1d9`: 2948 of the 2970 compiles give the same bytes, |
| 418 | exit status and diagnostics; the other 22 are 11 files that were error 13 under |
| 419 | `cfd96b48` and are fragments or tests of that refusal (refused either way, or |
| 420 | `seed/omc/om2/s1/bad-kw-field.om`, now `kw-long-field.om`, accepted). |
| 421 | Gate: `seed/omc/gate-longnames.sh`. |
| 422 | |
| 423 | |
| 424 | ## Scheduler-word compiler pin (ham/om-threads, draft) |
| 425 | |
| 426 | Scheduler host words 236..240 are additive; first born on Radicle main a59a425b |
| 427 | (`13a0c88c`, ham/om-threads-3 on f71942bb), now on `ham/om-threads-4`, stacked on |
| 428 | `ham/omc-perf-loops-5` on Radicle main 12bdb787. |
| 429 | The seed-born compiler is |
| 430 | `0ed21175a1709cb755c289383cd8fcbfaac8330c3967fe4656b9f82fc96a3c4f`, |
| 431 | from compiler source |
| 432 | `232f89ebe688e81c289a9d0225dd06e4d8e8aaad8e489433634e7f8bf0b9b0a9`. |
| 433 | The seed birth, both-parent equality and self-rebuild fixpoint were EXERCISED. |
| 434 | The contract is in `spec/omegese-cpu-workers.md`; the full scheduler module is |
| 435 | `seed/host/affinity/sched.cases`, included in `seed/host/check.sh`. |
| 436 | All new words are program-only. No function-mode mapping context or device word |
| 437 | changes. CPU threads and scaling are NOT_RUN in this head, deferred by parent |
| 438 | mac-ham to a separate run. Historical compiler and mapping receipts above stay |
| 439 | unchanged. |