code wiki / (root) / nx_gpu_mem_gate.nx

nx_gpu_mem_gate.nx

buildroot/runtime/nx_gpu_mem_gate.nx

7811 B121 linesdepth 5pulls 6 transitivereach 0 importersview sourcekind gate/prooftopic gpu
docsdependenciesstructsconstsfunctions

about

nx_gpu_mem_gate.nx -- gpu GP6 heaps and residency on the real device, driven directly through nx_gpu_mem. Teeth: the budget is READ from the device for both segment groups; a bounded window of heaps (well under the budget) is allocated, placed and made resident; every heap is then EVICTED through the device's own EVICT and the proof of eviction is the device's own paging answer -- a make-resident after the evict returns DXG_MKRES_PENDING, where a heap that was never evicted answers 0. Tampers: an evict of a bogus handle is refused; a budget query for an invalid segment group is refused; and a positive control after the tampers reads the same local budget back. THE THIRD STATE: absent /dev/dxg (every host but the GPU laptop) is a gv_need precondition -> SKIP, never RED. SCOPE the board carries: the heaps are non-local (sysmem-backed, UMD-less); exhausting the LOCAL segment to force driver-initiated eviction needs VRAM allocations the vendor UMD owns, and exhausting the non-local segment would exhaust the host's RAM -- so this gate proves the EVICT MECHANISM and the budget accounting, not budget exhaustion. license_tier: ORIGINAL No hw writes (Rule 26). expect_exit: 0 (or 3 = SKIP where there is no /dev/dxg)

dependencies 5 imports · 0 importers

nx_syscalls.nx nx_dxg.nx nx_gpu_sync.nx nx_gpu_mem.nx nx_gate_verdict.nx nx_gpu_mem_gate.nx

imports: nx_syscalls.nxnx_dxg.nxnx_gpu_sync.nxnx_gpu_mem.nxnx_gate_verdict.nx

imported by: nobody (leaf or entry point)

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main gv_ctr sys_mmap nxa_die sys_write sys_exit nxa_lock_take nxa_lock_addr sys_write ↻ nxa_lock_give nxa_lock_addr ↻ nxa_report_overrun sys_write ↻ nxa_dump_printable sys_write ↻ nxa_dump_sizes sys_write ↻ gv_head gv_puts sys_write ↻ dxg_open sys_openat_rd gv_need gv_puts ↻ gv_verdict gv_note_bare_rate gv_bare_rate gv_at gv_obj_has_n gv_at ↻ gv_puts ↻ gv_num sys_mmap ↻ sys_write ↻ sys_munmap gv_puts ↻ gv_num ↻ gv_journal sys_openat_append sys_mmap ↻

structs

none

consts

19const GMG_HEAPS: i64 = 16
20const GMG_HEAP_BYTES: i64 = 1048576 // 1 MiB per heap: 16 MiB in flight, a bounded window under any budget here
21const GMG_BAD_GROUP: i64 = 5
22const GMG_BOGUS_ALLOC: i64 = 0xdeadbeef

functions

24func main() -> i64