Files
nvdriver/docs/GOAL_100_PARITY_PROMPT.md
Eric Hartford 4e60a36c7d fix(kernel,tools): guard all BAR0 MMIO poll loops against PCIe bus loss (0xffff_ffff)
- 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).
2026-12-03 09:56:37 +00:00

6.3 KiB
Raw Permalink Blame History

/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:

  1. RMAPI Escapes (RmIoctl + nvidia_unlocked_ioctl): every NV_ESC_* command (0x27..0x5F, 0xC8..0xDB), exact struct size, field offsets, error ordering, and side effects.
  2. 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 by libcuda.so.1, libnvidia-ml.so.1, or libGLX_nvidia.so.
  3. 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.
  4. UVM Ioctls & Internal Helpers (/dev/nvidia-uvm + /dev/nvidia-uvm-tools): every uvm_api_* and uvm_tools_* handler in nvidia-uvm.ko, exact ABI struct sizes/offsets, arch property tables (Maxwell–Blackwell), and fault/migration/atomics semantics.
  5. DRM & NVKMS UAPI (nvidia-drm.ko + nvidia-modeset.ko): every nv_drm_*_ioctl (all 24) and every NVKMS_IOCTL_* command, dma-buf export/revocation, and fence/semsurf path.
  6. Character Devices, /proc/driver/nvidia/*, sysfs & hwmon: every /proc file, /dev/nvidia-caps/*, DeviceFileMode, and hwmon attribute exposed by stock nvidia.ko.
  7. 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_ffff bus-loss guards on every MMIO poll loop.
  8. 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 of PORTED, PARTIAL, MISSING, INTENTIONALLY_EXCLUDED
  • rust_location: exact src/... or kernel-open/... file + symbol + line range (required for PORTED and PARTIAL)
  • verification: exact unit test, Unicorn binary oracle, or QEMU test proving bit-for-bit parity (required for PORTED)
  • exclusion_reason: required if INTENTIONALLY_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):

  1. 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).
  2. Port faithfully in Rust: Implement the full algorithm cleanly in #![no_std] Rust (keep C in kernel-open/ strictly a thin Linux-kernel ABI shim).
  3. Add tests & oracles: Write unit tests covering every branch, boundary condition, and error code; add/update Unicorn binary oracles where applicable.
  4. Validate before committing:
    • cargo fmt --check
    • cargo clippy --workspace --all-targets -- -D warnings
    • cargo test --workspace
    • make modules (with zero C warnings)
    • python3 tools/check_kernel_module.py (0 GOT, 0 SIMD, 0 memcpy/memset/memmove, stack <= 1024 B)
    • python3 -m unittest tests/kernel-module-gate/test_gate_cases.py
    • python3 -m unittest discover -s tests/offline
  5. Update the ledger: Mark newly completed items PORTED with exact file/line + test citations, and commit cleanly in logical, reviewable commits (or PRs following AGENTS.md §3).
  6. Re-run the ledger generator script after every batch to prove monotonically decreasing MISSING + PARTIAL counts.

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:

  1. Every symbol, escape, RM control, RM class, UVM ioctl, DRM ioctl, NVKMS ioctl, and /proc entry extracted from stock 580.178.04 is present in reports/parity_ledger_580.json with UNACCOUNTED == 0.
  2. MISSING == 0 and PARTIAL == 0 across all 8 domains (every entry is either PORTED with verified rust_location + passing test, or INTENTIONALLY_EXCLUDED with a narrow, audited platform justification).
  3. Zero regressions: cargo fmt --check, cargo clippy -- -D warnings, cargo test --workspace, make modules, check_kernel_module.py, and tests/kernel-module-gate/test_gate_cases.py all pass 100%.
  4. 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.