diff --git a/kernel-open/nvidia-uvm/uvm_hmm.c b/kernel-open/nvidia-uvm/uvm_hmm.c index 9b676f971..3b75b9078 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, 0, 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 97ff13dcd..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,11 @@ 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) + .folio_free = devmem_folio_free, +#else .page_free = devmem_page_free, +#endif .migrate_to_ram = devmem_fault_entry, }; @@ -3148,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; @@ -3158,14 +3175,25 @@ 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) + .folio_free = device_coherent_folio_free, +#else .page_free = device_coherent_page_free, +#endif }; static NV_STATUS uvm_pmm_cdmm_init(uvm_parent_gpu_t *parent_gpu) @@ -3302,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..2c6ca74c3 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..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 @@ -160,7 +161,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 +185,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)