Commit Graph

19 Commits

Author SHA1 Message Date
d5e0b9bb87 Wave 7A: Proactive P0 lock/UAF fixes and kernel build/compat hardening
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.
2026-12-02 01:34:46 +00:00
3ada318df4 Drop-in UX (#133), Maxwell/Pascal ACR FW, Hopper/Blackwell split-RM, and #142 Phases 3-4
- 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).
2026-12-01 23:03:43 +00:00
e3c196cd49 gsp/rmapi/tools: zero GSP boot refusal stubs (#74/#127), DmaMapLedger in Rust (#142 Phase 2), host-portable validate_all.sh (#64) 2026-12-01 22:27:32 +00:00
10b4b44ee8 rmapi/uvm/pmgr: Rust alloc registry (#142), uvm_ext_gpu_map_split (#134), PMGR power limit (#136), per-BDF clocks (#130), .ko.zst & bare-metal docs (#133) 2026-12-01 21:39:34 +00:00
3670ca66c2 Merge upstream/master into pr/edition-2024
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>
2026-12-02 02:15:43 +08:00
32c8728037 Migrate the workspace and kernel crates to Rust edition 2024
Mechanical, behavior-neutral: edition/resolver keys, unsafe extern blocks,
unsafe(no_mangle)/unsafe(export_name), unsafe blocks inside unsafe fn,
r#gen renames, --edition flags in Makefiles/tools, rustfmt style_edition
pinned to 2021 so formatting stays edition-independent, and clippy
collapsible_if allowed workspace-wide (let-chain churn).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-12-02 01:52:38 +08:00
ea8b4af427 fix: CE scrub retire polling (#63), Maxwell FECS/park (#84), rethunk/retpoline (#78), admission log (#80), rustup lookup (#56)
- rmapi_engine.rs (#63): poll NV_PFIFO_ENG_RUNLIST PENDING bit (bit 20) after submit_runlist and poll CCSR idle flags before failing stop_scrub_ce(); clear scrub_ce.retire_pending on deactivate().
- adapter_start.rs (#84): filter 0xbadfxxxx PRI error codes from FECS golden context size discovery and call nv_rs_runtime_park + deactivate_runtime in boot_maxwell_pascal_pre_gsp.
- utils.mk (#78): auto-enable -Z function-return=thunk-extern and -Z retpoline-external-thunk when CONFIG_(MITIGATION_)?RETHUNK/RETPOLINE=y in target kernel .config.
- pci_driver.c (#80): log rejected pci_admitted tuple (class, subclass, vendor, device, subsys) via dev_info instead of failing silently.
- tools/vm/verify_rust_guest.py (#56): resolve rustup via shutil.which('rustup') / Path.home() instead of hardcoded /home/geodd.

Validated: fmt, IBT=1 & IBT=0 modules + check_kernel_module.py (with rethunk+retpoline enabled), test_gate_cases.py (16/16), QEMU EDU non-IOMMU + IOMMU.
2026-12-01 17:43:07 +00:00
d4cd0444d2 tools: stop EDU validation when VM build prerequisites fail 2026-12-01 17:27:18 +00:00
d7894b7b43 tools: replace stale EDU success reports when a run fails (#103) 2026-12-01 12:24:33 -05:00
6f57dc38c7 tools: validate exact integer types in EDU guest evidence (#99) 2026-12-01 12:24:10 -05:00
57cdbd9e58 tools: make the QEMU guest gate steps host-portable (fixes #79)
- build_guest_test.sh: strip debug info from the Rust object so pahole can
  encode the guest module's BTF; honour KERNEL_OUTPUT/SYSOUT/SYSSRC like the
  production build; set LLVM=1 on clang-built kernels (#77).
- build_initramfs.sh: take the kernel image from NV_RS_VMLINUZ or
  /usr/lib/modules/<release>/vmlinuz before /boot/vmlinuz-<release>; allow
  BUSYBOX to name the static busybox.
- run_guest.py: boot with ignore_loglevel so the pr_info result line reaches
  the serial console when the console loglevel is below 6; run QEMU directly
  when /dev/kvm is already accessible instead of requiring a sudo runas rule.
- validate_all.sh: build target/compat32-rust-driver for the live step when
  it is missing.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-12-01 08:52:54 -05:00
8202288ea7 Follow-up to PR #16/#29: harden IRQ/CE/NVLink edge cases and fix guest test build
- gv100_irq_service.rs: drop sw_methods_serviced > 0 requirement so a fresh SW method (PGRAPH_INTR == 0x10) arriving before PMC_INTR_0 recheck never falsely quarantines PGRAPH.
- rmapi_engine.rs: unbind SCRUB_CHID in CCSR on CE scrub timeout; preserve bound_irq_handle across deactivate/reactivate so nv_rs_irq_bind() does not fail with -EBUSY on reopen.
- uvm_node.rs & uvm_interface_ffi.rs: check NVLink symmetrically before enabling peer atomics.
- tools/vm/build_guest_test.sh & tests/vm/edu_adapter_test.c: copy uvm_node.h and stub nv_rs_uvm_unmap_gpu_dev for the QEMU EDU guest module build.
2026-12-01 01:10:46 +00:00
caef37fa93 kernel: add RHEL 9.8+ (5.14) compat guards, firmware install, boot kit, and driver_version= param
Cherry-picked and adapted from PR #9 onto master:
- RHEL 9.8+ backport guards: #ifndef PCI_IRQ_INTX in irq_adapter.c, RHEL_RELEASE_CODE in vm_flags_set/clear (rmapi_node.c, uvm_node.c) and DMA_BUF namespace import (dmabuf_p2p.c). (nano_timer_adapter.c container_of() and rom_fw_adapter.c MAX_PAGE_ORDER were already landed on master.)
- install.sh: install extracted target/firmware/nvidia-rs/*/*.fw packs into /lib/firmware before depmod.
- contrib/rhel-5.14-boot/: boot persistence setup for RHEL 9 (modprobe/dracut/udev/systemd/nodes.sh), with empty-vs-wildcard pci_target guard in nodes.sh.
- driver_version= module parameter (default 580.178.04): overrides /proc/driver/nvidia/version, NV_ESC_CHECK_VERSION_STR, and RM 0x101/0x13e identity replies at load time so hosts running newer 580.x userspace (e.g. driver_version=580.196.07) work without breaking 580.178.04 parity.

Co-authored-by: Gaël STEPHAN <gstephan@wyplay.com>
2026-12-01 00:09:44 +00:00
f002da37b2 Port Tier 1 & Tier 2 580.178.04 subsystems (PMU stack, HWPM/UVM_TOOLS, InfoROM, live IRQ, MPS/dmabuf, Video, Display, MIG/IMEX, GSP-RM) 2026-11-30 13:33:37 +00:00
b5864d99ec feat(gv100): add P0 voltage + NAFLL boost bring-up and head-to-head benchmark suite 2026-11-28 06:08:32 +00:00
321278a032 Bump Turing-Blackwell-Rubin GSP-RM path to 620.70.06 (MCTP+NVDM+GMCAPI, GR100, C-header oracle) 2026-11-28 04:33:24 +00:00
a209eced9d Port ATS THP fault coalescing, client-close sysmem pool trim, force_p2p, resize-bar1, and MOK install.sh 2026-11-28 02:22:41 +00:00
4b6a77d90f Clean-room Rust NVIDIA 580.178.04 driver: GV100 0-diff parity (8-GPU PyTorch/NCCL/llama.cpp, H.264+HEVC NVDEC/NVENC, 2,096/2,096 RM controls, stock UVM/modeset bridges, artificial restrictions unlocked) 2026-11-27 20:45:30 +00:00
4526e6a816 Baseline: validated 30/30 tree with passing Level 7 hardware regression
- Updated tools/post_reboot.sh to check kernel oops taint bit and stuck driver tasks instead of <86400s uptime
- Level 7 hardware regression passed on 0000:b3:00.0 (module 37e6fa430835eee2b426019db3ad70eeb7a9e9070c09c84bd9b973cf56cbe529, 107 inventory words, 0 static mismatches, CUDA baseline verified before and after)
- Updated .gitignore to exclude build archives (*.a, *.rlib), __pycache__, and raw trace dumps
2026-11-23 23:48:38 +00:00