commit 799a1b3f62d727a481ce3c5a313fe8e93797d010
Author: Leigh Scott <leigh123linux(a)gmail.com>
Date: Tue Aug 13 13:55:55 2024 +0100
Add debian build fixes for kernel-6.10
kernel-610-buildfix.patch | 168 ++++++++++++++++++++++++++++++++++++++++++++++
nvidia-470xx-kmod.spec | 7 +-
2 files changed, 174 insertions(+), 1 deletion(-)
---
diff --git a/kernel-610-buildfix.patch b/kernel-610-buildfix.patch
new file mode 100644
index 0000000..f01f227
--- /dev/null
+++ b/kernel-610-buildfix.patch
@@ -0,0 +1,168 @@
+From 8ab6949372810eb4ea617b1c0ad42c07eec6c624 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Thu, 1 Feb 2024 14:58:45 -0500
+Subject: [PATCH] import pfn_valid() w/o GPL rcu_read_lock/unlock from v6.8-rc3
+
+linux-6.1.76, 6.6.15, and 6.7.3 have modified the non-ARCH-specific
+pfn_valid() to use __rcu_read_lock/unlock[1] that is marked GPL and
+cannot be used here[2][3][4] unless using the open source variant.
+
+pfn_valid() has been changed to use GPL rcu_read_lock/unlock by
+"mm/sparsemem: fix race in accessing memory_section->usage" in Linux
+ v6.8-rc1 (5ec8e8ea8b7783fab150cf86404fc38cb4db8800)
+which has been backported to Linux
+ v6.7.3 (3a01daace71b521563c38bbbf874e14c3e58adb7)
+ v6.6.15 (70064241f2229f7ba7b9599a98f68d9142e81a97)
+ v6.1.76 (68ed9e33324021e9d6b798e9db00ca3093d2012a)
+ v5.10.210 (90ad17575d26874287271127d43ef3c2af876cea)
+
+pfn_valid() has been further changed to use non-GPL
+rcu_read_lock_sched()/rcu_read_unlock_sched() by
+"mm, kmsan: fix infinite recursion due to RCU critical section" in Linux
+ v6.8-rc3 (f6564fce256a3944aa1bc76cb3c40e792d97c1eb)
+which has been backported to Linux
+ v6.7.4 (5a33420599fa0288792537e6872fd19cc8607ea6)
+ v6.6.16 (6335c0cdb2ea0ea02c999e04d34fd84f69fb27ff)
+ v6.1.77 (dc904345e3771aa01d0b8358b550802fdc6fe00b)
+but not (yet) to Linux v5.10.x
+
+As a workaround, use the v6.8-rc3 implementation for all kernels
+having only the first patch until NVIDIA makes a fixed release
+(that no longer will be using pfn_valid[5]).
+
+[1]
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/i...
+[2]
https://bugs.gentoo.org/923456
+[3]
https://forums.developer.nvidia.com/t/280908
+[4]
https://github.com/NVIDIA/open-gpu-kernel-modules/issues/594
+[5]
https://github.com/NVIDIA/open-gpu-kernel-modules/issues/594#issuecomment...
+
+Bug-Debian:
https://bugs.debian.org/1062932
+Origin: gentoo,
https://github.com/gentoo/gentoo/blob/c64caf53/x11-drivers/nvidia-drivers...
+---
+ common/inc/nv-linux.h | 33 +++++++++++++++++++++++++++++++++
+ 1 file changed, 33 insertions(+)
+
+diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
+index e095a89..a17fb08 100644
+--- a/common/inc/nv-linux.h
++++ b/common/inc/nv-linux.h
+@@ -2014,6 +2014,39 @@ static inline void nv_mutex_destroy(struct mutex *lock)
+
+ }
+
++#if (!defined(CONFIG_HAVE_ARCH_PFN_VALID)) && \
++ ((LINUX_VERSION_CODE == KERNEL_VERSION(6,7,3)) || \
++ (LINUX_VERSION_CODE == KERNEL_VERSION(6,6,15)) || \
++ (LINUX_VERSION_CODE == KERNEL_VERSION(6,1,76)) || \
++ ((LINUX_VERSION_CODE >= KERNEL_VERSION(5,10,210)) && (LINUX_VERSION_CODE
< KERNEL_VERSION(5,11,0))))
++
++/* Linux v6.8-rc3 pfn_valid version without GPL rcu_read_lock/unlock() */
++static inline int nv_pfn_valid(unsigned long pfn)
++{
++ struct mem_section *ms;
++ int ret;
++
++ 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);
++ rcu_read_lock_sched();
++ if (!valid_section(ms)) {
++ rcu_read_unlock_sched();
++ return 0;
++ }
++ ret = early_section(ms) || pfn_section_valid(ms, pfn);
++ rcu_read_unlock_sched();
++
++ return ret;
++}
++
++#else
++# define nv_pfn_valid pfn_valid
++#endif
++
+ #define NV_CHECK_EXPORT_SYMBOL(symbol) (NV_IS_EXPORT_SYMBOL_PRESENT_##symbol &&
\
+ !NV_IS_EXPORT_SYMBOL_GPL_##symbol)
+ #endif /* _NV_LINUX_H_ */
+From 910bd390666769db4e3522e01cabefceb1952947 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <anbe(a)debian.org>
+Date: Tue, 23 Jul 2024 21:49:33 +0200
+Subject: [PATCH] backport follow_pfn changes from 550.90.07
+
+---
+ conftest.sh | 16 +++++++++-------
+ nvidia/nvidia.Kbuild | 2 +-
+ nvidia/os-mlock.c | 6 +++---
+ 3 files changed, 13 insertions(+), 11 deletions(-)
+
+diff --git a/conftest.sh b/conftest.sh
+index 98af501..d5a5845 100755
+--- a/conftest.sh
++++ b/conftest.sh
+@@ -4685,20 +4685,22 @@ compile_test() {
+ compile_check_conftest "$CODE"
"NV_SG_PAGE_ITER_PAGE_PRESENT" "" "functions"
+ ;;
+
+- unsafe_follow_pfn)
++ follow_pfn)
+ #
+- # Determine if unsafe_follow_pfn() is present.
++ # Determine if follow_pfn() is present.
+ #
+- # unsafe_follow_pfn() was added by commit 69bacee7f9ad
+- # ("mm: Add unsafe_follow_pfn") in v5.13-rc1.
++ # follow_pfn() was added by commit 3b6748e2dd69
++ # ("mm: introduce follow_pfn()") in v2.6.31-rc1, and removed
++ # by commit 233eb0bf3b94 ("mm: remove follow_pfn")
++ # from linux-next 233eb0bf3b94.
+ #
+ CODE="
+ #include <linux/mm.h>
+- void conftest_unsafe_follow_pfn(void) {
+- unsafe_follow_pfn();
++ void conftest_follow_pfn(void) {
++ follow_pfn();
+ }"
+
+- compile_check_conftest "$CODE"
"NV_UNSAFE_FOLLOW_PFN_PRESENT" "" "functions"
++ compile_check_conftest "$CODE" "NV_FOLLOW_PFN_PRESENT"
"" "functions"
+ ;;
+
+ drm_plane_atomic_check_has_atomic_state_arg)
+diff --git a/nvidia/nvidia.Kbuild b/nvidia/nvidia.Kbuild
+index 44990d3..31a6f92 100644
+--- a/nvidia/nvidia.Kbuild
++++ b/nvidia/nvidia.Kbuild
+@@ -164,7 +164,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += cc_mkdec
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += iterate_fd
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += seq_read_iter
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += sg_page_iter_page
+-NV_CONFTEST_FUNCTION_COMPILE_TESTS += unsafe_follow_pfn
++NV_CONFTEST_FUNCTION_COMPILE_TESTS += follow_pfn
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_get
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_gem_object_put_unlocked
+ NV_CONFTEST_FUNCTION_COMPILE_TESTS += set_close_on_exec
+diff --git a/nvidia/os-mlock.c b/nvidia/os-mlock.c
+index fb0bcd3..607f2f1 100644
+--- a/nvidia/os-mlock.c
++++ b/nvidia/os-mlock.c
+@@ -17,10 +17,10 @@ static inline int nv_follow_pfn(struct vm_area_struct *vma,
+ unsigned long address,
+ unsigned long *pfn)
+ {
+-#if defined(NV_UNSAFE_FOLLOW_PFN_PRESENT)
+- return unsafe_follow_pfn(vma, address, pfn);
+-#else
++#if defined(NV_FOLLOW_PFN_PRESENT)
+ return follow_pfn(vma, address, pfn);
++#else
++ return -1;
+ #endif
+ }
+
+--
+2.20.1
+
+
diff --git a/nvidia-470xx-kmod.spec b/nvidia-470xx-kmod.spec
index ce06074..9bf41a9 100644
--- a/nvidia-470xx-kmod.spec
+++ b/nvidia-470xx-kmod.spec
@@ -12,7 +12,7 @@ Name: nvidia-470xx-kmod
Epoch: 3
Version: 470.256.02
# Taken over by kmodtool
-Release: 2%{?dist}
+Release: 3%{?dist}
License: Redistributable, no modification permitted
Summary: NVIDIA 470xx display driver kernel module
@@ -21,6 +21,7 @@ URL:
https://www.nvidia.com/
Source11: nvidia-470xx-kmodtool-excludekernel-filterfile
Patch0: gcc-14.patch
Patch1: nvidia-UBSAN.patch
+Patch2: kernel-610-buildfix.patch
# needed for plague to make sure it builds for i586 and i686
ExclusiveArch: x86_64
@@ -45,6 +46,7 @@ kmodtool --target %{_target_cpu} --repo rpmfusion --kmodname %{name}
--filterf
tar --use-compress-program xz -xf
%{_datadir}/%{name}-%{version}/%{name}-%{version}-%{_target_cpu}.tar.xz
%patch -P0 -p1
%patch -P1 -p1
+%patch -P2 -p1 -d kernel/
for kernel_version in %{?kernel_versions} ; do
cp -a kernel _kmod_build_${kernel_version%%___*}
done
@@ -75,6 +77,9 @@ done
%{?akmod_install}
%changelog
+* Tue Aug 13 2024 Leigh Scott <leigh123linux(a)gmail.com> - 3:470.256.02-3
+- Add debian build fixes for kernel-6.10
+
* Sat Aug 03 2024 RPM Fusion Release Engineering <sergiomb(a)rpmfusion.org> -
3:470.256.02-2
- Rebuilt for
https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild