Arsenova 78f8530140 dma-buf export of VRAM: by RM handle (stock ABI) and by CUDA address (#148)
* dmabuf: export RM video memory by handle

NV_ESC_EXPORT_TO_DMABUF_FD (0xd9) only exported a raw BAR1 range, for
CAP_SYS_ADMIN, ignoring the RM handles in the request. Implement the
stock ABI (nv_ioctl_export_to_dma_buf_fd_t, 2608 bytes):

- resolve each (hClient, hMemory, offset, size) to its VRAM with
  nv_rs_rmapi_resolve_dmabuf_object(), authorized like the original:
  the client belongs to the caller's file or its control file
  (CAP_SYS_ADMIN may export any);
- a non-contiguous allocation (scatter_id != 0) is walked segment by
  segment, each piece of the requested range becoming its own BAR1
  extent, so an export never covers the VRAM between two segments;
- up to 128 objects per call, batched calls (index > 0) for larger
  VMM exports, contiguous extents coalesced, segments capped at 1 GiB,
  at most 2^20 extents per dma-buf; its kernel memory (pins, extents)
  grows with the objects appended, not the declared total, and is
  charged to the caller's memory cgroup;
- the dma-buf is BAR1-backed (the GA10x BAR1 maps VRAM 1:1), mapped for
  importers with dma_map_resource(); bAllowMmap allows a write-combined
  CPU mmap, shared only (a private, copy-on-write mapping of PFN-mapped
  memory is refused: vmf_insert_pfn() BUG()s on one). The raw BAR1
  export stays for h_client == 0 (admin only);
- only GSP-RM GPUs export: their BAR1 maps VRAM 1:1 for as long as the
  GPU is in the RM. A pre-GSP GPU's BAR1 window belongs to the runtime
  engines, which clear it when they stop (suspend, AER) while an export
  would keep its offsets, so those GPUs refuse (NV_ERR_NOT_SUPPORTED);
- the fd is reserved, and installed only once the reply carrying it has
  been copied to the caller: a reply that does not arrive leaves no fd,
  and no pin, behind (the raw BAR1 export included).

A dma-buf must not outlive its memory: once the VRAM is freed it can be
handed to another allocation, and a peer still DMAing into the old
range would write into it. The dma-buf therefore holds the memory, as
the stock driver's exports do. Each exported object's backing is pinned
in the RM memory table (Table::pin_export, the reference the FD exports
already take), and every route that frees memory honours it:
NV_ESC_RM_FREE, NVOS32_FUNCTION_FREE (NV_ESC_RM_VID_HEAP_CONTROL),
freeing a parent or the whole client, file release, and channel USERD
orphan cleanup drop the handle but leave the VRAM, and a non-contiguous
allocation's segment chain, allocated while a pin exists. (The orphan
cleanup released a segment chain without that check; it now has it.)
When the dma-buf is released, a work item drops its pins under the RM
API lock and frees whatever nothing else references; a dma-buf can be
released with that lock held, so its release callback does not take it.
Module unload flushes the work item. Exports resolve their handles and
take their pins under the same lock, so a concurrent free either runs
first, and the export fails, or finds the pin.

