Files
nvdriver/src/nvidia/kernel
BlivionIaG dfda0a29a4 dma: device-owned coherent DMA contexts for GV11B platform GPUs (#606)
Add nv_rs_dma_context_create_dev(struct device *, bits, **) and
LinuxDma::from_device so Tegra194 GV11B platform GPUs, which have no
nv_rs_pci lease, can own a coherent DMA context.

ctx->pci is now optional. Creation, close and force_close share
context_init/context_destroy/context_release_owner: a PCI-owned context
releases its DMA user count and PCI reference exactly as before, a
device-owned context drops its get_device() reference with put_device().
Removal checks go through context_removed(), which consults
nv_rs_pci_is_removed only when ctx->pci is set. The PCI path keeps its
check order and errno values (-EINVAL, -ENODEV, -ERANGE, -ENOMEM).

The dma-mock fixture models get_device/put_device and covers the
device-owned lifecycle, every create failure path, force_close, and
independence from PCI removal state.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-12-05 07:20:57 -08:00
..

Linux 5.15 isolated control integration (protocol2)

make modules builds kernel-open/nvidia_rs.ko. It links the real nv-rs-abi and
nv-rs-core crates through a freestandingRust staticlib and LTO, then retains
reachable exported FFI with ld-r. No CONFIG_RUST needed. Soft-float/no-SSE
x86_64-unknown-none core, kernel code model, static relocations, no redzone,
frame pointers and panic=abort are explicit. Panic emits UD2. Empty unwind and
LLVMmetadata sections are discarded. Object validation rejects SIMD/x87,
unsupportedGOT relocations, unexpected undefinedsymbols, unwind, redzone or
individual stack reservations over1024bytes.

The C adapter registers only /dev/nvidia-rsctl (miscdevice0600). No PCI binding,
NVIDIA-named device nodes, GPU initialization, CUDA/UVM/DRM implementation or
original-driver replacement. No module has been loaded by this workflow.

Implemented IOCTL subset on that isolated node:
- Native x86_64 type'F', directionread/write. Command210/version uses exact
  72byte ABI: query'2', relaxed'1' up to firstdecimal, othercommands strict.
  Reply recognized1; mismatch returnsLinux-EINVAL but copies recognizedreply
  and580.178.04 string back. This is protocolcompatibility, not CUDA support.
-206/207 allocate/free bounded OS-eventrecords with native16byte statusfields.
  Duplicate key(client,fd) returnsNV0x1a; missingfreeNV0x28; transport succeeds.
 256events/64files, per-device. Fileclose retires associatedevents.
-0x2a RMcontrol decodes32byte ABI, returnsNV_ERR_NOT_SUPPORTED0x56 inpayload
  with transport0. Its nestedparameter pointer is never dereferenced.
-Othercommands return-ENOTTY; wrong knownpayload size-EINVAL; usercopyfault
  -EFAULT. Allocationfailure-ENOMEM. Filecapacity-ENOSPC. No32bitcompatABI.

A directrequest copies one boundedpayload in/out. XFER211 copies exactly one
16byteheader then onepayload in/out, maximum16384bytes (originalnv.h limit).
RecursiveXFER andcommands>255 are rejected. No nestedRMparameter/rights/user
pointers are followed: zero nestedpayload copies in this implementation.
Global/per-file mutexes serialize Rust state; fixedlockorderperfile->device.
Userspacecopy occurs outside locks. Buffer ownership is C; Rust receives only
kernel-copied bytes and properly sized/aligned stateallocations.

Deviceeventtable initialization writes zero-valid numeric/boolfields in place,
using volatile byte stores so no temporary large stackframe or GOTmemset call
is generated. Changing Device to include non-zero-valid types requires revising
this FFI initialization. The purecore remains forbidunsafe; unsafe is confined
to pointer validation/storage/slices at this adapter boundary.

No actual event delivery endpoint exists yet: OS-eventrecordsuccess does not
meanLinuxpayloadqueues/wakeups/GPUasynchronous signaling are implemented. The
core begin_post/drop-lock/delivery/reacquire/finish_post discipline remains the
future adapter's obligation. NoGPUmetadata is fabricated for RMcontrol.

Verification (no module loading):
  make modules
  python3 src/nvidia/kernel/verify-object.py
  src/nvidia/kernel/run-host-fixtures.sh
The hostharness invokes the sameRustFFI and sharedC envelopepolicy with bounded
simulatedcopyregions. It covers strict/relaxed/query/versionmismatch/copyback,
wronglength/type/direction, XFERbounds/recursion, copyfaultprecedence, event
lifecycle/globalduplicates/fileclose and unsupportednestedpointercommands.
It does not emulate Linuxaccess_ok, scheduler, realfileops or kernelconcurrency.

Prerequisites: pinnedRust1.100.0 and x86_64-unknown-none target, Ccompiler/make/
matchingLinuxheaders. rustup target add --toolchain1.100.0 x86_64-unknown-none.
modules_install requires INSTALL_MOD_PATH staging and never runs hostdepmod.

RM transport and per-file namespaces (current integration)
Native ALLOC48, FREE16 and CONTROL32 dispatch through the core transport and
PerFileRm<64>. The Linux shim copies top-level data, plans a single nested
parameter buffer from verified class metadata/control length, then copies that
buffer before acquiring per-file and device locks. Rights and serialization
paths are rejected without following their pointers. Address wrap is rejected.
The adapter allocation limit is explicitly1MiB (ENOMEM), not an inferred RM
hardware ABI limit. Nested output precedes top-level output; either copy fault
returns EFAULT. No arbitrary userspace pointer reaches the Rust backend.

The default backend creates software root clients with per-file ownership and
unique handles. Device/resource construction and control remain NOT_SUPPORTED.
Invalid client and object handles return RM status in the wrapper while the
transport succeeds. Successful root free purges associated OS event records.
FREE's parent argument is ignored as observed in the original wrapper.
File close drains its root namespace before retiring file event ownership.

File state includes the64-object manager. It is initialized in place from a
valid static empty template using volatile MaybeUninit-byte copies, preserving
padding and avoiding both a2560-byte temporary frame and a GOT memcpy call.
The earlier diagnostic-only sections above describe historical limitations;
these nested-copy and object-manager paths supersede those specific limits.

Host fixtures now execute38 cases against the same Rust FFI and C transport
planning, including nested region faults, output faults, overflow, root
allocation/free, cross-file ownership and purge/close behavior. No Linux
module was loaded by this implementation subtask.