From 16e88bbbaa3e1f4f1a49cd82bc6d55a695dd1027 Mon Sep 17 00:00:00 2001 From: Lee Yunjin Date: Tue, 27 Jan 2026 15:56:41 +0900 Subject: [PATCH 1/5] uvm: Fix build failure for Linux kernel 6.19 and later --- kernel-open/nvidia-uvm/uvm_hmm.c | 4 ++++ kernel-open/nvidia-uvm/uvm_pmm_gpu.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/kernel-open/nvidia-uvm/uvm_hmm.c b/kernel-open/nvidia-uvm/uvm_hmm.c index 9b676f971..574ac2a57 100644 --- a/kernel-open/nvidia-uvm/uvm_hmm.c +++ b/kernel-open/nvidia-uvm/uvm_hmm.c @@ -2140,7 +2140,11 @@ static void fill_dst_pfn(uvm_va_block_t *va_block, UVM_ASSERT(!page_count(dpage)); UVM_ASSERT(!dpage->zone_device_data); +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 19, 0) zone_device_page_init(dpage); +#else + zone_device_page_init(dpage, 0); +#endif dpage->zone_device_data = gpu_chunk; atomic64_inc(&va_block->hmm.va_space->hmm.allocated_page_count); } diff --git a/kernel-open/nvidia-uvm/uvm_pmm_gpu.c b/kernel-open/nvidia-uvm/uvm_pmm_gpu.c index 97ff13dcd..dca7e2f41 100644 --- a/kernel-open/nvidia-uvm/uvm_pmm_gpu.c +++ b/kernel-open/nvidia-uvm/uvm_pmm_gpu.c @@ -3060,7 +3060,9 @@ static vm_fault_t devmem_fault_entry(struct vm_fault *vmf) static const struct dev_pagemap_ops uvm_pmm_devmem_ops = { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 19, 0) .page_free = devmem_page_free, +#endif .migrate_to_ram = devmem_fault_entry, }; @@ -3165,7 +3167,9 @@ static void device_coherent_page_free(struct page *page) static const struct dev_pagemap_ops uvm_device_coherent_pgmap_ops = { +#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 19, 0) .page_free = device_coherent_page_free, +#endif }; static NV_STATUS uvm_pmm_cdmm_init(uvm_parent_gpu_t *parent_gpu) From c5f5fa10d2a2cb9ad2fc961cea24b444789bd6ef Mon Sep 17 00:00:00 2001 From: Lee Yunjin Date: Sat, 31 Jan 2026 18:24:46 +0900 Subject: [PATCH 2/5] uvm: fix Linux 6.19 build based on CachyOS and community feedback --- kernel-open/nvidia-uvm/uvm_hmm.c | 6 +++--- kernel-open/nvidia-uvm/uvm_pmm_gpu.c | 32 ++++++++++++++++++++++++++-- src/nvidia-modeset/Makefile | 8 ++++--- src/nvidia/Makefile | 6 ++++-- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/kernel-open/nvidia-uvm/uvm_hmm.c b/kernel-open/nvidia-uvm/uvm_hmm.c index 574ac2a57..f6e344f35 100644 --- a/kernel-open/nvidia-uvm/uvm_hmm.c +++ b/kernel-open/nvidia-uvm/uvm_hmm.c @@ -2140,10 +2140,10 @@ static void fill_dst_pfn(uvm_va_block_t *va_block, UVM_ASSERT(!page_count(dpage)); UVM_ASSERT(!dpage->zone_device_data); -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 19, 0) - zone_device_page_init(dpage); -#else +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0) zone_device_page_init(dpage, 0); +#else + zone_device_page_init(dpage); #endif dpage->zone_device_data = gpu_chunk; atomic64_inc(&va_block->hmm.va_space->hmm.allocated_page_count); diff --git a/kernel-open/nvidia-uvm/uvm_pmm_gpu.c b/kernel-open/nvidia-uvm/uvm_pmm_gpu.c index dca7e2f41..6add3ede1 100644 --- a/kernel-open/nvidia-uvm/uvm_pmm_gpu.c +++ b/kernel-open/nvidia-uvm/uvm_pmm_gpu.c @@ -177,6 +177,8 @@ #include "uvm_test.h" #include "uvm_linux.h" +#include + #if defined(CONFIG_PCI_P2PDMA) && defined(NV_STRUCT_PAGE_HAS_ZONE_DEVICE_DATA) #include #endif @@ -2999,8 +3001,13 @@ static bool uvm_pmm_gpu_check_orphan_pages(uvm_pmm_gpu_t *pmm) return ret; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0) +static void devmem_folio_free(struct folio *folio) { + struct page *page = &folio->page; +#else static void devmem_page_free(struct page *page) { +#endif uvm_gpu_chunk_t *chunk = uvm_pmm_devmem_page_to_chunk(page); uvm_gpu_t *gpu = uvm_gpu_chunk_get_gpu(chunk); @@ -3060,7 +3067,9 @@ static vm_fault_t devmem_fault_entry(struct vm_fault *vmf) static const struct dev_pagemap_ops uvm_pmm_devmem_ops = { -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 19, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0) + .folio_free = devmem_folio_free, +#else .page_free = devmem_page_free, #endif .migrate_to_ram = devmem_fault_entry, @@ -3150,8 +3159,14 @@ static void device_p2p_page_free_wake(struct nv_kref *ref) wake_up(&p2p_mem->waitq); } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0) +static void device_p2p_folio_free(struct folio *folio) +{ + struct page *page = &folio->page; +#else static void device_p2p_page_free(struct page *page) { +#endif uvm_device_p2p_mem_t *p2p_mem = page->zone_device_data; page->zone_device_data = NULL; @@ -3160,14 +3175,23 @@ static void device_p2p_page_free(struct page *page) #endif #if UVM_CDMM_PAGES_SUPPORTED() +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0) +static void device_coherent_folio_free(struct folio *folio) +{ + device_p2p_folio_free(folio); +} +#else static void device_coherent_page_free(struct page *page) { device_p2p_page_free(page); } +#endif static const struct dev_pagemap_ops uvm_device_coherent_pgmap_ops = { -#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 19, 0) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0) + .folio_free = device_coherent_folio_free, +#else .page_free = device_coherent_page_free, #endif }; @@ -3306,7 +3330,11 @@ static bool uvm_pmm_gpu_check_orphan_pages(uvm_pmm_gpu_t *pmm) static const struct dev_pagemap_ops uvm_device_p2p_pgmap_ops = { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0) + .folio_free = device_p2p_folio_free, +#else .page_free = device_p2p_page_free, +#endif }; void uvm_pmm_gpu_device_p2p_init(uvm_parent_gpu_t *parent_gpu) diff --git a/src/nvidia-modeset/Makefile b/src/nvidia-modeset/Makefile index b54138cc4..2a6271724 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 @@ -130,7 +129,7 @@ ifeq ($(TARGET_ARCH),x86_64) # # GCC flags -fcf-protection=branch and -mindirect-branch=extern-thunk can - # be used together after GCC version 9.4.0. See + # be used together after GCC version 9.4.0. See # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93654 for details. # Check if GCC version is appropriate. # @@ -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, -mindirect-branch=thunk-extern) + CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -fno-asynchronous-unwind-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, -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 d1d6d8663..af50af329 100644 --- a/src/nvidia/Makefile +++ b/src/nvidia/Makefile @@ -160,7 +160,7 @@ ifeq ($(TARGET_ARCH),x86_64) # # GCC flags -fcf-protection=branch and -mindirect-branch=extern-thunk can - # be used together after GCC version 9.4.0. See + # be used together after GCC version 9.4.0. See # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93654 for details. # Check if GCC version is appropriate. # @@ -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) From 0acd5ee95ddeedcc98049b2306526b9f23b3726c Mon Sep 17 00:00:00 2001 From: Lee Yunjin Date: Sat, 31 Jan 2026 19:28:43 +0900 Subject: [PATCH 3/5] fix: remove '-fno-asynchronous-unwind-tables' and add omitted -fno-strit-aliasing in 'src/nvidia/Makefile'. --- src/nvidia-modeset/Makefile | 1 - src/nvidia/Makefile | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/nvidia-modeset/Makefile b/src/nvidia-modeset/Makefile index 2a6271724..8d70f0e82 100644 --- a/src/nvidia-modeset/Makefile +++ b/src/nvidia-modeset/Makefile @@ -152,7 +152,6 @@ 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-register) CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch=thunk-extern) CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mharden-sls=all) diff --git a/src/nvidia/Makefile b/src/nvidia/Makefile index af50af329..06c612480 100644 --- a/src/nvidia/Makefile +++ b/src/nvidia/Makefile @@ -74,6 +74,7 @@ CFLAGS += -Werror-implicit-function-declaration CFLAGS += -Wwrite-strings CFLAGS += -Wundef CFLAGS += -fno-common +CFLAGS += -fno-strict-aliasing CFLAGS += -ffreestanding CFLAGS += -fno-stack-protector From edc5a652e61350729ce8c1026927443b3173e436 Mon Sep 17 00:00:00 2001 From: Lee Yunjin Date: Sat, 31 Jan 2026 22:38:53 +0900 Subject: [PATCH 4/5] Add -fno-asynchronous-unwind-tables to prevent build failure on Ubuntu --- src/nvidia-modeset/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/src/nvidia-modeset/Makefile b/src/nvidia-modeset/Makefile index 8d70f0e82..2c6ca74c3 100644 --- a/src/nvidia-modeset/Makefile +++ b/src/nvidia-modeset/Makefile @@ -152,6 +152,7 @@ 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-register) CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mindirect-branch=thunk-extern) CONDITIONAL_CFLAGS += $(call TEST_CC_ARG, -mharden-sls=all) From 2ed5d2f5e64b5d577eee7a1c8da89371584af55f Mon Sep 17 00:00:00 2001 From: Lee Yunjin Date: Sun, 1 Feb 2026 13:14:01 +0900 Subject: [PATCH 5/5] uvm: add order argument to zone_device_page_init for kernel commit 12b2285 --- kernel-open/nvidia-uvm/uvm_hmm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel-open/nvidia-uvm/uvm_hmm.c b/kernel-open/nvidia-uvm/uvm_hmm.c index f6e344f35..3b75b9078 100644 --- a/kernel-open/nvidia-uvm/uvm_hmm.c +++ b/kernel-open/nvidia-uvm/uvm_hmm.c @@ -2141,7 +2141,7 @@ static void fill_dst_pfn(uvm_va_block_t *va_block, UVM_ASSERT(!page_count(dpage)); UVM_ASSERT(!dpage->zone_device_data); #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 19, 0) - zone_device_page_init(dpage, 0); + zone_device_page_init(dpage, 0, 0); #else zone_device_page_init(dpage); #endif