The legacy NVIDIA 390.157 driver the last one supporting Fermi is widely documented as requiring kernel 5.15 on Ubuntu-family systems. Ubuntu decided not to patch it for the rest of Jammy's life, and the community PPAs carry patches up to 6.2 and stop.
It builds on 6.8 fine. It needs two things, and only one of them is my work.
Five things broke between 6.3 and 6.8:
| Kernel | Change |
|---|---|
| 6.3 | vma->vm_flags write-protected, needs vm_flags_set() |
| 6.4 | drm_driver.dumb_destroy removed |
| 6.5 | get_user_pages_remote() lost its vmas argument |
| 6.6 | drm_gem_prime_handle_to_fd unexported |
| 6.8 | DRM_UNLOCKED removed |
All five patches already exist, written by the AUR nvidia-390xx-utils
maintainers, who have kept 390 building on current kernels for years past its
EOL. Their series covers 6.2 through 7.0.
They don't apply to a Debian/Ubuntu DKMS tree as-is, because Arch's source
layout has a kernel/ prefix that Debian's doesn't. This script fetches them,
rewrites the paths, picks the ones your target kernel needs, and adds them to
dkms.conf.
This is the part that isn't documented anywhere I could find, and it's why "apply the AUR patches" isn't enough on a current Ubuntu kernel.
With all five patches applied the build still fails, and there is no compiler
error anywhere in make.log:
make[3]: *** [scripts/Makefile.build:243: .../nvidia/nv.o] Error 241
make[3]: *** Deleting file '.../nvidia/nv.o'
Immediately before it, 15 of these:
nv.o: warning: objtool: __x86_indirect_thunk_rax+0x0: indirect jump found in MITIGATION_RETPOLINE build
nv.o: warning: objtool: __x86_indirect_thunk_rbx+0x0: indirect jump found in MITIGATION_RETPOLINE build
...
It's objtool, not gcc. The compile line ends with
; ./tools/objtool/objtool ... --module nv.o, so the exit status make sees is
objtool's.
Cause is kernel/Makefile line 66:
SPECTRE_V2_RETPOLINE ?= 0Hardcoded since 2018. It isn't detecting anything. It feeds
-DNV_SPECTRE_V2=0, and common/inc/nv-retpoline.h:28 gates on
#if (NV_SPECTRE_V2 == 0) to define __x86_indirect_thunk_* itself NVIDIA
did that because in 2018 not every kernel exported them.
So 390 has always shipped duplicate retpoline thunks. It didn't matter on 5.15
because objtool wasn't checking. Ubuntu's 6.8.0-136 has the backported
objtool that does, and a retpoline thunk is by definition a bare indirect jump, so objtool flags exactly what it exists to flag.
Setting it to 1 fixes it, and as a side effect the driver starts using the
kernel's real retpolines instead of its own passthroughs. Spectre v2 mitigation
that had been silently off is now on.
Arch doesn't hit this because their 6.8 predates the objtool backport.
chmod +x nv390-kernel-fix.sh
# dry run - fetches patches, reports what applies, changes nothing
sudo ./nv390-kernel-fix.sh
# apply and rebuild
sudo ./nv390-kernel-fix.sh --apply
# target a specific kernel
sudo ./nv390-kernel-fix.sh --apply -k 6.8.0-136-generic
# use a local AUR checkout instead of cloning
sudo ./nv390-kernel-fix.sh --src ~/nvidia-390xx-utils
# undo (restores /usr/src/nvidia-390.157 from backup)
sudo ./nv390-kernel-fix.sh --revertIt picks patches by version, so targeting a newer kernel pulls more of the series automatically. Keep your old kernel installed it stays in GRUB under Advanced options, so a bad boot costs you one menu selection.
Afterwards:
sudo apt-mark hold nvidia-driver-390 nvidia-dkms-390or a package update will overwrite /usr/src and undo all of it.
Dell Inspiron 3542, Pentium 3558U, 4 GB RAM
GPU: GF117M [GeForce 820M] [10de:1140] (Fermi)
OS: Linux Mint 21.3 Xfce (jammy base)
Kernel: 6.8.0-136-generic (linux-generic-hwe-22.04)
Driver: 390.157-0ubuntu+klbkjammy1.1 (ppa:kelebek333/nvidia-legacy)
dkms status nvidia/390.157, 6.8.0-136-generic, x86_64: installed
nvidia/390.157, 5.15.0-186-generic, x86_64: installed
nvidia-smi GeForce 820M, P0
glxinfo OpenGL renderer string: GeForce 820M/PCIe/SSE2
One machine, one GPU. If it works or breaks on yours, open an issue and say which card and kernel.
The AUR series covers up to 7.0, so 6.12 and 6.18 LTS should both be reachable. I haven't tested either jammy's HWE track ends at 6.8, so going further means sourcing a kernel from outside the distro repos.
There is no 6.9 or 6.11 patch because those releases didn't break anything.
One warning if you go past 6.8: kernel-6.10.patch is not version-gated,
and it makes nv_follow_pfn() return -1 when follow_pfn is absent (removed
in 6.10). That's not a build fix, it's removing a code path in os-mlock.c.
Harmless below 6.10 where follow_pfn still exists. Above it, something
quietly stops working probably UVM-related, but I haven't chased it. The
script warns when it selects that patch.
The kernel patches are the work of the AUR nvidia-390xx-utils maintainers.
They are fetched at run time, not redistributed here. Everything upstream of
the retpoline fix is theirs.
GPL-2.0, matching the driver source it patches.