Only GPU removal still revokes, as the memory goes away regardless.
It first marks the device as going away: from then until the GPU has
left the RM no dma-buf is created over it (the check and the insertion
into the export list are under one lock hold, so an export is either
listed or refused). Before taking the RM API lock, so that RM calls do
not wait behind the importers, every dma-buf over the device is first
marked revoked (attach, map and mmap then fail with -ENODEV) and its
CPU mappings are zapped; then its importers' mappings are invalidated
(dma_buf_invalidate_mappings), those whose reservation object is free
first; only then are the two waits the kernel-doc asks for done for
each: until the fences on the reservation object retire, and until
every importer mapping has been unmapped. An importer slow to retire
its fences, or holding a reservation object, thus leaves no other
dma-buf readable. A dma-buf whose last reference is already going is
waited for until its release has queued its pins, which are then
flushed, so none is dropped after the GPU is gone. Then,
under the lock and before the GPU leaves the RM, the pins are dropped;
nothing waits there. The CPU zap is unmap_mapping_range(); CPU mappings
are filled in at fault time
(vmf_insert_pfn after checking `revoked` under the dma-buf's lock), not
in .mmap, because the kernel links a new VMA into the file's i_mmap
only after .mmap returns and pages inserted there could escape a racing
zap. After a revoke a CPU access gets SIGBUS.

Only importers that can honour a revoke may attach: peer-to-peer
capable (allow_peer2peer, the scatterlist has BAR1 bus addresses and no
struct pages) and revocable (dma_buf_attach_revocable(): they
invalidate and unmap in bounded time). The NVMe dma-buf I/O path is
both. Kernels without dma_buf_attach_revocable() have no such contract
(move_notify only asks importers to remap as soon as possible), so
there the dma-buf has no importers, only the CPU mmap. The exporter is
dynamic (pin/unpin, a no-op: BAR1 memory never moves), so that no
kernel caches an importer's mapping at attach time, where its unmap
would not reach the exporter.

Built against 7.4 only. dma_buf_attach_revocable(), the
invalidate_mappings rename and enum dma_resv_usage are probed in Kbuild
with fallbacks for older kernels, which have not been compiled.

Tested on an RTX 3050 Laptop (GA107), on a 7.4-rc2 kernel with KASAN
and lockdep, IOMMU in identity mode, with io_uring + NVMe dma-buf reads,
through the export by CUDA address added later in this series. That
shares the dma-buf creation, mapping, pinning and release code with
this ioctl but not its handle loop: libcuda does not issue
NV_ESC_EXPORT_TO_DMABUF_FD on this GPU, so multi-object and batched
exports have not run on hardware. NVMe -> VRAM reads were verified
byte for byte. With the memory freed (cuMemFree, cuMemRelease) while
128 reads were queued, or at points in the middle of a stream, every
read completed without error, and the freed VRAM was not reused: a new
allocation filled before the free stayed untouched. The VRAM stays
allocated while the dma-buf is open (free VRAM did not come back after
the RM free) and is returned when it is closed. A dma-buf whose
exporter exited keeps working, and killing a reader mid-I/O tears it
down. No KASAN or lockdep report. GPU removal (the remaining revoke)
is run on hardware by the test added in the third commit.

These runs used the gpu-prio `preempt 0` policy: on this GPU, master's
default CILP/GFXP preemption policy makes cuCtxCreate fail before any
export (the second channel's compute object allocation returns
NV_ERR_INSUFFICIENT_RESOURCES), with or without this series.

* gsp_route: answer GPU_GET_INFO DMABUF_CAPABILITY as kernel RM does

NV2080_CTRL_GPU_INFO_INDEX_DMABUF_CAPABILITY (0x3d) is answered by
NVIDIA's kernel-side RM, not by GSP-RM: subdevice_ctrl_gpu_kernel.c
returns YES when osDmabufIsSupported(). GSP-RM has no dma-buf and
answers NO, and the GA10x routing passed that through. nvdriver exports
dma-bufs itself (NV_ESC_EXPORT_TO_DMABUF_FD), so answer YES like the
kernel-side RM, on every path that answers the index: GSP-RM's V2
reply, the V2 reply a V1 GET_INFO is translated to, an R620-sized V2
query translated to 580 batches, and nvdriver's native GET_INFO_V2
table.

libcuda 580.178.04 queries this index, but on a GeForce laptop GPU it
still reports CU_DEVICE_ATTRIBUTE_DMA_BUF_SUPPORTED=0 afterwards and
never issues the export ioctl: its decision depends on more than this
answer. This only makes the answer correct.

* uvm: export a CUDA allocation as a dma-buf by GPU address

libcuda only exports a dma-buf through cuMemGetHandleForAddressRange,
and on GPUs it reports CU_DEVICE_ATTRIBUTE_DMA_BUF_SUPPORTED=0 for (a
GeForce RTX 3050 Laptop here) it refuses in user space with
CUDA_ERROR_NOT_SUPPORTED, before asking the kernel. The RM handles that
NV_ESC_EXPORT_TO_DMABUF_FD needs live inside libcuda, so an application
cannot call the ioctl itself.

The UVM node knows them: UVM_MAP_EXTERNAL_ALLOCATION maps (hClient,
hMemory, offset) at a GPU virtual address. Record them in each
ExternalMap (and carry them through uvm_ext_gpu_map_split, the piece
after a hole moving its offset along), and add an nvidia_rs ioctl on
the process's own /dev/nvidia-uvm VA-space fd:

  NV_RS_UVM_EXPORT_DMABUF (0x4e520001)
  { u64 va; u64 size; u32 flags; s32 fd; u32 status; s32 rm_fd; }

[va, va + size) must be page aligned and lie inside one external
mapping; flags bit 0 allows a (shared) CPU mmap. The range resolves to
its RM memory and goes through the same export as
NV_ESC_EXPORT_TO_DMABUF_FD (nv_rs_rmapi_export_dmabuf_object(), a single
extent), so it gets the same lifetime (the dma-buf pins the memory)
and the same authorization: the memory's client must belong to rm_fd,
an RM file the caller holds (or to its control file), the way UVM's
rmCtrlFd names it. The UVM mapping is
not enough on its own: UVM_MAP_EXTERNAL_ALLOCATION also accepts objects
shared through NV_ESC_RM_SHARE, which this export does not. If GPUs'
mappings of the range name different memory, the address is ambiguous
and refused. The lookup takes only the UVM lock (it reads this file's VA
space); the export then resolves the memory again under the RM API lock,
so a mapping changed in between exports memory the caller still owns, or
fails. As for NV_ESC_EXPORT_TO_DMABUF_FD, the fd is installed only once
the reply has been copied out.

tools/nv_rs_dmabuf.h wraps it (nv_rs_export_dmabuf(ptr, size, flags,
&status) finds the UVM and RM fds in /proc/self/fd); tools/
cuda_dmabuf_uvm_export_test.c checks that the dma-buf is the
allocation's VRAM (CPU mmap reads what cuMemcpyHtoD wrote and
cuMemcpyDtoH reads what it wrote, whole and for a sub-range), that bad
ranges and private mmaps are refused, that an export whose reply cannot
be copied back leaves no fd, and that the dma-buf keeps a
freed cuMemMap allocation: an existing CPU mapping still reads its
data, and writes through it never reach a new allocation.

On the RTX 3050 Laptop with io_uring + NVMe dma-buf reads (block layer
support from the io_uring dma-buf series in 7.4; ext4 needs out-of-tree
patches, device-mapper is refused), NVMe reads land in VRAM at the speed
they land in host memory on a Gen3 x4 drive (3.2 GB/s), and at ~75% of
it from a Gen4 x4 drive on another root port (5.1 vs 6.8 GB/s).

