open-gpu-kernel-modules icon indicating copy to clipboard operation
open-gpu-kernel-modules copied to clipboard

nvidia-modeset: suspend crash (jump_label BUG) caused by missing objtool NOP conversion in DKMS build

Open alexanderlerch-arch opened this issue 7 months ago • 18 comments

NVIDIA Open GPU Kernel Modules Version

595.58.03

Operating System and Version

Ubuntu 26.04 LTS (Resolute Raccoon)

Kernel Release

Linux 7.0.0-10-generic x86_64

Please confirm you are running a stable release kernel (e.g. not a -rc). We do not accept bug reports for unreleased kernels.

  • [x] I am running on a stable kernel release.

Build Command

No build done, but the template forces me to provide a command. dkms build nvidia/595.58.03 -k 7.0.0-10-generic

Terminal output/Build Log

Actually also no build done, but the template forces me to provide some log. objtool is skipped during DKMS build due to pre-compiled blobs lacking -mfunction-return=thunk-extern (see #1077, #1021). This results in static_branch JMPs not being converted to NOPs, causing a runtime crash on suspend.

More Info

Hey,

i had a hard time debugging this, but i finally had some success and found the potential root cause for the bug. In short, i cannot suspend to s3 deep and resume again, always resulting in a crash, after some digging to isolate the problematic function, i finally can suspend and resume again and it may only comes down to skipping objtools during build.

Here is some AI slop, with insights:

nvidia-modeset: jump_label BUG on suspend — missing objtool NOP conversion in DKMS build

Description

nvidia-modeset.ko built via DKMS crashes on suspend with a jump_label: Fatal kernel bug on kernels ≥ 6.0 (x86_64, CONFIG_HAVE_JUMP_LABEL_HACK=y).

The DKMS build does not run objtool on the compiled shim objects (nvidia-modeset-linux.c, nv-kthread-q.c). With CONFIG_HAVE_JUMP_LABEL_HACK, GCC emits JMP instructions at static_branch_unlikely() sites that objtool is supposed to convert to NOPs (see comment in arch/x86/include/asm/jump_label.h: "jmp %l[l_yes] # objtool NOPs this").

Before kernel 6.0, jump_label_apply_nops() in arch/x86/kernel/module.c corrected this at module load time. Commit fdfd42892f31 (June 2022, merged in 6.0) removed that function for x86, expecting modules to ship correct instructions.

The result: nvidia-modeset.ko has JMPs where the kernel expects NOPs. On suspend, the kernel enables freezer_active and tries to patch NOP→JMP at these sites — finds JMP instead of NOP — triggers BUG().

Error signature

jump_label: Fatal kernel bug, unexpected op at nvkms_kthread_q_callback+0x8e/0x1a0 [nvidia_modeset]
  (e9 9b 00 00 00 != 0f 1f 44 00 00)) size:5 type:1
kernel BUG at arch/x86/kernel/jump_label.c:73!

Followed by GSP Heartbeat Timeout, GPU lost, hard reset required.

Affected functions in nvidia-modeset

All functions calling nvkms_read_lock_pm_lock() which inlines try_to_freeze() → freezing() → static_branch_unlikely(&freezer_active):

  • nvkms_kthread_q_callback (5-byte JMP e9 at +0x8e)
  • nvkms_close_pm_unlocked (2-byte JMP eb at +0x26)
  • nvkms_open_from_kapi (2-byte JMP eb at +0x34)
  • nvkms_close_from_kapi (2-byte JMP eb at +0x26)
  • nvkms_ioctl_from_kapi (2-byte JMP eb at +0x36)

How I verified this

1. Disassembly of nvidia-modeset.ko vs a test module

A minimal GPL module (test_freezer.ko) compiled against the same kernel headers with identical try_to_freeze() usage has correct NOPs at static_branch sites. nvidia-modeset.ko has JMPs.

test_freezer.ko .text+0x21:  66 90              ← 2-byte NOP (correct)
nvidia-modeset.ko .text+0x9ae: e9 9b 00 00 00   ← 5-byte JMP (wrong)

2. Runtime memory verification

Reading the loaded module's memory via /proc/kcore:

# nvidia-modeset WITHOUT fix:
0xffffffffc04d09ae: 0xe9 0x9b 0x00 0x00 0x00   ← JMP still in memory (not patched to NOP)

# nvidia-modeset WITH fix (text_poke to NOP):
0xffffffffc04d09ae: 0x0f 0x1f 0x44 0x00 0x00   ← NOP (patched by fix module)

3. Suspend tests

Condition Result
Suspend with nvidia-modeset (unpatched) jump_label: Fatal kernel bug → crash
Suspend without nvidia-modeset (rmmod) Clean S3 suspend/resume
Suspend with nvidia-modeset + runtime NOP fix Clean S3 suspend/resume

4. The __jump_table entries confirm freezer_active

$ readelf -r nvidia-modeset.ko | grep freezer_active
000000000008  ...  R_X86_64_PC64  freezer_active + 2
000000000018  ...  R_X86_64_PC64  freezer_active + 2
000000000048  ...  R_X86_64_PC64  freezer_active + 2
000000000058  ...  R_X86_64_PC64  freezer_active + 2
000000000068  ...  R_X86_64_PC64  freezer_active + 2

Tested driver versions (all crash the same way)

  • nvidia-driver-595-open (595.58.03)
  • nvidia-driver-595 proprietary (595.58.03)
  • nvidia-driver-590-open
  • nvidia-driver-590 proprietary
  • nvidia-driver-580-open (580.126.09)
  • nvidia-driver-580 proprietary

System info

  • Kernel: 7.0.0-10-generic (Ubuntu 26.04 LTS)
  • GPU: NVIDIA GeForce RTX 3060 Ti (GA104)
  • CPU: AMD Ryzen Threadripper 3960X
  • Board: MSI TRX40 PRO WIFI
  • CONFIG_HAVE_JUMP_LABEL_HACK=y
  • CONFIG_JUMP_LABEL=y

Affected kernel versions

Any kernel ≥ 6.0 on x86_64 with CONFIG_HAVE_JUMP_LABEL_HACK=y.

Before 6.0, jump_label_apply_nops() masked the bug by patching all module jump_label sites at load time.

Related issues

This is a direct consequence of the objtool incompatibility tracked in:

In #1077, an NVIDIA collaborator confirmed that the blobs are not yet built with -mfunction-return=thunk-extern and suggested disabling CONFIG_OBJTOOL_WERROR or setting OBJECT_FILES_NON_STANDARD := y as a workaround. Both workarounds disable objtool validation entirely, which also skips the JMP→NOP conversion for static_branch sites — directly causing the suspend crash described here.

Suggested fix

The pre-compiled blobs need to be compiled with the correct compiler flags so that objtool validation passes. This would allow objtool to run during the DKMS build, which would convert the static_branch JMPs to NOPs as the kernel expects.

If fixing the blobs is not feasible short-term, nvidia-modeset's module init could patch its own __jump_table entries to convert JMPs→NOPs for disabled keys (equivalent to the removed jump_label_apply_nops()).

Workaround

A runtime fix module that patches JMPs→NOPs via text_poke() after nvidia-modeset loads:

/* Iterate nvidia_modeset's jump_entries, patch JMPs to NOPs for disabled keys */
for (; iter < stop; iter++) {
    struct static_key *key = jump_entry_key(iter);
    if (!static_key_enabled(key)) {
        unsigned char *addr = (unsigned char *)jump_entry_code(iter);
        if (addr[0] == 0xe9)
            text_poke(addr, nop5, 5);  /* 0f 1f 44 00 00 */
        else if (addr[0] == 0xeb)
            text_poke(addr, nop2, 2);  /* 66 90 */
    }
}

Full source available on request.

alexanderlerch-arch avatar Apr 03 '26 13:04 alexanderlerch-arch

