nvidia-kernel-patches/README.md

3.7 KiB

nvidia-kernel-patches

Source patches that make NVIDIA's driver build against kernels newer than the driver knows about. Currently: 580.76.05 (kernel-open) on 7.0.14-11-pve (Proxmox VE 9.2.10, host spicy). New driver/kernel combos get their own patch + section as they happen.

Referenced from the house infra repo (trikilli → hosts/spicy-rtx3090-bringup.md), which holds the full bring-up narrative (LXC passthrough, DKMS setup, device majors). This repo is just the patch and how to use it.

nvidia-580.76.05-kernel7.patch

Applies to the kernel-open/ tree extracted from NVIDIA-Linux-x86_64-580.76.05.run. Deployed on spicy 2026-08-10; DKMS source lives at /usr/src/nvidia-580.76.05 on-host.

Why the stock driver fails on kernel 7.x

Three independent causes:

  1. GCC 14 breaks NVIDIA's conftest. The "is function X present" probes are inverted: they call X with no arguments and treat a successful compile (old compilers: implicit-declaration warning) as "absent". GCC 14 makes implicit declarations hard errors → every probe fails to compile → everything detected "present" → driver calls APIs that don't exist (and builds Tegra-only code on x86).
  2. Kernel 7.x headers need -std=gnu11 -fms-extensions. kbuild passes these; conftest didn't. Without -fms-extensions, anonymous tagged-struct members (e.g. struct filename { struct __filename_head; ... }) silently drop and a static_assert on the struct size kills every probe including fs/device/pci headers.
  3. Real API changes — table below.

What the patch does

File Change
conftest.sh Add -std=gnu11 -fms-extensions -Wno-error=implicit-function-declaration -Wno-error=int-conversion -Wno-error=incompatible-pointer-types to CFLAGS
common/inc/nv-time.h, nvidia/os-interface.c in_irq() → in_hardirq() (removed)
common/inc/nv-mm.h vm_flags writes → vm_flags_set/clear() / vma_flags_set_word/clear_word() (vm_flags is a const union member now)
nvidia/nv-dma.c dma_map_ops.map_resource → map_phys (phys-addr DMA rework)
nvidia/nv-pci.c pci_resize_resource() gained 4th arg exclude_bars → pass 0
nvidia-uvm/uvm_pmm_gpu.c dev_pagemap_ops.page_free(page) → .folio_free(folio) — thin wrappers added
nvidia-uvm/uvm_hmm.c zone_device_page_init(page) → (page, pgmap, order) signature

Use kernel-open, not the closed blob: GA102+ is fully supported, and the open modules are Dual MIT/GPL so they can call the kernel's GPL-only VMA-lock API — the closed blob reimplements those internals and chases a moving target. Exclude nvidia-drm (DRM API churn, headless boxes don't need it) and nvidia-peermem.

Apply + install

sh NVIDIA-Linux-x86_64-580.76.05.run --extract-only --target nv580
cd nv580 && patch -p1 < nvidia-580.76.05-kernel7.patch   # paths are kernel-open/...
cp -r kernel-open /usr/src/nvidia-580.76.05              # + dkms.conf: set version,
                                                          #   exclude nvidia-drm/peermem
dkms add nvidia/580.76.05 && dkms build nvidia/580.76.05 && dkms install nvidia/580.76.05
sh NVIDIA-Linux-x86_64-580.76.05.run --no-kernel-modules --silent --no-x-check  # userspace

Container userspace must match the host module version exactly; install inside each LXC with --no-kernel-modules.

Caveats

  • Every kernel update re-runs the DKMS build against new headers — further API churn means further patching. Verify nvidia-smi (host, then containers) after any reboot.
  • -Wno-error=incompatible-pointer-types in conftest is scoped to probe compiles only; the real module build keeps default warnings.