Package: release.debian.org
Severity: normal
Tags: bullseye
User: release.debian....@packages.debian.org
Usertags: pu

[ Reason ]
Two commits from Linux 6.8 got backported to Linux 6.1, but only one
of them got backported to Linux 5.10, causing the use of GPL-only
symbols (on ppc64el only) from 5.10.210 onwards.
We already had fixed this in the previous point release in
  nvidia-graphics-drivers 470.256.02-2 and
  nvidia-graphics-drivers-tesla-470 470.256.02-1~deb11u2
but the Tesla 418/450/460 packages are affected as well.

[ Impact ]
dkms module failing to build on ppc64el

[ Tests ]
Manual module build test in bullseye ppc64el chroot.
The package has autopkgtest-pkg-dkms, but that is not run by
dkms/bullseye.

[ Risks ]
Low. The changes have already been tested in the 470 driver series.

[ Checklist ]
  [*] *all* changes are documented in the d/changelog
  [*] I reviewed all changes and I approve them
  [*] attach debdiff against the package in (old)stable
  [*] the issue is verified as fixed in unstable

[ Changes ]
+nvidia-graphics-drivers-tesla-418 (418.226.00-6~deb11u2) bullseye; 
urgency=medium
+
+  * Cherry-pick ppc64el changes from 418.226.00-16.
+  * Backport pfn_valid changes in nv-mmap.c from 470.239.06.
+  * ppc64el: Use pfn_valid() variant with rcu_read_{,un}lock_sched() for
+    Linux 5.10 from 5.10.210 onwards to avoid using GPL symbols.
+
+ -- Andreas Beckmann <a...@debian.org>  Sun, 04 Aug 2024 16:41:41 +0200

[ Other info ]
I'm not rebuilding the package from sid this time since that contains
some changes not suitable for bullseye as I had not expected to need
updating the package again in bullseye after it got EoLed upstream.

I'm going to upload this change right now.


Andreas
diff --git a/debian/changelog b/debian/changelog
index 45fd50b05..414961dc3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+nvidia-graphics-drivers-tesla-418 (418.226.00-6~deb11u2) bullseye; 
urgency=medium
+
+  * Cherry-pick ppc64el changes from 418.226.00-16.
+  * Backport pfn_valid changes in nv-mmap.c from 470.239.06.
+  * ppc64el: Use pfn_valid() variant with rcu_read_{,un}lock_sched() for
+    Linux 5.10 from 5.10.210 onwards to avoid using GPL symbols.
+
+ -- Andreas Beckmann <a...@debian.org>  Sun, 04 Aug 2024 16:41:41 +0200
+
 nvidia-graphics-drivers-tesla-418 (418.226.00-6~deb11u1) bullseye; 
urgency=medium
 
   * Rebuild for bullseye.
diff --git a/debian/gbp.conf b/debian/gbp.conf
index 415779ad1..31f6e0c17 100644
--- a/debian/gbp.conf
+++ b/debian/gbp.conf
@@ -1,5 +1,5 @@
 [DEFAULT]
-debian-branch = tesla-418/master
+debian-branch = tesla-418/bullseye
 
 [buildpackage]
 overlay = True
diff --git 
a/debian/module/debian/patches/0036-backport-pfn_valid-changes-in-nv-mmap.c-from-470.239.patch
 