I tested that putting https://github.com/eeickmeyer/nvidia-graphics-drivers/blob/63b86e48f695cbc8a8e4174918165f24bb181536/debian/dkms-objtool-jl.sh in /usr/src/nvidia-595.58.03/dkms-objtool-jl.sh and changing the MAKE line in /usr/src/nvidia-595.58.03/dkms.conf to

MAKE[0]="unset ARCH; [ ! -h /usr/bin/cc ] && export CC=/usr/bin/gcc; env NV_VERBOSE=1 \
    'make' -j$PROCS_NUM NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=${kernelver} IGNORE_XEN_PRESENCE=1 IGNORE_CC_MISMATCH=1 SYSSRC=$kernel_source_dir LD=/usr/bin/ld.bfd CONFIG_X86_KERNEL_IBT= modules && sh dkms-objtool-jl.sh $kernel_source_dir"

Then running the following commands:

sudo dkms build nvidia/595.58.03 --force
sudo dkms install nvidia/595.58.03 --force
sudo update-initramfs -u

This fixes the suspend issue on Ubuntu 26.04 kernel 7.0.0-12-generic for me.

veldenb avatar Apr 11 '26 17:04 veldenb

@veldenb Thank you! this fixed the suspend issue for me too.

Kubuntu 26.04, kernel 7.0.0-14-generic (GeForce GTX 1660)

lishaie avatar Apr 16 '26 20:04 lishaie

@veldenb This fixes suspend for me, too!

UBuntu 26.04, 7.0.0-14-generic with a 3080

MichaelHeimann avatar Apr 21 '26 08:04 MichaelHeimann

I am having an issue after upgrading to Ubuntu 26.04 with my Nvidia. I used to use the Nvidia 535 driver and it was fine. Now this is not available under Ubuntu 26.04. Here is my crash report:

Title: Ubuntu 26.04 kernel 7.0.0-14: suspend crashes with NVIDIA GTX 1650 Mobile / Max-Q in nvidia_modeset nvkms_kthread_q_callback / jump_label BUG

System:

  • Laptop: Dell Inspiron 7501
  • OS: Ubuntu 26.04 LTS “resolute”
  • Kernel: 7.0.0-14-generic
  • Desktop: GNOME on Wayland
  • GPU: NVIDIA GeForce GTX 1650 Mobile / Max-Q, TU117M
  • Hybrid graphics: Intel iGPU + NVIDIA dGPU
  • External display connected via HDMI; external display requires NVIDIA mode
  • Current PRIME mode: nvidia
  • Current NVIDIA driver: nvidia-driver-595 proprietary, 595.58.03
  • Also reproduced with:
    • nvidia-driver-580 proprietary, 580.142
    • nvidia-driver-595-open, 595.58.03
    • nvidia-driver-595 proprietary, 595.58.03
  • NVIDIA suspend/resume/hibernate services are enabled.
  • PreserveVideoMemoryAllocations is enabled: PreserveVideoMemoryAllocations: 1

Problem: When I select Suspend, the system shows a kernel trace/panic and then becomes unusable. Sometimes it briefly reaches the lock screen/black screen, but keyboard/mouse cannot wake it. I have to force power off.

The problem happens with both suspend modes:

  • s2idle
  • deep

The problem happens with both NVIDIA 595 open and proprietary modules, and also with NVIDIA 580 proprietary.

Expected result: System suspends and resumes normally.

Actual result: Kernel BUG/Oops during suspend in nvidia_modeset.

