- Add u32::MAX (0xffff_ffff) PCIe bus-loss checks to all 11 unguarded MMIO polling loops in src/nvidia/kernel/pmu_bringup.rs (NVDEC/NVENC falcon reset & DMA transfer waits) and src/nvidia/kernel/rmapi_engine.rs (BAR1/UVM MMU TLB invalidation waits and MmioOp::Poll32). - Add mmio_bus_loss_guards domain and Windows-only ETW exclusion (0x00000131) to tools/build_parity_ledger.py (29/29 MMIO poll loops guarded, 6/8 domains at 0 MISSING).
6.3 KiB
/goal Perform a closed-world, exhaustive REA parity audit and port of NVIDIA 580.178.04 into nvidia-driver-rs until ZERO unported functionality remains.
Core Rule
Do NOT sample "top N gaps" and stop. You MUST enumerate the COMPLETE surface of the original 580.178.04 driver binaries on disk (target/stock-580-kmods/nvidia/nv-kernel.o_binary, target/stock-580-kmods/nvidia.ko, target/stock-580-kmods/nvidia-uvm.ko, target/stock-580-kmods/nvidia-modeset.ko, target/stock-580-kmods/nvidia-drm.ko, target/stock-580-kmods/nvidia-peermem.ko, plus userspace callers libcuda.so.1, libnvidia-ml.so.1, libGLX_nvidia.so) using REA MCP tools (inspect_kernel_module, inspect_with_objdump, open_binary, procedure_pseudo_code, procedure_assembly, procedure_callees, xrefs, build_reconstruction_obligation_ledger, evaluate_reconstruction_coverage).
Follow AGENTS.md strictly at all times (7-step REA-first loop, clean-room MIT #![no_std], geodd03 machine safety rules, and §3 review gate). Treat the shared Ghidra project as read-only.
Step 1 — Build a Machine-Verified Closed-World Parity Ledger
Maintain tools/build_parity_ledger.py, reports/parity_ledger_580.json, and docs/PARITY_LEDGER.md containing every single item extracted from the stock 580.178.04 binaries across all 8 domains:
- RMAPI Escapes (
RmIoctl+nvidia_unlocked_ioctl): everyNV_ESC_*command (0x27..0x5F,0xC8..0xDB), exact struct size, field offsets, error ordering, and side effects. - RM Control Commands (
0x0000_*,0x0041_*,0x0073_*,0x0080_*,0x2080_*,0x2081_*,0x503c_*,0x90f1_*,0xa06c_*,0xa06f_*,0xc361_*,0xc36f_*): every control command present in stock 580.178.04 RM control tables and/or referenced bylibcuda.so.1,libnvidia-ml.so.1, orlibGLX_nvidia.so. - RM Object Classes (
NV_ESC_RM_ALLOC/NV_ESC_RM_ALLOC_OBJECT/NV_ESC_RM_ALLOC_MEMORY/NV_ESC_RM_VID_HEAP_CONTROL): every class ID, constructor, destructor, and cross-client/cross-GPU access check. - UVM Ioctls & Internal Helpers (
/dev/nvidia-uvm+/dev/nvidia-uvm-tools): everyuvm_api_*anduvm_tools_*handler innvidia-uvm.ko, exact ABI struct sizes/offsets, arch property tables (Maxwell–Blackwell), and fault/migration/atomics semantics. - DRM & NVKMS UAPI (
nvidia-drm.ko+nvidia-modeset.ko): everynv_drm_*_ioctl(all 24) and everyNVKMS_IOCTL_*command, dma-buf export/revocation, and fence/semsurf path. - Character Devices,
/proc/driver/nvidia/*, sysfs & hwmon: every/procfile,/dev/nvidia-caps/*,DeviceFileMode, and hwmon attribute exposed by stocknvidia.ko. - Hardware Engines & GSP/Pre-GSP Silicon Paths: every Maxwell/Pascal/Volta Pre-GSP engine routine (MMU/BAR1/BAR2/FIFO/GR/CE/PMU/SEC2/ACR/NVLINK/THERM/CLK/VOLT/PMGR) and every Turing/Ampere/Ada/Hopper/Blackwell GSP-RM boot, RPC, sequencer, and telemetry routine — including BAR0
0xffff_ffffbus-loss guards on every MMIO poll loop. - Retrospective PR/Issue Gap Sweep: Inspect EVERY PR opened or merged in the last 48 hours and every open GitHub issue; for each one, identify the underlying unported stock 580.178.04 behavior it exposed and add the entire family of related stock functions (not just the single reported symptom) to the ledger.
Every ledger entry MUST have:
id(symbol name, ioctl/control hex code, or path)stock_evidence(exact binary path + symbol + instruction/offset verified via REA)status: one ofPORTED,PARTIAL,MISSING,INTENTIONALLY_EXCLUDEDrust_location: exactsrc/...orkernel-open/...file + symbol + line range (required forPORTEDandPARTIAL)verification: exact unit test, Unicorn binary oracle, or QEMU test proving bit-for-bit parity (required forPORTED)exclusion_reason: required ifINTENTIONALLY_EXCLUDED(e.g., Windows-only, VMware-only, non-Linux platform; never exclude a Linux feature just because it is hard)
Step 2 — Iterative Porting Loop (Repeat Until MISSING == 0 and PARTIAL == 0)
For each batch of MISSING or PARTIAL entries (prioritized by real userspace impact: CUDA → NVML/nvidia-smi → Vulkan/DRM/NVKMS → UVM → multi-gen silicon → /proc/caps):
- REA first: Disassemble/decompile the exact stock 580.178.04 function and its callees (struct layouts, field offsets, bitmasks, error-code precedence, lock order, MMIO sequence).
- Port faithfully in Rust: Implement the full algorithm cleanly in
#![no_std]Rust (keep C inkernel-open/strictly a thin Linux-kernel ABI shim). - Add tests & oracles: Write unit tests covering every branch, boundary condition, and error code; add/update Unicorn binary oracles where applicable.
- Validate before committing:
cargo fmt --checkcargo clippy --workspace --all-targets -- -D warningscargo test --workspacemake modules(with zero C warnings)python3 tools/check_kernel_module.py(0 GOT, 0 SIMD, 0memcpy/memset/memmove, stack <= 1024 B)python3 -m unittest tests/kernel-module-gate/test_gate_cases.pypython3 -m unittest discover -s tests/offline
- Update the ledger: Mark newly completed items
PORTEDwith exact file/line + test citations, and commit cleanly in logical, reviewable commits (or PRs followingAGENTS.md §3). - Re-run the ledger generator script after every batch to prove monotonically decreasing
MISSING+PARTIALcounts.
Step 3 — Hard Exit Gate (Do NOT Finish Early)
You may ONLY consider the goal complete when ALL of the following are simultaneously true and verified by an automated script run at the end:
- Every symbol, escape, RM control, RM class, UVM ioctl, DRM ioctl, NVKMS ioctl, and
/procentry extracted from stock 580.178.04 is present inreports/parity_ledger_580.jsonwithUNACCOUNTED == 0. MISSING == 0andPARTIAL == 0across all 8 domains (every entry is eitherPORTEDwith verifiedrust_location+ passing test, orINTENTIONALLY_EXCLUDEDwith a narrow, audited platform justification).- Zero regressions:
cargo fmt --check,cargo clippy -- -D warnings,cargo test --workspace,make modules,check_kernel_module.py, andtests/kernel-module-gate/test_gate_cases.pyall pass 100%. - Every PR from the last 48 hours and every open issue has been cross-checked against the ledger so no class of gap they revealed remains unported.