commit 6c9d396dad3e8fd0e89f9b93a4774016d4ba9528
Author: Leigh Scott <leigh123linux(a)gmail.com>
Date: Thu Feb 1 22:57:55 2024 +0000
fix build with gcc-14 ad kernel-6.7.3
gcc14.patch | 15 ++++++++++++
kernel-6.7.3.patch | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
nvidia-kmod.spec | 4 ++++
3 files changed, 87 insertions(+)
---
diff --git a/gcc14.patch b/gcc14.patch
new file mode 100644
index 0000000..9165694
--- /dev/null
+++ b/gcc14.patch
@@ -0,0 +1,15 @@
+--- a/kernel/conftest.sh
++++ b/kernel/conftest.sh
+@@ -5155,6 +5155,11 @@
+ CODE="
+ #include <drm/drm_gem.h>
++ #if defined(NV_LINUX_IOSYS_MAP_H_PRESENT)
++ typedef struct iosys_map nv_sysio_map_t;
++ #else
++ typedef struct dma_buf_map nv_sysio_map_t;
++ #endif
+ int conftest_drm_gem_object_vmap_has_map_arg(
+- struct drm_gem_object *obj, struct dma_buf_map *map) {
++ struct drm_gem_object *obj, nv_sysio_map_t *map) {
+ return obj->funcs->vmap(obj, map);
+ }"
diff --git a/kernel-6.7.3.patch b/kernel-6.7.3.patch
new file mode 100644
index 0000000..4eae1ea
--- /dev/null
+++ b/kernel-6.7.3.patch
@@ -0,0 +1,68 @@
+diff -uNrp a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h
+--- a/kernel/common/inc/nv-linux.h 2024-01-18 08:06:58.000000000 +0000
++++ b/kernel/common/inc/nv-linux.h 2024-02-01 22:27:07.734667760 +0000
+@@ -2074,4 +2074,25 @@ typedef enum
+ #define NV_CHECK_EXPORT_SYMBOL(symbol) (NV_IS_EXPORT_SYMBOL_PRESENT_##symbol &&
\
+ !NV_IS_EXPORT_SYMBOL_GPL_##symbol)
+
++#if defined(CONFIG_HAVE_ARCH_PFN_VALID) || LINUX_VERSION_CODE <
KERNEL_VERSION(6,1,76)
++# define nv_pfn_valid pfn_valid
++#else
++/* pre-6.1.76 kernel pfn_valid version without GPL rcu_read_lock/unlock() */
++static inline int nv_pfn_valid(unsigned long pfn)
++{
++ struct mem_section *ms;
++
++ if (PHYS_PFN(PFN_PHYS(pfn)) != pfn)
++ return 0;
++
++ if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
++ return 0;
++
++ ms = __pfn_to_section(pfn);
++ if (!valid_section(ms))
++ return 0;
++
++ return early_section(ms) || pfn_section_valid(ms, pfn);
++}
++#endif
+ #endif /* _NV_LINUX_H_ */
+diff -uNrp a/kernel/nvidia/nv-mmap.c b/kernel/nvidia/nv-mmap.c
+--- a/kernel/nvidia/nv-mmap.c 2024-01-18 08:06:58.000000000 +0000
++++ b/kernel/nvidia/nv-mmap.c 2024-02-01 22:29:13.752956449 +0000
+@@ -577,12 +577,12 @@ int nvidia_mmap_helper(
+ //
+ // This path is similar to the sysmem mapping code.
+ // TODO: Refactor is needed as part of bug#2001704.
+- // Use pfn_valid to determine whether the physical address has
++ // Use nv_pfn_valid to determine whether the physical address has
+ // backing struct page. This is used to isolate P8 from P9.
+ //
+ if ((nv_get_numa_status(nvl) == NV_NUMA_STATUS_ONLINE) &&
+ !IS_REG_OFFSET(nv, access_start, access_len) &&
+- (pfn_valid(PFN_DOWN(mmap_start))))
++ (nv_pfn_valid(PFN_DOWN(mmap_start))))
+ {
+ ret = nvidia_mmap_numa(vma, mmap_context);
+ if (ret)
+diff -uNrp a/kernel/nvidia/os-mlock.c b/kernel/nvidia/os-mlock.c
+--- a/kernel/nvidia/os-mlock.c 2024-01-18 08:06:58.000000000 +0000
++++ b/kernel/nvidia/os-mlock.c 2024-02-01 22:29:48.584574014 +0000
+@@ -113,7 +113,7 @@ static NV_STATUS get_io_pages(struct vm_
+ for (i = 0; i < page_count; i++)
+ {
+ if ((nv_follow_pfn(vma, (start + (i * PAGE_SIZE)), &pfn) < 0) ||
+- (!pfn_valid(pfn)))
++ (!nv_pfn_valid(pfn)))
+ {
+ rmStatus = NV_ERR_INVALID_ADDRESS;
+ break;
+@@ -187,7 +187,7 @@ NV_STATUS NV_API_CALL os_lookup_user_io_
+ goto done;
+ }
+
+- if (pfn_valid(pfn))
++ if (nv_pfn_valid(pfn))
+ {
+ rmStatus = get_io_pages(vma, start, page_count, (struct page **)result_array);
+ if (rmStatus == NV_OK)
diff --git a/nvidia-kmod.spec b/nvidia-kmod.spec
index 457fe05..2a2024b 100644
--- a/nvidia-kmod.spec
+++ b/nvidia-kmod.spec
@@ -19,6 +19,8 @@ URL:
https://www.nvidia.com/
Source11: nvidia-kmodtool-excludekernel-filterfile
Patch0: make_modeset_default.patch
+Patch1: kernel-6.7.3.patch
+Patch2: gcc14.patch
# needed for plague to make sure it builds for i586 and i686
ExclusiveArch: x86_64 aarch64
@@ -53,6 +55,8 @@ echo "Using original nvidia defaults"
echo "Set nvidia to fbdev=1 modeset=1"
%patch -P0 -p1
%endif
+%patch -P1 -p1
+%patch -P2 -p1
for kernel_version in %{?kernel_versions} ; do
cp -a kernel _kmod_build_${kernel_version%%___*}
done