Relevant log excerpt: PM: suspend entry (s2idle) jump_label: Fatal kernel bug, unexpected op at nvkms_kthread_q_callback+0x8e/0x1a0 [nvidia_modeset] (...) size:5 type:1 kernel BUG at arch/x86/kernel/jump_label.c:73! Oops: invalid opcode: 0000 [#1] SMP NOPTI Call Trace: pm_suspend+0x49/0x90

Same issue with deep: PM: suspend entry (deep) jump_label: Fatal kernel bug, unexpected op at nvkms_kthread_q_callback+0x8e/0x1a0 [nvidia_modeset] (...) size:5 type:1 kernel BUG at arch/x86/kernel/jump_label.c:73! Oops: invalid opcode: 0000 [#1] SMP NOPTI Call Trace: pm_suspend+0x49/0x90

Troubleshooting already performed:

  • Confirmed NVIDIA DKMS builds successfully for kernel 7.0.0-14.
  • Confirmed nvidia-smi works normally before suspend.
  • Confirmed nvidia-suspend.service, nvidia-resume.service, and nvidia-hibernate.service are enabled.
  • Confirmed PreserveVideoMemoryAllocations=1.
  • Tested s2idle and deep sleep.
  • Tested nvidia-driver-580 proprietary.
  • Tested nvidia-driver-595-open.
  • Tested nvidia-driver-595 proprietary.
  • Tested PRIME Intel-only mode; external monitor does not work in Intel mode, so NVIDIA mode is required for my normal setup.

Impact: Suspend is unusable on Ubuntu 26.04 with NVIDIA mode enabled. The system must be force powered off after attempting suspend.

jubisa avatar Apr 28 '26 12:04 jubisa

I can confirm that the procedure by @veldenb in the earlier post fixes the issue with kernels 7.0.0-14 and 7.0.0-15, running on a Dell Precision M4800 with NVIDIA Quadro M2200 mobile and driver 580.142.

emk2203 avatar Apr 30 '26 20:04 emk2203

@veldenb He solution fixed the issue for me too! THis is my setup: Laptop: Dell Inspiron 7501 GPU: NVIDIA GeForce GTX 1650 Mobile / Max-Q, TU117M Hybrid graphics: Intel iGPU + NVIDIA dGPU External monitor: Lenovo ThinkVision P24q-10 over HDMI OS: Ubuntu 26.04 LTS Desktop: GNOME on Wayland Kernel at time of fix: 7.0.0-15-generic NVIDIA driver at time of fix: nvidia-driver-595 proprietary NVIDIA version: 595.58.03

jubisa avatar May 01 '26 11:05 jubisa

Anyone have a fix for this on openSUSE? veldenb's fix would not work since dkms-objtool-jl.sh does not exist.

saucylegs avatar May 04 '26 11:05 saucylegs

@saucylegs

Anyone have a fix for this on openSUSE? veldenb's fix would not work since dkms-objtool-jl.sh does not exist.

Assuming you're using the precompiled versions for the driver from openSUSE-repos-X-NVIDIA: these aren't managed by dkms so the fix provided above doesn't apply. I'm sure there's a better way about it, but I was able to manually patch the kernel modules via:

cd /usr/lib/modules/$(uname -r)/updates/
sudo /usr/src/<kernel-version>-obj/x86_64/default/tools/objtool/objtool --hacks=jump_label --module --link nvidia.ko
sudo /usr/src/<kernel-version>-obj/x86_64/default/tools/objtool/objtool --hacks=jump_label --module --link nvidia-modeset.ko

and then rebooting.

krwilt avatar May 04 '26 14:05 krwilt

Attempted the workaround. Unfortunately, the issue continues in my system after applying @veldenb solution. I even reinstalled NVIDIA drivers to use the dkms package specifically.

My Hardware details:

Ubuntu 26.04 LTS
Kernel: 7.0.0-15-generic
NVIDIA driver: 595.58.03
NVIDIA package: nvidia-dkms-595 / nvidia-driver-595
Hardware: Lenovo Legion Pro 5 (16IRX8)
    Intel Core i7-13700HX
    NVIDIA GeForce RTX 4060

MatiArgu avatar May 05 '26 18:05 MatiArgu

Reproducible on openSUSE Tumbleweed with kernel 7.0.2 and nvidia-open 595.71.05, RTX 4090, identical stack trace

Arthagus avatar May 05 '26 22:05 Arthagus

I have the same issue with suspend/resume and the workaround works for me.

Running Ubuntu 26.04 kernel 7.0.0-15-generic, Nvidia 595.58.03 open (tried both) on Lenovo Yoga Pro 7 with Intel Core Ultra 7 155H and NVIDIA RTX 4050.

This works for me:

Create this file: /usr/src/nvidia-595.58.03/dkms-objtool-jl.sh (chmod +x)

OBJTOOL="$1/tools/objtool/objtool"

if [ ! -x "$OBJTOOL" ]; then
    echo "  OBJTOOL: not found, skipping jump_label fix"
    exit 0
fi

for mod in nvidia.ko nvidia-modeset.ko; do
    if [ -f "$mod" ]; then
        "$OBJTOOL" --hacks=jump_label --module --link "$mod"
        echo "  OBJTOOL [jump_label] $mod"
    fi
done

Edit /usr/src/nvidia-595.58.03/dkms.conf and add this to the MAKE line: && sh dkms-objtool-jl.sh $kernel_source_dir

Rebuild modules:

sudo dkms build nvidia/595.58.03 --force
sudo dkms install nvidia/595.58.03 --force
sudo update-initramfs -u

Hopefully we'll get a solution to this issue soon.

fhangel avatar May 06 '26 02:05 fhangel

Suspend seems to work again on ubuntu 26.04. has this been been fixed with some update?

perja2 avatar May 25 '26 04:05 perja2

Suspend seems to work again on ubuntu 26.04. has this been been fixed with some update?

Under what kernel & driver?

fhangel avatar May 25 '26 05:05 fhangel

nvidia-driver-595-open 595.71.05-0ubuntu0.26.04.1 linux-image-7.0.0-15-generic 7.0.0-15.15

perja2 avatar May 25 '26 05:05 perja2

Yes, the relevant Ubuntu patch has reached stable

Vanuan avatar May 26 '26 16:05 Vanuan

Suspend seems to work again on ubuntu 26.04. has this been been fixed with some update?

It's more random for me. Sometimes it works, sometimes not.

Ou7law007 avatar May 30 '26 09:05 Ou7law007

Sorry, i lost track bc. the PR was closed and not merged. The commit that fixes this issue: https://github.com/canonical/nvidia-graphics-drivers/commit/041536841f3b00caa27c62960a987543269b6e9c

thx @eeickmeyer @jacobmartin0

alexanderlerch-arch avatar Jul 17 '26 11:07 alexanderlerch-arch

7. I tested that putting https://github.com/eeickmeyer/nvidia-graphics-drivers/blob/63b86e48f695cbc8a8e4174918165f24bb181536/debian/dkms-objtool-jl.sh in /usr/src/nvidia-595.58.03/dkms-objtool-jl.sh and changing the MAKE line in /usr/src/nvidia-595.58.03/dkms.conf to MAKE[0]="unset ARCH; [ ! -h /usr/bin/cc ] && export CC=/usr/bin/gcc; env NV_VERBOSE=1 \ 'make' -j$PROCS_NUM NV_EXCLUDE_BUILD_MODULES='' KERNEL_UNAME=${kernelver} IGNORE_XEN_PRESENCE=1 IGNORE_CC_MISMATCH=1 SYSSRC=$kernel_source_dir LD=/usr/bin/ld.bfd CONFIG_X86_KERNEL_IBT= modules && sh dkms-objtool-jl.sh $kernel_source_dir"

Then running the following commands:
```
sudo dkms build nvidia/595.58.03 --force
sudo dkms install nvidia/595.58.03 --force
sudo update-initramfs -u
```


    
      
    

      
    

    
  
This fixes the suspend issue on Ubuntu 26.04 kernel 7.0.0-12-generic for me.

can confirm this issue works when adapted/edited for the nvidia/580.178.04 driver. I did find that I needed to rebuild, reinstall and re-update the initramfs with each reboot, but I was able to automate this by putting those commands in my crontab (sans the sudo, ofc)

llarrieu avatar Oct 24 '26 21:10 llarrieu