The 19 areas of tools/gp106/check.sh, which hold all 26 GP106 opt-in (#[ignore]) comparisons against the 580.178.04 instructions, were run by nothing: not by validate_all.sh, not by the Makefile. They only ran when someone typed the loop from reports/gp106-core-validation.md, and that loop left out pte-policy. check.sh gains an `all` area that runs every area in order and stops at the first failure. validate_all.sh runs it as the optional step gp106_oracles, next to gsp_620_headers. Missing prerequisites follow the existing optional-step rule (exit 2 is SKIP, as in test_native_compute.sh and oracle_gsp_620.py): `all` exits 2 before running anything when the interpreter cannot import Unicorn and pyelftools, or when resolve_580_binary() finds no original object. A present object with the wrong digest, a generator error or a Rust mismatch is still FAIL. The interpreter default is the top-level Makefile's REA_PYTHON default. The report now documents `check.sh all` in place of the hand-written loop. The step count in AGENTS.md, CLAUDE.md and docs/GPU_BRINGUP_GUIDE.md is set to 36, the number of PASS/FAIL/SKIP lines validate_all.sh prints with this step; those files said 31, 30 and 31 while the script already printed 35. Tests: tests/gp106/test_check_all.py covers both exit-2 paths and the usage line with stand-in interpreters; tests/vm/test_validate_guest_steps.py covers PASS, SKIP and FAIL of the new step. All six fail on master. No driver logic changes. On this host `check.sh all` passes all 19 areas (90 Rust tests, 0 failed) in about 4 minutes cold, 3 minutes warm; BAR2 and the two framebuffer generators are most of it.
8.3 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Rules that override everything below
All agent, REA parity-verification, and machine safety rules for this repository are maintained in AGENTS.md. Follow it in full, and copy its rules into every subagent brief that could touch hardware, the original driver, or driver logic.
@AGENTS.md
The points most likely to be violated by accident:
- Driver logic is never guessed. Any RM control, UVM ioctl, MMU format, FIFO/runlist sequence or firmware protocol is derived from the closed 580.178.04 binaries with the REA MCP tools first, then implemented, then checked against oracles (AGENTS.md §1).
- Never run
reboot/shutdown/poweroff, never reset a GPU through sysfs orsetpci, never mmiotrace the original driver. Before anything that opens/dev/nvidia*, run the health checks in AGENTS.md §2 and give the command its owntimeout. tools/validate_all.shis not purely offline: its last step (live) runssudo -n python3 tools/run_live_control.py, whichinsmodsnvidia_rs.kowith an emptypci_target(no GPU binding) and exercises/dev/nvidia-rsctl. Withkernel.panic_on_oops=1on geodd03, a bug there restarts the machine.make modules_installrefuses to run withoutINSTALL_MOD_PATHpointing at a staging directory. Replacing the working driver is done only through./install.sh, and only when the user asks.- Never merge a PR containing code changes without CodeRabbit review and approval (AGENTS.md §3). Do not merge while CodeRabbit is rate-limited, unreviewed, or has unresolved findings.
Commands
Run everything from the repository root so rustup picks the pinned toolchain (rust-toolchain.toml, 1.100.0, target x86_64-unknown-none).
sh tools/validate_all.sh # the 36-step gate; one PASS/FAIL/SKIP line per step, logs in target/validate-logs/<step>.log
make modules # Rust core -> nv-rust.o_binary, Kbuild -> kernel-open/*.ko, then tools/check_kernel_module.py
make check # fmt + clippy -D warnings + `--check` of every generated table (needs REA_PYTHON)
make test # cargo test --workspace
make uvm-bridge # CONFIG_MODVERSIONS bridge for stock nvidia-uvm.ko + symbol conformance check
make modeset-bridge # same for stock nvidia-modeset.ko
make -C src/nvidia audit-codegen && python3 tools/check_native_codegen.py
ARCH=arm64 make modules # aarch64-unknown-none build
Single tests:
cargo test -p nv-rs-core <name_filter> # unit test inside src/nvidia/src
cargo test -p nv-rs-core --test gr_load # one integration test file from src/nvidia/tests/
sh tools/test_dma_bridge.sh # one C<->Rust host fixture (see the list in validate_all.sh; two of them need bash)
python3 tools/vm/run_guest.py [--iommu] # QEMU guest tests (after tools/vm/build_guest_test.sh and build_initramfs.sh)
python3 tools/mock_gv100_diff.py # Unicorn oracles: Rust vs. original 580 instructions
Kernel tree selection: KERNEL_UNAME, KERNEL_SOURCES/SYSSRC, KERNEL_OUTPUT/SYSOUT. utils.mk turns on LLVM=1 for clang-built kernels and the IBT flags (-Z cf-protection=branch, RUSTC_BOOTSTRAP=1) when the kernel has CONFIG_X86_KERNEL_IBT=y; override with NV_RS_KERNEL_IBT=0/1. When a kernel-open build breaks on a removed kernel symbol, read docs/KERNEL_COMPAT.md before adding a version guard: the preferred fix mirrors what stock 580 does without a guard.
Live testing on a real GPU goes through a disposable VFIO VM (sudo python3 tools/vm/run_vfio_guest.py --bdf <bdf> --driver rust) or tools/dual_gpu_parity.py --no-rebind, never by rebinding a card back to stock nvidia.ko.
Architecture
The module is a Rust static object linked into a thin C shim. The kernel does not need CONFIG_RUST.
src/common/abi nv_rs_abi #![no_std], forbid(unsafe) C/Rust wire structs and ioctl layouts
src/nvidia/src nv_rs_core #![no_std], forbid(unsafe) all driver logic: gpu/, mmu/, fifo/, rmapi/, uvm/, ...
src/nvidia/kernel nv_rs_kernel staticlib, unsafe allowed FFI boundary + live bring-up (ACR, PMU, FIFO, GR, GSP, GA10x)
kernel-open/nvidia C PCI/chardev/DMA/IRQ/hwmon/dma-buf adapters -> nvidia_rs.ko
- Build pipeline (
src/nvidia/Makefile):rustcis invoked directly, not through cargo, with the kernel flags fromutils.mk(soft-float, no redzone, kernel code model,panic=abort).nv_rs_abiandnv_rs_corebecome rlibs,nv_rs_kernela fat-LTO staticlib, andld -r --gc-sectionskeeps only what is reachable from an explicit-u nv_rs_<name>list. A new#[no_mangle] nv_rs_*export must be added to that list or it is garbage-collected and the C side fails to link. The result,kernel-open/nvidia/nv-rust.o_binary, is copied torust-core.obykernel-open/Kbuild. - Cargo is for host tests only. The workspace has two members (
src/common/abi,src/nvidia);nv_rs_kernelis not a cargo crate and is compiled for the host only by thetools/test_*.shfixtures and the VM guest build. - C shim rule of thumb: each
kernel-open/nvidia/*_adapter.cowns one kernel facility (PCI, DMA, IRQ, timers, threads, registry, ROM) and has a matching Rust module insrc/nvidia/kernel/and a mock undertests/<name>-mock/that compiles the same C withNV_RS_*_HOST_FIXTURE. Buffer ownership and user copies stay in C; Rust receives kernel-copied bytes and sized/aligned state allocations. - Device nodes:
rmapi_node.c(RM API, the/dev/nvidia*ioctl surface) anduvm_node.c(integrated UVM) route intokernel/rmapi_node.rs,rmapi_engine.rsanduvm_node.rs, which dispatch intonv_rs_core::rmapiandnv_rs_core::uvm.diagnostic.cis the isolated/dev/nvidia-rsctlcontrol node used by the live gate step. Module parameters are declared in the shim file that owns the feature (mostlygpu_owner.candrmapi_node.c). - Chip selection:
src/nvidia/src/gpu/chip_arch.rsmapsPMC_BOOTto anArchFamilyand MMU format; pre-GSP families (Maxwell, Pascal, Volta) run natively, Turing and later go through the GSP-RM transport (gpu/gsp_*.rs,kernel/gsp_bringup.rs, ABI chosen bygsp_abi), and GA10x has its own split-RM path inkernel/ga10x*.rs. - Sibling modules (
kernel-open/nvidia-modeset,nvidia-drm,nvidia-peermem) are built by the same Kbuild;uvm_bridgeandmodeset_bridgeare separate builds that export stock-CRC symbols so unmodifiednvidia-uvm.ko/nvidia-modeset.koload againstnvidia_rs.ko.
Kernel-object constraints
tools/check_kernel_module.py runs at the end of every make modules and fails the build on: GOT relocations, SIMD/x87 instructions, calls to memcpy/memset/memmove, unwind sections, or any stack frame over 1,024 bytes. In practice: no large by-value structs or arrays on the stack in nv_rs_core/nv_rs_kernel, no floating point, and large state is initialised in place (the FFI layer uses volatile byte stores for this). Panics compile to UD2, and overflow-checks is on, so an arithmetic overflow is a kernel oops.
Generated code and oracle vectors
- Files headed
// Generated by tools/...; do not edit(e.g.src/nvidia/src/hardware/generated.rs, the RM API class/control tables) are regenerated with the matchingtools/generate_*.py;make checkruns each with--check. *_vectors.rsfiles next to a module are recorded outputs of the original driver's instructions (Unicorn or compiled-C oracles). A test that disagrees with them means the Rust is wrong; regenerate vectors only through the generating tool, never by hand.*_tests.rssits beside the module it tests and is pulled in under#[cfg(test)].
Evidence and history
HANDOFF.mdis the running engineering log (latest status at the top, current artifact digests);reports/HANDOFF-history-through-2026-11-20.mdholds older history. UpdateHANDOFF.mdbefore any hardware run.reports/<topic>-rea/holds per-subsystem reverse-engineering evidence,analysis/the extracted reference material from the closed driver. Keep the evidence categories from AGENTS.md §1.3 separate when adding to them.docs/PARITY_AND_UNLOCKS.mdis the source of truth for what is verified on silicon versus offline only. Read it before claiming parity for anything.