b/debian/module/debian/patches/0036-backport-pfn_valid-changes-in-nv-mmap.c-from-470.239.patch
new file mode 100644
index 000000000..330122f5c
--- /dev/null
+++ 
b/debian/module/debian/patches/0036-backport-pfn_valid-changes-in-nv-mmap.c-from-470.239.patch
@@ -0,0 +1,39 @@
+From 63d49836d41809282dce33126a0117d51d1d6834 Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <a...@debian.org>
+Date: Sun, 25 Feb 2024 09:38:15 +0100
+Subject: [PATCH] backport pfn_valid changes in nv-mmap.c from 470.239.06
+
+---
+ nvidia/nv-mmap.c | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/nvidia/nv-mmap.c b/nvidia/nv-mmap.c
+index 29ac828..af53116 100644
+--- a/nvidia/nv-mmap.c
++++ b/nvidia/nv-mmap.c
+@@ -13,6 +13,7 @@
+ 
+ #include "os-interface.h"
+ #include "nv-linux.h"
++#include "nv-ibmnpu.h"
+ #include "nv_speculation_barrier.h"
+ 
+ extern nv_cpu_type_t nv_cpu_type;
+@@ -461,11 +462,10 @@ 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
+-        // backing struct page. This is used to isolate P8 from P9. 
+         //
+-        if (!IS_REG_OFFSET(nv, access_start, access_len) && 
+-            (pfn_valid(PFN_DOWN(mmap_start))))
++        nv_linux_state_t *nvl = NV_GET_NVL_FROM_NV_STATE(nv);
++        if ((nv_get_numa_status(nvl) == NV_NUMA_STATUS_ONLINE) &&
++            !IS_REG_OFFSET(nv, access_start, access_len))
+         {
+             ret = nvidia_mmap_numa(vma, mmap_context);
+             if (ret)
+-- 
+2.20.1
+
diff --git 
a/debian/module/debian/patches/0044-use-pfn_valid-variant-with-rcu_read_-un-lock_sched.patch
 
b/debian/module/debian/patches/0044-use-pfn_valid-variant-with-rcu_read_-un-lock_sched.patch
new file mode 100644
index 000000000..e80d0ade7
--- /dev/null
+++ 
b/debian/module/debian/patches/0044-use-pfn_valid-variant-with-rcu_read_-un-lock_sched.patch
@@ -0,0 +1,80 @@
+From 2d0d2cad42331b75fcff6f0492d69cbc3a1d47ab Mon Sep 17 00:00:00 2001
+From: Andreas Beckmann <a...@debian.org>
+Date: Mon, 24 Jun 2024 02:31:03 +0200
+Subject: [PATCH] use pfn_valid() variant with rcu_read_{,un}lock_sched()
+
+---
+ common/inc/nv-linux.h | 45 +++++++++++++++++++++++++++++++++++++++++++
+ nvidia/nv-vtophys.c   |  2 +-
+ 2 files changed, 46 insertions(+), 1 deletion(-)
+
+diff --git a/common/inc/nv-linux.h b/common/inc/nv-linux.h
+index 0b5b0db..21a6b7a 100644
+--- a/common/inc/nv-linux.h
++++ b/common/inc/nv-linux.h
+@@ -2050,4 +2050,49 @@ static inline NvU32 nv_default_irq_flags(nv_state_t *nv)
+ #include <linux/backlight.h>
+ #endif
+ 
++#if defined(CONFIG_HAVE_ARCH_PFN_VALID) || \
++      !defined(NVCPU_PPC64LE) || \
++      LINUX_VERSION_CODE < KERNEL_VERSION(5,10,210) || \
++      LINUX_VERSION_CODE > KERNEL_VERSION(5,11,0)
++#  define nv_virt_addr_valid virt_addr_valid
++#else
++/* - based on pfn_valid() from v5.10.210 which uses
++     rcu_read_lock()/rcu_read_unlock() from
++     5ec8e8ea8b7783fab150cf86404fc38cb4db8800 (v6.8-rc1/v6.1.76)
++   - applied rcu_read_lock_sched()/rcu_read_unlock_sched() switch from
++     f6564fce256a3944aa1bc76cb3c40e792d97c1eb (v6.8-rc3/v6.1.77)
++     which is not yet backported to 5.10
++*/
++static inline int nv_pfn_valid(unsigned long pfn)
++{
++        struct mem_section *ms;
++        int ret;
++
++        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;
++        }
++        /*
++         * Traditionally early sections always returned pfn_valid() for
++         * the entire section-sized span.
++         */
++        ret = early_section(ms) || pfn_section_valid(ms, pfn);
++        rcu_read_unlock_sched();
++
++        return ret;
++}
++
++#define nv_virt_addr_valid(vaddr)  ({                                   \
++        unsigned long _addr = (unsigned long)vaddr;                     \
++        _addr >= PAGE_OFFSET && _addr < (unsigned long)high_memory &&   \
++        nv_pfn_valid(virt_to_pfn(_addr));                               \
++})
++#endif
++
++#define NV_CHECK_EXPORT_SYMBOL(symbol)  (NV_IS_EXPORT_SYMBOL_PRESENT_##symbol 
&& \
++                                         !NV_IS_EXPORT_SYMBOL_GPL_##symbol)
+ #endif  /* _NV_LINUX_H_ */
+diff --git a/nvidia/nv-vtophys.c b/nvidia/nv-vtophys.c
+index 9c8d4ef..02c3068 100644
+--- a/nvidia/nv-vtophys.c
++++ b/nvidia/nv-vtophys.c
+@@ -28,7 +28,7 @@ NvU64 NV_API_CALL nv_get_kern_phys_address(NvU64 address)
+ #endif
+ 
+     /* direct-mapped kernel address */
+-    if (virt_addr_valid(address))
++    if (nv_virt_addr_valid(address))
+         return __pa(address);
+ 
+     nv_printf(NV_DBG_ERRORS,
+-- 
+2.20.1
+
diff --git a/debian/module/debian/patches/series.in 
b/debian/module/debian/patches/series.in
index e43f0c42f..c20226964 100644
--- a/debian/module/debian/patches/series.in
+++ b/debian/module/debian/patches/series.in
@@ -11,6 +11,8 @@
 0011-backport-iosys_map-changes-from-470.129.06.patch
 0012-backport-dma_set_coherent_mask-from-470.129.06.patch
 0013-backport-acpi_bus_get_device-changes-from-470.129.06.patch
+0036-backport-pfn_valid-changes-in-nv-mmap.c-from-470.239.patch
+0044-use-pfn_valid-variant-with-rcu_read_-un-lock_sched.patch
 
 # build system updates
 bashisms.patch

Reply via email to