tools/dmabuf_unbind_race_test.py (run by tools/dmabuf_unbind_race_run.sh)
exercises the GPU-removal revoke from commit 1 through this export: it
unbinds nvidia_rs from the GPU while an io_uring reader keeps 32 NVMe
reads in flight into an exported buffer, another export carries an
unsignaled sw_sync write fence (signaled HOLD seconds into the unbind),
an RM-call loop runs, and an export loop runs. Its io_uring side is fastsafetensors' io_uring
dma-buf layer (IoUring); the export is its own, the ioctl of
tools/nv_rs_dmabuf.h. The reader exports after the
fenced buffer, so the revoke meets the fence first. On the RTX 3050
Laptop with a 5 s hold (three runs), exports were refused from 9-29 ms
into the unbind, every in-flight read completed with -ENODEV by
24-51 ms (the fenced buffer did not keep the reader's readable), RM
calls kept completing without a failure (slowest call 182 ms) while the revoke waited
for the fence, and the GPU teardown under the RM API lock started right
after the fence was signaled. Lockdep stayed on through the run, with no
KASAN or lockdep report.

---------

Co-authored-by: Arsenova <arsenova@a7snv.com>
2026-12-04 23:05:05 -08:00
2026-12-04 20:50:58 -08:00

nvdriver

the nvidea quadro p2000 offical supported on my laptop the driver has given me display output

What doesn't (on 'GP107') Check Stock 580.196.07 nvdriver 0.2.0 nvidia-smi / NVML works GPU access blocked by the 'OS' CUDA cuInit ok rc=100 no CUDA-capable device CUDA context (launcher) — rc=999 unknown Vulkan Quadro P2000 'none' D2D / H2D / D2H / memset 42.0 / 12.3 / 12.4 / 87.8 GB/s — (no device) NVENC API 13.0 (needs 13.1) same, unusable

image

Platform: This is the Linux driver repository. For Windows, see nvdriver/nvdriver-windows.

I am taking applications for co-maintainer, if you have been contributing and wish to help maintain this project, please reach out. eric@quixi.ai

nvdriver (nvidia_rs.ko) is a clean-room, open-source #![no_std] Rust Linux kernel driver for NVIDIA GPUs. The goal is a full drop-in replacement for NVIDIA's proprietary kernel driver across core Linux hardware support, CUDA compute, 3D graphics (Vulkan/OpenGL), and Linux desktop video output (Wayland/X11/KMS), without the software restrictions NVIDIA ships in the closed driver.

It works with unmodified NVIDIA userspace (libcuda.so, libnvidia-ml.so, nvidia-smi, NVENC/NVDEC, PyTorch, cuDNN, NCCL, llama.cpp, Vulkan/OpenGL) and ships both standalone companion modules (nvidia_rs_modeset.ko, nvidia_rs_drm.ko, nvidia_rs_peermem.ko) and CONFIG_MODVERSIONS bridges for stock nvidia-uvm.ko and nvidia-modeset.ko/nvidia-drm.ko. One codebase covers pre-GSP GPUs (Maxwell, Pascal, Volta) alongside Turing, Ampere, Hopper, Ada Lovelace, Blackwell, and Rubin.

On Tesla V100 (GV100), nvdriver also supports opt-in HBM2 overclocking to 1107 MHz (V100S factory spec, +26.2% memory bandwidth, 1,041.7 GB/s per card / 8.33 TB/s across 8x V100) using v100_hbm_ndiv=82, along with dynamic P0 boost (1290 MHz default / 1425 MHz configurable, 1380 MHz XBAR, 1 Hz thermal guard) and live nvidia-smi / hwmon telemetry. The V100 HBM2 clock unlock builds on the hardware work of arikamidotnet and FBR-ROM/FBR-RAM-Downloader.


Goals

  • Core Linux driver: Native #![no_std] Rust bring-up for Maxwell through Blackwell and Rubin. Handles PCI/MMU/Pre-GSP and GSP-RM boot, nvidia-smi/NVML, /sys/class/hwmon sensors, clocks/power/thermals, NVENC/NVDEC, multi-GPU P2P/NVLink/RDMA, S3/RTD3 suspend, and both x86_64 and arm64.
  • CUDA and compute: Drop-in support for unmodified libcuda.so, UVM, PyTorch, cuDNN, NCCL, and llama.cpp, matching or beating the proprietary driver where hardware locks can be removed.
  • 3D graphics (Vulkan and OpenGL): Full hardware-accelerated rendering and compute with unmodified Vulkan and OpenGL stacks, including headless and PRIME render offload on datacenter and mining cards.
  • Linux desktop (video output): Native display output for Wayland and X11 through nvidia_rs_modeset.ko and nvidia_rs_drm.ko: VBIOS DCB connector enumeration, KMS CRTC/plane/encoder pipelines, DP/HDMI/eDP link training, EDID, hotplug, and VRR/G-Sync on display-capable cards.

What It Does Today

  • Unmodified userspace compatibility: Runs stock libcuda.so, libnvidia-ml.so, nvidia-smi, libnvidia-encode.so, libnvcuvid.so, Vulkan/OpenGL userspace, PyTorch, cuDNN, NCCL, and llama.cpp, plus stock nvidia-uvm.ko and nvidia-modeset.ko/nvidia-drm.ko via version-aware bridges.
  • No artificial software locks: Enables PCIe and Dynamic BAR1 P2P (RMDynBar1P2PEnable=1 + RMDisableFeatureDisablement=1, plus optional PCIe P2P Atomics), Resizable BAR1 by default, native Linux dma-buf + P2PDMA / GPUDirect RDMA, unrestricted NVENC sessions and telemetry, full compute on mining cards (CMP 100-210, 170HX, 90HX, 70HX, 50HX, 40HX, 30HX, P102-100), opt-in SM Speed-Select FP32-accumulate Tensor unlock (unlock_tensor_fp32_acc=1), unprivileged hardware profiling (unpriv_profiling=1 by default for non-root ncu/nsys/CUPTI), zero-reboot ECC toggle (disable_ecc=1), and vGPU/SR-IOV without CPUID or GRID licensing timers.
  • Opt-in HBM2/HBM2e and GDDR5X memory tuning: Supports live runtime-writable HBM2 clock scaling on V100 (v100_hbm_ndiv=82 for 1107 MHz / +26.2% bandwidth, stock 877.5 MHz by default for safety across all cards), multi-gen HBM2/HBM2e profiles for P100 and A100 (p100_hbm_ndiv, ga100_hbm_ndiv, verified with tools/hbm_gate.py), and Pascal GP102/GP104 GDDR5X timing profiles (gddr5x_timing_profile), with per-partition lock checks, automatic rollback on error, and clean restore on unload.
  • Native telemetry (nvidia-smi + /sys/class/hwmon): Exposes per-GPU Linux hwmon sensors (temp1_input, power1_average, in0_input, gpc_clock_mhz, mem_clock_mhz, gpu_util_pct, mem_util_pct for lm-sensors, btop, nvtop, Prometheus node_exporter) alongside NVML/RMAPI telemetry (PROM BIT VBIOS version, NV_PPWR_PMU_IDLE_COUNT GPU/memory utilization, and PMGR I2C INA3221 power readings).
  • x86_64 and ARM64 PCIe (ARCH=arm64): Builds for x86_64-unknown-none and aarch64-unknown-none (-C target-feature=-neon,-fp-armv8) with explicit non-coherent DMA cache sync (dma_sync_single_for_cpu/device) for ARM64 PCIe boards (RK3588, Ampere Altra, Apple Silicon Linux).
  • Pre-GSP and GSP-RM in one driver: Drives Maxwell, Pascal, and Volta natively in Rust alongside Turing, Ampere, Hopper, Ada Lovelace, Blackwell (620.70.06 GSP-RM default, 580 compat), and Rubin (GR100).
  • Kernel ABI hygiene: #![no_std] Rust core linked into a thin Linux C shim, audited on every build for zero GOT relocations, zero SIMD/x87, zero memcpy/memset/memmove/strlen leaks, zero unwind sections, stack frames <= 1,024 bytes, and CONFIG_MITIGATION_RETHUNK, CONFIG_MITIGATION_SLS, CONFIG_X86_KERNEL_IBT, and CONFIG_CALL_PADDING compatibility across Linux 5.15–7.0+.
  • Live Linux desktop video output & 3D gaming (GA102): Verified Dual-4K@60Hz GNOME Wayland desktop (DP-2 + HDMI-1), smooth OpenGL (Xonotic at 250 fps), and Vulkan + sparse resources (Counter-Strike 2) on physical RTX 3080 Ti via nvidia_rs.ko + nvidia_rs_modeset_bridge.ko backing stock nvidia-modeset.ko/nvidia-drm.ko modeset=1, alongside standalone nvidia_rs_modeset.ko / nvidia_rs_drm.ko KMS/DRM modules.
  • Tested on 8x physical V100s: Verified side-by-side against stock NVIDIA 580.178.04 on 8x physical Tesla V100-SXM2-32GB (256 GiB VRAM): 77/77 CUDA Parity Suite checks, 8-GPU PyTorch/NCCL AllReduce (59.71 GB/s BusBW, max_err = 0.0), 8.33 TB/s aggregate HBM2 STREAM Triad (at 1107 MHz), multi-GPU FP16/FP32 GEMM and llama.cpp, 25.781 Gbps NVLink 2.0, H.264/HEVC NVENC & NVDEC, S3/S4 suspend/resume, and automatic Xid 31 fault recovery with clean module unload.

Performance vs. Proprietary NVIDIA 580.178.04 (Tesla V100-SXM2-32GB)

Benchmark Proprietary 580.178.04 nvdriver (1107 MHz HBM2) Delta
PyTorch STREAM Triad (768 MiB) 821.85 GB/s 1,041.72 GB/s +26.8%
HBM2 D2D Copy (512 MiB) 819.01 GB/s 1,013.65 GB/s +23.8%
FP16 Tensor Core GEMM (8192³) 97.69 TFLOPS 107.17 TFLOPS +9.7%
FP32 GEMM (8192³) 14.18 TFLOPS 14.37 TFLOPS +1.3%
Memory-Bound LayerNorm + GELU 2.612 ms 2.126 ms 1.23x faster
llama.cpp Prompt Eval (pp512) 31,067 tok/s 34,884 tok/s +12.3%
Transformer Layer Fwd + Bwd 13.245 ms 12.885 ms +2.7% faster
CUDA Graph 50-op Replay 76.17 µs 80.20 µs 95.0% parity
PCIe Pinned H2D / D2H (256 MiB) 12.39 / 13.16 GB/s 12.40 / 13.16 GB/s 100% parity
2-GPU NVLink 2.0 NV2 Bidir / Unidir 94.0 / 48.1 GB/s 96.98 / 48.49 GB/s +3.2% (25.781 Gbps)

Bare-Metal 8x Tesla V100-SXM2-32GB (geodd03, 256 GiB VRAM)

Workload Measured on nvidia_rs.ko
8x V100 HBM2 STREAM Triad (1107 MHz) 8,334.1 GB/s (8.33 TB/s) aggregate (1,041.3–1,041.9 GB/s per GPU)
8-GPU PyTorch/NCCL AllReduce (FP16 256 MiB) 59.71 GB/s BusBW (34.12 GB/s AlgBW, max_err = 0.0)
8-GPU PyTorch DDP Transformer (92.4M, FP16 AMP) 497,072 tok/s (970.8 samples/s, 275.4 TFLOPS eff., 0.0e+00 weight parity)
8-GPU Simultaneous FP16 / FP32 GEMM (8192³) 776.14 TFLOPS FP16 / 103.44 TFLOPS FP32 aggregate (1290 MHz, 97.00–97.03 TFLOPS/GPU; 106.8 TFLOPS/GPU @ 1425 MHz)
8-GPU Layer-Split llama.cpp (-sm layer, 256 GiB) 30,169.8 tok/s pp512, 492.28 tok/s tg128 across all 8 GPUs

See docs/PARITY_AND_UNLOCKS.md for the full 3-way breakdown comparing stock 877.5 MHz vs. unlocked 1107 MHz HBM2 (v100_hbm_ndiv=82).


GPU Support Matrix

Every discrete NVIDIA GPU series this driver targets, ordered newest (Rubin) to oldest (Maxwell 1), split by silicon family and whether the card has physical display outputs.

  • Core: kernel bring-up, Pre-GSP/GSP-RM boot, nvidia-smi/NVML, hwmon, clocks and power
  • CUDA: compute, UVM, PyTorch, llama.cpp, NCCL
  • Graphics: Vulkan and OpenGL 3D rendering, including headless/PRIME offload
  • Display: Linux desktop video output (KMS/DRM, DP/HDMI/eDP, Wayland/X11)
  • vs. Proprietary: measured speedup over the proprietary NVIDIA driver

Legend: (blank) = supported target, not started · 25% 25% = offline HAL/firmware wired · 50% 50% = active silicon bring-up · 75% 75% = working on silicon (some dies or partial features) · 100% 100% = verified on silicon · n/a = no physical video outputs.

GPU Series Arch / Silicon Core CUDA Graphics Display vs. Proprietary
Rubin Datacenter (GR100) Rubin (GR100) 25% offline n/a
Blackwell Datacenter (GB300, GB200, B300, B200, B100) Blackwell 1 (GB100/GB102) 25% offline 25% offline n/a
RTX PRO Blackwell Server (RTX PRO 6000 Blackwell Server) Blackwell 2 (GB202) 25% offline 25% offline 25% offline n/a
RTX PRO Blackwell Workstation (6000–500, Desktop & Laptop) Blackwell 2 (GB202–GB207) 25% offline 25% offline 25% offline 25% offline
GeForce RTX 50 Series (5090–5050, Desktop & Laptop; GB10) Blackwell 2 (GB202–GB207/GB10B) 25% offline 25% offline 25% offline 50% bring-up
Hopper Datacenter (GH200, H200, H100, H800, H20) Hopper (GH100) 25% offline 25% offline n/a
Ada Datacenter Headless (L20, L4, L2) Ada (AD104/AD107) 25% offline 25% offline 25% offline n/a
Ada Workstation & Display Datacenter (L40S, L40, RTX 6000–500 Ada) Ada (AD102–AD107) 25% offline 25% offline 25% offline 25% offline
GeForce RTX 40 Series (4090–4050, Desktop & Laptop; 4090, 4060 verified) Ada (AD102–AD107) 75% partial silicon 75% partial silicon 25% offline 25% offline
Ampere Datacenter HBM (A100, A800, A30) Ampere (GA100) 25% offline 25% offline n/a
Ampere Datacenter PCIe Headless (A16, A10, A10G, A2) Ampere (GA102/GA107) 25% offline 25% offline 25% offline n/a
Ampere Workstation & Display Datacenter (A40, RTX A6000–A400; RTX A4500 verified) Ampere (GA102–GA107) 75% partial silicon 75% partial silicon 25% offline 25% offline
GeForce RTX 30 Series (3090 Ti–3050, RTX 2050/MX570; 3090, 3080 Ti, 3050/3050 Ti Laptop verified) Ampere (GA102–GA107) 75% partial silicon 75% partial silicon 75% partial silicon 75% partial silicon
Ampere Mining (CMP 170HX, 90HX, 70HX) Ampere (GA100/GA102/GA104) 50% bring-up 25% offline 25% offline n/a
Tesla T4 Turing (TU104) 50% bring-up 25% offline 25% offline n/a
Quadro RTX / TITAN RTX / T-Series (RTX 8000–3000, T1200–T400) Turing (TU102–TU117) 50% bring-up 25% offline 25% offline 25% offline
GeForce RTX 20 Series (2080 Ti–2060, Desktop & Laptop) Turing (TU102–TU106) 50% bring-up 25% offline 25% offline 25% offline
GeForce GTX 16 Series (1660 Ti–1630, Desktop & Laptop; MX550/MX450) Turing (TU116–TU117) 50% bring-up 25% offline 25% offline 25% offline
Turing Mining (CMP 50HX, 40HX, 30HX) Turing (TU102/TU106/TU116) 25% offline 25% offline 25% offline n/a
Tesla V100 (SXM2, SXM3, PCIe 16GB/32GB, V100S) Volta (GV100) 100% verified 100% verified 25% offline n/a +26.8% BW / +9.7% FP16
Quadro GV100 / TITAN V Volta (GV100) 75% partial silicon 75% partial silicon 25% offline 25% offline
CMP 100-210 Volta (GV100) 75% partial silicon 75% partial silicon 25% offline n/a
Tesla P100 (SXM2, PCIe 12GB/16GB) Pascal (GP100) 50% bring-up 50% bring-up n/a
Tesla P40 / P6 / P4 Pascal (GP102/GP104) 50% bring-up 50% bring-up n/a
Quadro Pascal & TITAN (Quadro GP100, P6000–P400, TITAN Xp, TITAN X) Pascal (GP100–GP107) 25% offline 25% offline
GeForce GTX 10 / GT 10 Series (1080 Ti–1010, Desktop & Laptop; MX350–MX150) Pascal (GP102–GP108) 50% bring-up 25% offline
Pascal Mining (P102-100, P104-100, P106-100, P106-090) Pascal (GP102–GP106) 50% bring-up 25% offline 25% offline n/a
Tesla Maxwell (M60, M40, M10, M6, M4) Maxwell 2/1 (GM20x/GM107) 50% bring-up 25% offline n/a
Quadro Maxwell & TITAN (M6000–M520, K2200–K620, NVS 810, GTX TITAN X) Maxwell 2/1 (GM20x/GM107) 50% bring-up 25% offline
GeForce GTX 900 Series (980 Ti–950, Desktop & Laptop) Maxwell 2 (GM200–GM206) 50% bring-up 25% offline
GeForce GTX 750 Ti / 750 / 745 & 800M/900M (MX130/MX110) Maxwell 1 (GM107–GM108) 25% offline

Notes:

  • vs. Proprietary shows real-silicon deltas vs. stock NVIDIA drivers. On Tesla V100 (v100_hbm_ndiv=82), that is +26.8% STREAM Triad HBM2 bandwidth, +9.7% FP16 Tensor Core GEMM, and +12.3% llama.cpp prompt eval. Other GPUs will fill in as head-to-head benchmarks are run.
  • Tegra / Jetson and older GPUs: Early Jetson Xavier (T194 / GV11B) scaffolding has started (#355, #356); Jetson Orin (T234) and Thor (T264) are not supported yet. Pre-Maxwell GPUs (Kepler, Fermi, Tesla) are outside the 580.x driver scope.
  • To test a card on real hardware, see docs/GPU_BRINGUP_GUIDE.md. For the full 43-chip tuple table, verified workload digests, and disassembly notes on unlocked restrictions, see docs/PARITY_AND_UNLOCKS.md.

Quick Start

For a step-by-step distro install guide (Ubuntu/Debian, Arch/CachyOS, Fedora, NixOS, Secure Boot, troubleshooting, and rollback), see docs/INSTALL.md.

Prerequisites

  • Linux x86_64 or arm64 (aarch64) with kernel headers (/lib/modules/$(uname -r)/build)
  • Rust toolchain with the x86_64-unknown-none (or aarch64-unknown-none) target
  • Existing NVIDIA userspace libraries (libcuda.so, nvidia-smi, etc.)

Build & Validate

# Build nvidia_rs.ko and run the 36-step unit, oracle, QEMU guest & kernel-hygiene gate
sh tools/validate_all.sh

# ARM64 / SBC PCIe build (RK3588, Ampere Altra, Apple Silicon Linux)
ARCH=arm64 make modules

# Optional: x86_64 Unicorn binary oracles & companion module bridges
python3 tools/mock_gv100_diff.py
make uvm-bridge && python3 tools/check_uvm_symbol_conformance.py
make modeset-bridge && python3 tools/check_modeset_symbol_conformance.py

Install & Module Options

Run ./install.sh to install with runtime_engines=1, pci_target=*, and BIND_DEV_NODES=1. It extracts pre-GSP firmware packs, copies GSP blobs, writes /etc/modprobe.d/nvdriver.conf and udev rules, handles Secure Boot MOK signing, and on Volta GV100 / Tesla V100 installs pinned volta-forever for CUDA 13 compatibility (pass SKIP_VOLTA_FOREVER=1 to skip). Any MODPROBE_ARGS you pass are saved to /etc/modprobe.d/nvdriver.conf so they persist across reboots. ./uninstall.sh unloads the modules and removes the files the installer wrote (REMOVE_FIRMWARE=1 also deletes /lib/firmware/nvidia-rs).

Or set options directly in /etc/modprobe.d/nvdriver.conf:

options nvidia_rs pci_target=* runtime_engines=1

Key module parameters:

  • v100_hbm_ndiv=0 (default = stock 877.5 MHz, runtime-writable 0644): GV100 / CMP 100-210 HBM2 clock divider. Opt in to 82 (1107 MHz V100S spec / +26.2%), 80 (1080 MHz / +23%), or 78 (1053 MHz / +20%). One V100-PCIe-32GB field report saw hangs or NaN results at 1107 and 1053 MHz while stock clocks ran clean; stability varies by card (Issue #76).
  • v100_hbm_ndiv_map="" (optional, runtime-writable 0644): Per-BDF GV100 HBM2 NDIV overrides (e.g. v100_hbm_ndiv_map="0000:81:00.0=67,82:00.0=82"), falling back to v100_hbm_ndiv.
  • p100_hbm_ndiv=0 / ga100_hbm_ndiv=0 (opt-in, runtime-writable 0644; plus p100_hbm_ndiv_map / ga100_hbm_ndiv_map): Multi-gen HBM2/HBM2e clock dividers for GP100 and GA100 (see tools/hbm_gate.py).
  • gddr5x_timing_profile=0 (opt-in, runtime-writable 0644; plus gddr5x_timing_map): Runtime GDDR5X memory timing controller for Pascal GP102/GP104.
  • v100_p0_gpc_ndiv=190 (default, runtime-writable 0644, auto-capped to 172 / 1290 MHz unless Level-3 HS voltage scaling succeeds): GV100 dynamic P0 GPC NAFLL divider; writable live via /sys/module/nvidia_rs/parameters/v100_p0_gpc_ndiv (plus v100_p0_gpc_ndiv_map for per-BDF overrides). The parameter always reads back the requested value; when the cap lowers a request, dmesg shows a GV100 P0 GPC NDIV request capped line with the requested and applied NDIV/MHz once per distinct capped request on each GPU (an uncapped request in between re-arms it) (Issue #367).
  • v100_p0_volt_uv=0 (default, experimental): Optional GV100 LOGIC rail voltage target in µV (clamped to [800_000, 1_050_000] µV in <= 25 mV steps; 0 keeps VBIOS boot voltage and caps GPC at 1290 MHz).
  • unlock_ada_tensor=0 (alias unlock_tensor_fp32_acc=0, opt-in): Multi-gen SM Speed-Select FP32-accumulate Tensor Core unlock (PLM-guarded).
  • dyn_bar1_p2p=1 (default): Enables Dynamic BAR1 P2P (RMDynBar1P2PEnable=1 + RMDisableFeatureDisablement=1 + RMForceP2PType=2) in the GSP-RM registry alongside EnableResizableBar=1.
  • unpriv_profiling=1 (default): Allows non-root CUPTI / ncu / nsys hardware performance counters (RMRestrictProfilingToAdminUsers=0).
  • disable_ecc=0 (opt-in): Zero-reboot ECC disable toggle across RMAPI, UVM, and GSP-RM without flashing InfoROM.
  • live_pci_irq=1 (default): Enables storm-guarded hardware MSI-X/PCI IRQ handling across PFIFO, PGRAPH, PMU, THERM, and HUB/MMU (0 to disable).
  • enable_resizable_bar=1 (default): Expands BAR1 to the largest supported ReBAR aperture automatically.
  • force_p2p=0x11 (default): Enables PCIe P2P Read+Write (0x211 adds PCIe P2P Atomics).
  • force_pcie_gen=0 (opt-in, runtime-writable 0644; plus force_pcie_gen_map): Overrides target PCIe link generation, clamped to upstream bridge LNKCAP.
  • vram_limit_mb=0 (opt-in): Caps exposed VRAM size in MiB (useful for testing or isolating bad memory regions).
  • idle_pstate=0 (opt-in, runtime-writable 0644; plus idle_pstate_delay_s=5, idle_pstate_gpc_khz=0): Activity-wake idle clock governor.
  • hwmon_poll_ms (runtime-writable 0644): Cache TTL in ms for on-demand GSP-RM hwmon telemetry polling.
  • gsp_abi=620 (default): Selects GSP-RM 620.70.06 / 620.73.04 MCTP+NVDM framing for Turing–Blackwell–Rubin (580 for 580.178.04 compat).
  • driver_version=auto (default) & strict_version_check=0 (default): Automatically negotiates userspace NVML/libcuda version strings per open file (driver_version=<ver> pins a specific string; strict_version_check=1 restores strict stock version matching).
  • ga10x_gsp=1 (default): Boots Turing through Blackwell (TU10x/TU11x, GA100/GA10x, AD10x, GH100, GB10x/GB20x) on GSP-RM 580.178.04 through ga10x_gsp.rs regardless of gsp_abi; with driver_version=580.196.07, TU102/TU116 and GA102-class GPUs boot GSP-RM 580.196.07 instead. Set 0 to use gsp_bringup.
  • ga10x_events=1 (default): Delivers RM events from GR and copy-engine non-stall interrupts on GA10x and GV100 so blocking-sync waits wake right away instead of hitting libcuda's 100 ms fallback timer.
  • system_memory_pool_retain_mb=0 (default): Trims cached system-memory pages on client close so MemAvailable stays accurate.

Bare-Metal Setup (GV100 / Pre-GSP)

  1. Extract signed GV100 firmware from your installed stock 580.178.04 package (auto-detects /usr/src/nvidia-srv-580.178.04/ and /usr/src/nvidia-580.178.04/):
    sudo python3 tools/extract_gv100_firmware.py --out /lib/firmware/nvidia-rs/580.178.04/gv100.fw
    
    If the host has a different stock version installed (for example 580.196.07), fetch the 580.178.04 object first. This unpacks one file from NVIDIA's installer without running or installing it, and verifies its digest:
    sh tools/fetch_580_kernel_object.sh
    sudo python3 tools/extract_gv100_firmware.py --rm-object target/stock-580.178.04/nv-kernel.o_binary --out /lib/firmware/nvidia-rs/580.178.04/gv100.fw
    
  2. Keep nvidia-modprobe from loading stock nvidia.ko over nvidia_rs (plain blacklist is bypassed by explicit modprobe nvidia; boot clean so stock nvidia.ko does not touch the GPU first):
    # /etc/modprobe.d/nvidia-blacklist.conf
    install nvidia /bin/false
    install nvidia_uvm /bin/false
    
  3. Load nvidia_rs with live runtime engines (for example via ./install.sh with MODPROBE_ARGS="pci_target=* runtime_engines=1"), and run unmodified nvidia-smi / CUDA workloads through tools/rmapi_namespace_launcher.py (which bind-mounts /sys/module/nvidia_rs -> /sys/module/nvidia so NVML sees /sys/module/nvidia/initstate == live).

Live /sys/class/hwmon Telemetry & Runtime Clock Tuning

Every GPU exposes a Linux hwmon sensor node (name = nvdriver) readable by lm-sensors, btop, nvtop, and Prometheus node_exporter. GV100 clocks can be adjusted live without reloading nvidia_rs.ko:

# Read live per-GPU sensors directly from sysfs (no libnvidia-ml.so required)
for h in /sys/class/hwmon/hwmon*; do
  [ "$(cat "$h/name" 2>/dev/null)" = "nvdriver" ] && \
    echo "$h: $(( $(cat $h/temp1_input)/1000 ))C $(( $(cat $h/power1_average)/1000000 ))W gpc=$(cat $h/gpc_clock_mhz)MHz mem=$(cat $h/mem_clock_mhz)MHz util=$(cat $h/gpu_util_pct)%"
done

# Tune GV100 GPC NAFLL clock live (takes effect within 1 s, no reload)
echo 160 | sudo tee /sys/module/nvidia_rs/parameters/v100_p0_gpc_ndiv   # 1200 MHz
echo 172 | sudo tee /sys/module/nvidia_rs/parameters/v100_p0_gpc_ndiv   # 1290 MHz

Safe Live Testing in a Disposable VFIO VM

# Single-GPU CUDA Parity Suite v19 on a VFIO-bound Tesla V100
sudo python3 tools/vm/run_vfio_guest.py --bdf 0000:b3:00.0 --driver rust

580.178.04 Subsystem Parity & Kernel Modules

nvdriver ships 4 standalone Linux kernel modules (nvidia_rs.ko with integrated UVM, nvidia_rs_modeset.ko, nvidia_rs_drm.ko, and nvidia_rs_peermem.ko), covering 100% of Linux UVM ioctls (73/73), 2,096/2,096 RM controls dispatched, and 1,090+ passing Rust unit/oracle tests:

Domain Ported Subsystems (src/nvidia/src/ & kernel-open/)
Compute, Scheduling & Sync CILP / GFXP preemption (cilp_preempt.rs), Persisting L2 EVICT_LAST (l2_cache.rs), Explicit Sync dma_fence timelines 0x00da (sync_timeline.rs), NVIDIA MPS (UVM_REGISTER_MPS_*), Async CE VRAM/ECC Scrubber (mem_scrub.rs)
Memory, UVM & P2P 100% Linux UVM ioctls (73/73), Linux HMM / SVA-ATS (uvm/hmm.rs), Thrashing/Prefetch heuristics (uvm/perf_heuristics.rs), Access Counter Notify Buffer 0xc365, Native dma-buf P2PDMA (NV_ESC_EXPORT_TO_DMABUF_FD), nvidia_rs_peermem.ko
Telemetry, Debug & Reliability HWPM (0x90cc/0xb0cc/0xb1cc/0xb2cc) & cuda-gdb (0x83de/0x83df) + 13 UVM_TOOLS_* ioctls, SPI/PROM InfoROM (inforom_spi.rs), ECC Poison Xid 94/95 containment (ecc_poison.rs), RC Watchdog (rc_watchdog.rs), FECS Ctxsw Timeout Dump (ctxsw_dump.rs), GSP CrashCat decoder (crashcat.rs), stock NVRM: Xid logs, full /proc/driver/nvidia/ tree
Power, Thermals & Interconnect Full PMU task stack VFE->THERM->VOLT->CLK->PMGR->PERF (pmu_task_stack.rs), LPWR GR-PG/MSCG/ELPG (lpwr_pg.rs), RTD3 & S3 VRAM preservation (rtd3_pm.rs), Fan 2.0/3.0 PWM (fan_cooler.rs), PCIe Gen1–5 & ASPM (pcie_bif.rs), NVLink 2.0 telemetry (nvlink_telemetry.rs), NVLink-C2C (nvlink_c2c.rs), NVSwitch/NVLS Multicast 0x00fd (nvls_multicast.rs)
Display, Media & Datacenter nvidia_rs_drm.ko (GEM/PRIME/KMS /dev/dri/renderD*), nvidia_rs_modeset.ko (/dev/nvidia-rs-modeset), EDID/vblank (display_kms.rs), DP AUX/DPCD (dp_aux.rs), VRR/G-Sync (vrr_gsync.rs), HDCP 1.x/2.2 (hdcp.rs), ACPI NBCI mux (acpi_nbci.rs), Video Falcons NVDEC/NVENC/SEC2 (video_falcon.rs), OFA/NVJPG (ofa_nvjpg.rs), MIG 0xc637/0xc638 & IMEX (mig_fabric.rs), SR-IOV/vGPU 0xa080–0xa084 (sriov_vgpu.rs), Live GSP-RM queue/LIBOS/CC (gsp_live.rs)

Field Reports

Independent installs on real hardware: environment, measurements, and the rough edges hit along the way. Host identifiers redacted.

V100-SXM2-32GB, Ubuntu 26.04, kernel 7.0.0-44 — full report

Single card, bare metal, a 251B-class MoE (IQ3_S, 84 GiB, ~45 GiB of experts streamed) at 256k context, --kv k8v4, 4k-token prompt, warm cache, two to three runs per arm:

Arm decode tok/s prefill tok/s
stock 580.178.04, experts resident 44.42 798.5
nvidia_rs, resident, HBM 1107 43.72 / 41.98 815.3 / 818.4
stock, paging 23.74 / 22.68 133.3 / 264.7
nvidia_rs, paging 21.93 / 22.67 / 22.50 266.6 / 274.0 / 275.2

The workload's memory strategy dominates the driver. Paging versus resident is worth ~1.9x decode and ~3x prefill; the driver stays inside the noise band in both strategies, and the only lever with a consistent sign is the HBM unlock (~5%, resident arm).

Clock behaviour. Under load stock holds 1530 MHz at 100% utilisation and nvidia_rs holds 1290 MHz — the driver is 19% lower and still lands within noise, so SM clock is not the binding constraint here. 1290 is a ceiling, not a choice: above v100_p0_gpc_ndiv=172 the divider needs v100_p0_volt_uv, and every RM_PMU_UNIT_VOLT RPC answers NV_ERR_NOT_SUPPORTED because the PMU task stack (VFE -> THERM -> VOLT -> ...) is never executed. PMGR_LOAD on the same path returns 0x0, so the transport is fine and this is a missing-prerequisite problem, not a payload one.

The report also covers the two installer gaps this install exposed (both since fixed upstream), the flaky first start after boot, power.draw reading N/A, and the empty process table (since wired for Pre-GSP in #354; utilization.gpu does work — it tracks load correctly; an earlier note claiming otherwise was sampled during model load).

RTX A4500 (GA102GL, 20 GB), NixOS 27.05, kernel 7.3.6 — full report

Single card, bare metal (#504), tested on default ga10x_gsp=1 with 580.178.04 GSP firmware and 580.178.04 userspace (runtime_engines=1), against stock 620.73.04 with the same llama.cpp binary (ee4671584) and GGUF weights (-ngl 99 -r 3 -fa on -b 4096 -ub 2048):

Model KV Test Stock 620.73.04 nvidia_rs (580.178.04)
Qwen3.8-27B UD-Q3_K_XL (12.23 GiB) q4_0 pp512 / tg128 1038.42 / 32.31 t/s 1064.87 / 32.73 t/s
Qwen3.8-27B UD-Q3_K_XL (12.23 GiB) q4_0 pp4096 / tg128 1033.17 / 31.54 t/s 1061.39 / 32.24 t/s
gemma-4-26B-A4B IQ4_NL (12.66 GiB) q8_0 pp512 / tg128 3454.47 / 104.28 t/s 3497.15 / 105.09 t/s

GSP-RM booted in 1.75 s (20470 MiB FB, nvidia-smi, hwmon, and CUDA Driver API all passed) and unloaded cleanly (fwsec-sb + booter-unload, WPR2 hi=0). The report also documents two edge cases: R620 userspace controls returning 0x1f against 580.178.04 GSP-RM (cuInit=100), and ga10x_gsp=0 + gsp_abi=620 timing out on 620.73.04/gsp_ga10x.bin.


Documentation


Repository Layout

.
├── src/
│   ├── common/abi/           # Stable C/Rust ABI definitions (nv_rs_abi)
│   └── nvidia/
│       ├── src/              # Core #![no_std] Rust driver (nv_rs_core): gpu, mmu, fifo, rmapi, uvm
│       └── kernel/           # Linux kernel FFI & live GV100/GSP bring-up (nv_rs_kernel)
├── kernel-open/
│   ├── nvidia/               # Minimal Linux PCI/chardev/DMA/hwmon/dmabuf C shim -> nvidia_rs.ko
│   ├── nvidia-modeset/       # Standalone /dev/nvidia-rs-modeset module -> nvidia_rs_modeset.ko
│   ├── nvidia-drm/           # Standalone Linux DRM GEM/PRIME/KMS module -> nvidia_rs_drm.ko
│   ├── nvidia-peermem/       # Standalone GPUDirect RDMA peermem bridge -> nvidia_rs_peermem.ko
│   ├── uvm_bridge/           # 82-symbol version-aware UVM bridge -> nvidia_rs_uvm_bridge.ko
│   └── modeset_bridge/       # nvidia_get_rm_ops bridge -> nvidia_rs_modeset_bridge.ko
├── docs/                     # Install/bring-up guides, parity tables, assets & write-ups
├── tools/                    # Validation gate, Unicorn binary oracles, VFIO VM harness & parity suites
├── dkms.conf                 # DKMS packaging for automatic rebuilds across kernel upgrades
├── install.sh                # Installer with Secure Boot MOK signing support
└── uninstall.sh              # Reverses install.sh

Known Limitations & Roadmap

  • Linux desktop video output: Native display output (nvidia_rs_modeset.ko + nvidia_rs_drm.ko) is in progress. VBIOS DCB connector enumeration (#189) and Vulkan 1.4 compute/transfer + DRM/NVKMS UAPI parity (#266) are underway; next up are KMS CRTC/plane/connector wiring, DP/HDMI/eDP link training, EDID/HPD, and live monitor scanout.
  • Multi-arch silicon validation: Physical silicon parity is verified on Tesla V100 (GV100), and live bring-up/CUDA is verified on RTX 4090 (AD102), RTX 4060 (AD107), RTX 3090 / RTX 3080 Ti / RTX A4500 (GA102/GA102GL), and RTX 3050 / 3050 Ti Laptop (GA107M). Other Maxwell through Rubin dies have HALs and GSP-RM paths verified offline (119/119 mock_gv100_diff.py + 19/19 oracle_gsp_620.py) and are going through community hardware bring-up.
  • GV100 dynamic V/F above 1290 MHz: Raising NV_THERM_VID0_PWM_1 (0x20344, Priv Level 3) above VBIOS boot voltage (~0.72 V) for 1425–1530 MHz across all bins needs the full PMU VFE + THERM + CLK + VOLT bring-up. Until then, nvidia_rs.ko caps GPC to 1290 MHz whenever voltage scaling is inactive.
  • Discrete PCIe GPUs first (x86_64 and arm64): Early Jetson Xavier (T194 / GV11B) SoC scaffolding has started (#355, #356); Jetson Orin and Thor are not supported yet.

Credits & Acknowledgments


Star History

Star History Chart
Description
No description provided
Readme MIT 157 MiB
Languages
Rust 65.3%
Python 17.9%
C 15%
Shell 0.7%
Makefile 0.5%
Other 0.4%