summarylogtreecommitdiffstats
path: root/0014-kernel-6.5.patch
blob: 811afdd6ded72e331d32a645d5005d7f6c684fd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
diff -Naur a/kernel/conftest.sh b/kernel/conftest.sh
--- a/kernel/conftest.sh	2023-09-09 04:19:11.170064889 +0000
+++ b/kernel/conftest.sh	2023-09-09 04:21:10.593482047 +0000
@@ -1977,6 +1977,30 @@
                 return
             fi
 
+            # Conftest #4: check if vma arg was dropped
+            # Return if available.
+            # Fall through to default case if absent.
+
+            echo "$CONFTEST_PREAMBLE
+            #include <linux/mm.h>
+            long get_user_pages(unsigned long start,
+                                unsigned long nr_pages,
+                                unsigned int gup_flags,
+                                struct page **pages) {
+                return 0;
+            }" > conftest$$.c
+
+            $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+            rm -f conftest$$.c
+
+            if [ -f conftest$$.o ]; then
+                echo "#define NV_GET_USER_PAGES_DROPPED_VMA" | append_conftest "functions"
+                echo "#undef NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
+                echo "#undef NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
+                rm -f conftest$$.o
+                return
+            fi
+
             
             echo "#define NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
             echo "#define NV_GET_USER_PAGES_HAS_TASK_STRUCT" | append_conftest "functions"
@@ -1985,6 +2009,8 @@
         ;;
 
         get_user_pages_remote)
+            echo "#define NV_GET_USER_PAGES_REMOTE_UNUSED" | append_conftest "functions"
+            return
             #
             # Determine if the function get_user_pages_remote() is
             # present and has write/force parameters.
diff -Naur a/kernel/nv-linux.h b/kernel/nv-linux.h
--- a/kernel/nv-linux.h	2023-09-09 04:19:11.163398218 +0000
+++ b/kernel/nv-linux.h	2023-09-09 04:21:36.163499676 +0000
@@ -2205,7 +2205,11 @@
             if (force)
                 flags |= FOLL_FORCE;
 
-            return get_user_pages(start, nr_pages, flags, pages, vmas);
+            #if defined(NV_GET_USER_PAGES_DROPPED_VMA)
+                return get_user_pages(start, nr_pages, flags, pages);
+            #else
+                return get_user_pages(start, nr_pages, flags, pages, vmas);
+            #endif
         }
     #endif
 #endif
@@ -2231,6 +2235,8 @@
  *   2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99
  */
 
+#if defined(NV_GET_USER_PAGES_REMOTE_UNUSED)
+#else
 #if defined(NV_GET_USER_PAGES_REMOTE_PRESENT)
     #if defined (NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS)
         #define NV_GET_USER_PAGES_REMOTE get_user_pages_remote
@@ -2295,5 +2301,6 @@
         }
     #endif
 #endif
+#endif
 
 #endif  /* _NV_LINUX_H_ */