Fixes two GV100 multi-GPU bugs observed on 8x Tesla V100-SXM2-32GB:
1. PCE8 (NV_PFAULT_MMU_ENG_ID_CE8 = 0x17) UNBOUND_INST_BLOCK on CE3 VRAM scrub:
pmu_bringup.rs previously programmed the PCIe-only PCE2LCE map (Table[0],
leaving PCE8 = 0xf) before PFIFO/CE bringup, and set_nvlink_ready_and_train()
later reprogrammed PCE2LCE to Table[4] (bonding PCE8 onto LCE3) while
SCRUB_CHID=0xffe was already bound on SCRUB_RUNLIST=7 (LCE3). That left PCE8
without a bound instance block so the first NV01_MEMORY_LOCAL_USER (0x40)
scrub_ce_memset_zero() faulted on SCRUB_SEM_VA (0x1_0000_2000) with
UNBOUND_INST_BLOCK and timed out TSG_PREEMPT (NOTE_SCRUB_CE 0xdead_0002).
- Program Table[4] upfront in pmu_bringup.rs on NVLink-capable SXM2 GPUs
(keeping Table[0] when NVLink is fused off).
- Track the programmed hardware PCE2LCE map as a packed u64 key per
LiveEngine (ce_pce2lce_key) so set_nvlink_ready_and_train() skips
redundant rewrites when the topology matches, and cleanly stops/resets/
re-initializes scrub_ce if a topology change is required.
2. Clean module unload after a non-replayable CE MMU fault:
deactivate() did not reset wedged CE engines or call clear_pfifo_pbdma_intrs()
when a non-replayable HUB MMU fault (0x100e60) or stuck TSG preempt (0x2634)
was latched, causing PMU unbind (_nv052303rm) to time out, ACR WPR unlock to
fail (0xdead_0007), and BAR0 to be leaked (-EBUSY on next insmod).
- Reset CE0..CE8 via NV_PMC_ENABLE (0x200) when 0x100e60 VALID or 0x2634
PENDING is set, and call clear_pfifo_pbdma_intrs() during deactivate().
Verified on 8x Tesla V100-SXM2-32GB: check_kernel_module.py passes (0 GOT
relocations, largest_stack 1000), hot-reload unloads/reloads cleanly without
reboot, and all 8 GPUs pass cuDevicePrimaryCtxRetain (73-155 ms) and PyTorch
2.17+cu135 FP32/FP16/BF16 GEMM, cuDNN, Triton, CUDA Graphs, SDPA, and P2P.
Fixes every root cause behind #141 (4x Tesla P100), #81 (GTX 1080 Ti), and #84
(GM206 Maxwell):
- Broaden gpu_needs_attach_registers from GV100-only to all pre-GSP GPUs
(Facts::is_pre_gsp) and allow engine_stage() fallback to Stage::Swept(fuse)
on Maxwell/Pascal when GV100 PCE2LCE is absent.
- Add architecture-aware class_db::map_class_for_arch / records_for_arch /
class_list_for_arch so Maxwell (0xb06f/0xb0c0/0xb1c0/0xb0b5) and Pascal
(0xc06f/0xc0c0/0xc1c0/0xc0b5/0xc1b5/0xb069) expose their real classes and
omit Volta-only 0xc361.
- Parameterize gr_info_for_arch (0x20801201) and gr_global_sm_order_for_arch
(0x2080121b) for 1 SM/TPC on Maxwell/Pascal and exact SM_VERSION
(0x500/0x502/0x600/0x601/0x700).
- Allow hUserdMemory == 0 in channel_alloc for Maxwell/Pascal BAR1 USERD slots.
- Replace nv_rs_runtime_park with a 1 Hz nv_rs_runtime_park_wait telemetry loop
in boot_maxwell_pascal_pre_gsp, fix attach-time 0x20400 integer °C decode,
disable Pascal fault IRQ on teardown, and bound nv_rs_gpu_owner_runtime_stop
wait_for_completion_timeout to 10s.
- Fix broken 8-byte Maxwell/Pascal runlist translation in rmapi_engine.rs
(tsg_len from header[1], scale/timeout from header[0][19:16]/[31:24], CHID
from entry[2][11:0]).
Validated: cargo fmt/clippy/test (958+2), NV_RS_KERNEL_IBT=0 & 1 make modules +
check_kernel_module.py (largest_stack=1000), QEMU EDU verify_rust_guest.py.
Cluster 2 (RMAPI/UVM/Locking/Memory P0s):
- Convert runtime_start_users to atomic_t so wait_event() in
nv_rs_rmapi_node_gpu_remove never calls mutex_lock while !TASK_RUNNING.
- Guard all 6 unlocked nv_rs_alloc_reg_find() call sites in rmapi_node.c with
nv_rs_rmapi_alloc_lock.
- Run nv_rs_rmapi_rc_recover_fault while nv_rs_rmapi_lock is held from
nv_rs_rmapi_node_trylock() in nv_rs_uvm_fault_work_fn (no blocking re-lock).
- Filter MANAGED_RANGES and PAGE_TREES by UvmFile owner in uvm_node.rs to
prevent cross-process managed_unmap UAF; use flush_gpu_tlb_trylock() +
TLB_FLUSH_PENDING deferral so .mmap/vm_ops->close never touch LIVE_ENGINES
without nv_rs_rmapi_lock.
- Pin FD-exported memory backings in memory::Table::export_pins and check via
shared backing_shares_resource() so export -> free original -> import never
UAFs; release orphaned backings on FD owner close.
- Fix Backing::System map_protection(flags), deduplicate video_allocated_bytes,
and unmap Backing::Register in drop_mappings.
Cluster 4 (Kernel Build Hygiene & Linux 5.15-7.3 Compat P0s):
- Factor shared kernel-open/compat_probes.mk for Kbuild + build_guest_test.sh
(fixing Linux 5.15 char *date probe and Linux 7.0+ guest_build).
- Extend tools/prepare_kernel_archive.py to strip all kernel-exported
compiler_builtins mem/string members (strlen/memcpy/memmove/memset/memcmp/bcmp)
and wire it into tools/vm/build_guest_test.sh.
- Fix tools/check_kernel_module.py no_unhardened_sls_return to check per-ret
int3 succession instead of file-wide has_int3.
- Set AR=llvm-ar / NM=llvm-nm under LLVM=1 in utils.mk, LC_ALL=C and non-rustup
fallback in verify_rust_guest.py/check_native_codegen.py, and 1024 MiB guest RAM.
Validated: cargo fmt/clippy/test (958+2), test_gate_cases.py (24/24),
test_kernel_archive.py (5/5), NV_RS_KERNEL_IBT=0 & 1 make modules +
check_kernel_module.py (largest_stack=1000), QEMU EDU verify_rust_guest.py.
GSP_SET_SYSTEM_INFO went to GSP-RM with acpiMethodData and bIsPrimary
left zero. On an Optimus laptop nouveau (r535/r570_gsp_acpi_info) and
OpenRM fill them from the GPU's ACPI node: the _DOD display list, the JT
_DSM capabilities and the NVOP Optimus capabilities. Do the same, at the
580.178.04 GspSystemInfo offsets (acpiMethodData 0xa0..0x344, bIsPrimary
0x380), and log what was found:
ga10x: ACPI sysinfo: primary=0 dod=0(n=1) jt=0(caps=20016003) opt=0(caps=19000059)
This did not by itself fix the GA107 boot (the sysmem flush page did,
programmed since #145),
and it has not been tested in isolation; it brings the system info in
line with what the other drivers send on Optimus systems. Only x86 with
CONFIG_ACPI evaluates the methods.
bIsPrimary comes from video_is_primary_device() where <asm/video.h> has
it (6.9+, probed in Kbuild) and from the VGA arbiter's default device
before that.
Also report an I/O BAR to GSP-RM only when PCI_COMMAND_IO is enabled:
the GA107 exposes an I/O BAR that the platform leaves disabled.
GSP_INIT_DONE carries GSP-RM's init status in rpc_result, and the boot
ignored it. When GSP-RM's init fails it answers no RPC afterwards, so
the visible failure came 10 s later and somewhere else: on an RTX 3050
Laptop (GA107) without a sysmem flush page, GSP_INIT_DONE arrived with
0x40 (NV_ERR_INVALID_STATE), GET_GSP_STATIC_INFO then timed out, and
the teardown after it (booter-unload mbox0 0x88) left WPR2 locked until
the next reboot. (The flush page itself is now programmed since #145.)
- Check the result: log it with the boot time, and fail the boot with
the register dump when it is non-zero.
- On an RPC timeout, log the command and message queue read/write
pointers: it tells "GSP-RM stopped consuming commands" apart from
"its replies do not arrive".
- Log a dropped reply (to a request sent without waiting, such as
GSP_SET_SYSTEM_INFO and SET_REGISTRY) when it carries an error,
instead of discarding it silently.
- Clear NV_PFB_NISO_FLUSH_SYSMEM_ADDR(_HI) once the falcons are
stopped, before the flush page is freed, so the GPU is not left
pointing at a freed IOVA.
Ports three real-silicon Ada Lovelace (AD107 / RTX 4060, strict AMD-Vi IOMMU)
hardware-parity fixes discovered in PR #145 (@morebrackets) into the unified
multi-generation GSP-RM boot path (src/nvidia/kernel/ga10x_gsp.rs):
1. Prioritize NV_USABLE_FB_SIZE_IN_MB (0x1183a4) when non-zero (matching
kmemsysReadUsableFbSize_GA102: 8188 MiB on RTX 4060 vs 8192 MiB in 0x100ce0),
preventing FWSEC-FRTS error 0xbf; fall back to read_vram_bytes_for_family
when 0x1183a4 is unpopulated (Turing).
2. Allocate a persistent 4 KiB coherent DMA page and program
NV_PFB_NISO_FLUSH_SYSMEM_ADDR_HI/LO (0x100c40/0x100c10, matching
kmemsysProgramSysmemFlushBuffer_GA100) before GSP launch on all GSP-RM GPUs
to eliminate strict-IOMMU IO_PAGE_FAULTs, freeing it after falcon reset.
3. Run cold-boot AD10x SEC2 scrubber (kgspExecuteScrubberIfNeeded_AD102:
0x1180fc <= 0x5fff_ffff) via nvidia/ad102/sec2/scrubber-580.bin before
FWSEC-FRTS when needed.
Validated: cargo fmt/clippy/test (958+2), NV_RS_KERNEL_IBT=0 & 1 make modules +
check_kernel_module.py (largest_stack=1000), and QEMU EDU verify_rust_guest.py.
- Zero-friction first-run UX (#133): default runtime_engines=1 and pci_target=*
in nvidia_rs.ko (with explicit bringup=N precedence via resolve_bringup_mode);
install.sh auto-extracts pre-GSP firmware packs + GSP blobs, installs
/etc/modprobe.d/nvdriver.conf (install nvidia /bin/false, char-major-195-*
alias), /etc/modules-load.d/nvdriver.conf, and /etc/udev/rules.d/70-nvdriver.rules,
and enables BIND_DEV_NODES=1 by default.
- Maxwell & Pascal real firmware loading (GM10x-GP108): extend
tools/extract_gv100_firmware.py (--family gm20x|gp100|gp10x|all) using
REA-verified 580.178.04 ACR/PMU bundles (_nv016827rm/_nv016828rm/_nv016888rm)
with a shared pack_container() builder; wire LoadedPack::request_legacy and
HS Falcon IMEM/DMEM upload + execution into boot_maxwell_pascal_pre_gsp.
- Unified Hopper/Blackwell split-RM routing: add GspFirmwareChipFamily::boot_mode()
(FwsecBooter vs Fmc) as a single source of truth; integrate GH100/GB10x/GB20x
FMC BootROM handshake into Ga10xGsp::boot/unload via PciRegIo so every GSP-RM
GPU from Turing through Blackwell runs on the unified gsp_route.rs split-RM.
- Issue #142 Phases 3-4: add FileMappingLedger and GpuSlotLedger (+ unit tests)
to src/nvidia/src/rmapi/alloc_registry.rs + rmapi_memory.rs FFI, removing
struct nv_rs_rmapi_mapping and redundant bar0/bar1/numa_status fields from
kernel-open/nvidia/rmapi_node.c.
Validated: cargo fmt/clippy/test (957+2), NV_RS_KERNEL_IBT=0 & 1 make modules +
check_kernel_module.py (largest_stack=1000), test_gate_cases.py (18/18),
extract_gv100_firmware.py --check, and QEMU EDU verify_rust_guest.py (non-IOMMU
and --iommu, maxframe=984).
c553930 replaced the `!memory.duped` guard in Objects::destruct with
has_backing_ref(), which recognises shared System and Video backings
only. A class 0x71 (NV01_MEMORY_SYSTEM_OS_DESCRIPTOR) object copied by
NV_ESC_RM_DUP_OBJECT or an FD import keeps the same
Backing::UserPages { lock, .. }, but fell into `_ => false`: freeing
either handle unregistered and unpinned the user pages while the other
handle (and any GPU mapping made through it) still referenced them.
Match UserPages by its lock token, which names the pin; aliases copy
the whole backing. Regression test: the remaining alias keeps the pin,
a different lock token or a System backing with the same number does
not.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nv_rs_runtime_park_wait() releases the RM API lock while the runtime
thread is parked and takes it again when a stop is requested, assuming
its caller owns the lock. The GV100 path parks under ApiGuard and
ga10x::open wraps the park in nv_rs_rm_api_lock()/unlock(), but
boot_maxwell_pascal_pre_gsp() is reached before ApiGuard::acquire() and
parked without it. The thread therefore unlocked a mutex it did not own
and exited holding it, and the next nv_rs_rm_api_lock(), in the PCI
remove path, blocked forever with the device lock held.
Take the lock across activate, park and deactivate.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Resolve merge conflict in src/nvidia/kernel/rmapi_node.rs and update
new Wave 8 extern "C" blocks in adapter_start.rs and gsp_bringup.rs
to Rust Edition 2024 syntax.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Resolve merge conflicts in src/nvidia/kernel/pmu_bringup.rs and
src/nvidia/kernel/rmapi_node.rs against Wave 6/7 (7f7021e), preserving
all upstream logic while keeping Rust Edition 2024 syntax.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Conflict in pmu_bringup.rs: took upstream's adaptive HBM backoff logic;
converted its new extern block in adapter_start.rs to `unsafe extern`.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The executor fell to EOPNOTSUPP on the routed escape. Record the original behavior on the GM206 with target/statuscode_probe.c against stock 580.159 (status byte-for-byte, five cases incl. three PCI-address misses): domain/bus/slot at 0/4/5, state word at 8, miss answers at the rm_ioctl level (block untouched), state reads NV_ERR_INVALID_STATE until the device node opens and NV_OK after. find_by_pci mirrors nv_get_adapter_state (nv.c:4925). Verified A/B in the VM: with the arm, all five replies match stock exactly; nvidia-smi 580.178.04 no longer dies in 0xd1.
Co-authored-by: Christian Nilo <christiannilo@users.noreply.github.com>
LD_PRELOAD ioctl recorder, replay_diff.py, capture_stock.sh, replay_live.sh,
golden stock 620.73.04 transcript + known-gaps, and an offline control test.
Stock swap is opt-in via NV_RS_CAPTURE_BDF. No HANDOFF.md/AGENTS.md changes.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Huge thank you @Cinderella-Man for rewriting the entire GA102 (RTX 3090) GSP-RM 580.178.04 + V100↔RTX 3090 CUDA P2P + RM events + streaming DMA-mask fix into clean-room MIT Rust! Verified locally across fmt, clippy -D warnings, cargo test --workspace, make modules + check_kernel_module.py, and both QEMU EDU guest suites (non-IOMMU + strict IOMMU) — all green.
gr_object_alloc logged a failed golden() and went on to promote the client's context and allocate the object, though
GSP-RM faults the first client context it builds without a golden one. It now fails the allocation (NO_MEMORY when
golden() ran out of memory, INVALID_STATE otherwise). golden() is still Ok when the golden context is in place and only
the cleanup of its attempt waits for GSP-RM.
The promote's parameter block was allocated, and filled with fallible writes, after the three context buffers, so an
error there returned with the buffers unowned. The block is now allocated and filled first, all but the buffers'
addresses; each address is written as its buffer is allocated, and a failure frees what was allocated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
If golden_run succeeded but the free of its client then failed, golden_done and golden_held were both set: the
callers skipped golden() and golden() returned before its retry, so the client and its temporaries stayed until GPU
teardown.
The held cleanup now runs before the golden_done check, and gr_object_alloc calls golden() while either is pending.
After a golden context that worked, a free GSP-RM still refuses is not an error (the context is in place; the next GR
allocation tries again); before one, it stays EBUSY and no new attempt starts. The buffers stay held until GSP-RM
confirms the free, as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
nv_rs_pci_widen_dma is called once per mapped client page, and its callers in rmapi_node.c and uvm_node.c drop the
result, so a GPU stuck at the probe's 32-bit streaming mask was only visible through its symptoms: swiotlb bouncing,
or, behind a translating IOMMU, IOVA exhaustion in the 4 GiB below the mask (a field report on a V100 under VT-d
without iommu=pt: NO_MEMORY at the fifth 264 MiB pinned map).
The widen now says so in the kernel log: one info line when it raises the mask (with the width the leases and the
coherent mask keep), and one warning per device when the DMA API refuses it. The host fixture checks both, with a
refusing dma_set_mask.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When the free of the golden client failed, its temporaries rightly stayed, but nothing remembered them. The next
attempt asked GSP-RM for the same client handle; if GSP-RM refused it, the attempt counted as "no client" and released
the earlier attempt's VA space tables, still in use by GSP-RM, while the earlier buffers were never freed.
A failed client free now records the attempt on the GPU (golden_held). The next golden() frees that client again
first: until GSP-RM confirms it, nothing is released and no new attempt starts (EBUSY); once confirmed, the earlier VA
space tables and buffers are released and a new attempt runs. GPU teardown frees whatever is still held with the rest
of the kernel-side memory, as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The channel-first free (9d4f937) runs before nvdriver's own checks of NV_ESC_RM_FREE, and it looked only at the client
handle. Another file could name a client it does not own and one of its memory objects: the channels using that
memory were freed in GSP-RM before nvdriver refused the free itself.
free_memory_users now takes the caller's file and looks only at GPUs where that file owns the client, as the control
path (0x2a) already does. For another file's client nothing is freed and the free goes on to nvdriver's own checks,
which refuse it (NV_ERR_INVALID_CLIENT).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>