Skip to content

Conversation

@gg582
Copy link

@gg582 gg582 commented Jan 27, 2026

Description

This PR addresses build failures in the NVIDIA UVM kernel module when compiling against Linux kernel version 6.19.0 and later. It handles two major API changes in the upstream kernel:

  1. zone_device_page_init signature change:
  • In Linux 6.19, zone_device_page_init now requires an additional argument.
  • Updated uvm_hmm.c to pass the required arguments based on the LINUX_VERSION_CODE.
  1. struct dev_pagemap_ops modification:
  • The page_free callback has been removed/changed in recent kernel updates.
  • Updated uvm_pmm_gpu.c to wrap the page_free assignment with version checks to prevent compilation errors.

The changes use conditional compilation to maintain backward compatibility with older kernel versions.

Testing

  • Target Kernel: Linux 6.19.0+
  • Result: Verified that the module builds successfully without regressions for older kernel versions.

@jeamieofqidan
Copy link

Testing has shown that open-kernel-modules with this patch applied fail to compile the Nvidia module under Ubuntu.

@ptr1337
Copy link

ptr1337 commented Jan 29, 2026

Testing has shown that open-kernel-modules with this patch applied fail to compile the Nvidia module under Ubuntu.

https://github.com/CachyOS/kernel-patches/blob/master/6.19/misc/nvidia/0003-Fix-compile-for-6.19.patch

Here is a fix, which works across several kernels versions. Even tough, I hope NVIDIA will push a 590 update before 6.19 goes stable.

@Fjodor42
Copy link

Fjodor42 commented Jan 31, 2026

Testing has shown that open-kernel-modules with this patch applied fail to compile the Nvidia module under Ubuntu.

This seems to stem from the fact that Ubuntu has begun setting CONFIG_OBJTOOL_WERROR=y in their kernels.

Hence, we need more steps there (and for other kernels setting that), at least to get the DKMS package to compile:

  1. Cloning this repository and applying the patch from this PR (or the one from CachyOS mentioned in uvm: Fix build failure for Linux 6.19+ due to HMM and PMM API changes #1015 (comment))
  2. Apply patch [1] below
  3. Compile with make modules -j$(nproc)
  4. Copy src/nvidia/_out/Linux_x86_64/nv-kernel.o to /usr/src/nvidia-590.48.01/nvidia/nv-kernel.o_binary
  5. Copy src/nvidia-modeset/_out/Linux_x86_64/nv-modeset-kernel.o to /usr/src/nvidia-590.48.01/nvidia-modeset/nv-modeset-kernel.o_binary
  6. Apply the patch from this PR (or the one from CachyOS mentioned in uvm: Fix build failure for Linux 6.19+ due to HMM and PMM API changes #1015 (comment)) in /usr/src/nvidia-590.48.01
  7. Install Ubuntu Linux 6.19 kernel packages
  8. ?
  9. Profit

[1]

diff --git a/src/nvidia-modeset/Makefile b/src/nvidia-modeset/Makefile
index b54138cc..a38244fd 100644
--- a/src/nvidia-modeset/Makefile
+++ b/src/nvidia-modeset/Makefile
@@ -112,7 +112,6 @@ endif

 CFLAGS += -fno-pic
 CFLAGS += -fno-common
-CFLAGS += -fomit-frame-pointer
 CFLAGS += -fno-strict-aliasing
 CFLAGS += -ffunction-sections
 CFLAGS += -fdata-sections
@@ -153,8 +152,11 @@ ifeq ($(TARGET_ARCH),x86_64)
     CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fcf-protection=branch)
   endif
   CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fno-jump-tables)
+  CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fno-asynchronous-unwind-tables)
   CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch=thunk-extern)
   CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch-register)
+  CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mharden-sls=all)
+  CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mfunction-return=thunk-extern)
 endif

 CFLAGS += $(CONDITIONAL_CFLAGS)
diff --git a/src/nvidia/Makefile b/src/nvidia/Makefile
index d1d6d866..b5a09324 100644
--- a/src/nvidia/Makefile
+++ b/src/nvidia/Makefile
@@ -184,7 +184,9 @@ ifeq ($(TARGET_ARCH),x86_64)
   endif
   CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fno-jump-tables)
   CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch-register)
-    CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch=thunk-extern)
+  CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch=thunk-extern)
+  CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mharden-sls=all)
+  CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mfunction-return=thunk-extern)
 endif

 CFLAGS += $(CONDITIONAL_CFLAGS)

Notes:

I am a bit uncertain about the + CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fno-asynchronous-unwind-tables) part, but feel free to test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants