-
Notifications
You must be signed in to change notification settings - Fork 1
/
buildfix_kernel_6.5-garbage-collect-all-references-to-get_user.patch
271 lines (265 loc) · 11.3 KB
/
buildfix_kernel_6.5-garbage-collect-all-references-to-get_user.patch
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
From 6fe0c6bd4b3bbac5cf868b927973255961b28ff4 Mon Sep 17 00:00:00 2001
From: Paolo Pisati <paolo.pisati@canonical.com>
Date: Tue, 18 Jul 2023 12:14:47 +0000
Subject: [PATCH 1/2] Linux 6.5: garbage collect all references to
get_user_pages_remote()
Upstream commit ca5e863233e8f6acd1792fd85d6bc2729a1b2c10 "mm/gup: remove
vmas parameter from get_user_pages_remote()" changed the API: since we
reference get_user_pages_remote() (but don't use it anywhere), garbage
collect all reference.
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
---
common/inc/nv-mm.h | 99 -------------
conftest.sh | 130 ------------------
2 files changed, 229 deletions(-)
diff --git a/common/inc/nv-mm.h b/common/inc/nv-mm.h
index aec55b0b..51d0df4a 100644
--- a/common/inc/nv-mm.h
+++ b/common/inc/nv-mm.h
@@ -98,105 +98,6 @@ typedef int vm_fault_t;
#endif
#endif
-/*
- * get_user_pages_remote() was added by commit 1e9877902dc7
- * ("mm/gup: Introduce get_user_pages_remote()") in v4.6 (2016-02-12).
- *
- * The very next commit cde70140fed8 ("mm/gup: Overload get_user_pages()
- * functions") deprecated the 8-argument version of get_user_pages for the
- * non-remote case (calling get_user_pages with current and current->mm).
- *
- * The guidelines are: call NV_GET_USER_PAGES_REMOTE if you need the 8-argument
- * version that uses something other than current and current->mm. Use
- * NV_GET_USER_PAGES if you are refering to current and current->mm.
- *
- * Note that get_user_pages_remote() requires the caller to hold a reference on
- * the task_struct (if non-NULL and if this API has tsk argument) and the mm_struct.
- * This will always be true when using current and current->mm. If the kernel passes
- * the driver a vma via driver callback, the kernel holds a reference on vma->vm_mm
- * over that callback.
- *
- * get_user_pages_remote() write/force parameters were replaced
- * with gup_flags by commit 9beae1ea8930 ("mm: replace get_user_pages_remote()
- * write/force parameters with gup_flags") in v4.9 (2016-10-13).
- *
- * get_user_pages_remote() added 'locked' parameter by commit 5b56d49fc31d
- * ("mm: add locked parameter to get_user_pages_remote()") in
- * v4.10 (2016-12-14).
- *
- * get_user_pages_remote() removed 'tsk' parameter by
- * commit 64019a2e467a ("mm/gup: remove task_struct pointer for
- * all gup code") in v5.9-rc1 (2020-08-11).
- *
- */
-
-#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
- #else
- static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk,
- struct mm_struct *mm,
- unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas)
- {
- unsigned int flags = 0;
-
- if (write)
- flags |= FOLL_WRITE;
- if (force)
- flags |= FOLL_FORCE;
-
- #if defined(NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG)
- #if defined (NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG)
- return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
- pages, vmas, NULL);
- #else
- return get_user_pages_remote(mm, start, nr_pages, flags,
- pages, vmas, NULL);
- #endif
-
- #else
-
- return get_user_pages_remote(tsk, mm, start, nr_pages, flags,
- pages, vmas);
-
- #endif
-
- }
- #endif
-#else
- #if defined(NV_GET_USER_PAGES_HAS_WRITE_AND_FORCE_ARGS)
- #define NV_GET_USER_PAGES_REMOTE NV_GET_USER_PAGES
- #else
- #include <linux/mm.h>
- #include <linux/sched.h>
-
- static inline long NV_GET_USER_PAGES_REMOTE(struct task_struct *tsk,
- struct mm_struct *mm,
- unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas)
- {
- unsigned int flags = 0;
-
- if (write)
- flags |= FOLL_WRITE;
- if (force)
- flags |= FOLL_FORCE;
-
- return get_user_pages(tsk, mm, start, nr_pages, flags, pages, vmas);
- }
- #endif
-#endif
-
-
/*
* The .virtual_address field was effectively renamed to .address, by these
* two commits:
diff --git a/conftest.sh b/conftest.sh
index 24daa850..abe435ff 100755
--- a/conftest.sh
+++ b/conftest.sh
@@ -3081,136 +3081,6 @@ compile_test() {
return
;;
- get_user_pages_remote)
- #
- # Determine if the function get_user_pages_remote() is
- # present and has write/force/locked/tsk parameters.
- #
- # get_user_pages_remote() was added by:
- # 2016 Feb 12: 1e9877902dc7e11d2be038371c6fbf2dfcd469d7
- #
- # get_user_pages[_remote]() write/force parameters
- # replaced with gup_flags:
- # 2016 Oct 12: 768ae309a96103ed02eb1e111e838c87854d8b51
- # 2016 Oct 12: 9beae1ea89305a9667ceaab6d0bf46a045ad71e7
- #
- # get_user_pages_remote() added 'locked' parameter
- # 2016 Dec 14:5b56d49fc31dbb0487e14ead790fc81ca9fb2c99
- #
- # get_user_pages_remote() removed 'tsk' parameter by
- # commit 64019a2e467a ("mm/gup: remove task_struct pointer for
- # all gup code") in v5.9-rc1 (2020-08-11).
- #
- # conftest #1: check if get_user_pages_remote() is available
- # return if not available.
- # Fall through to conftest #2 if it is present
-
- echo "$CONFTEST_PREAMBLE
- #include <linux/mm.h>
- void conftest_get_user_pages_remote(void) {
- get_user_pages_remote();
- }" > conftest$$.c
-
- $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
- rm -f conftest$$.c
-
- if [ -f conftest$$.o ]; then
- echo "#undef NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
- rm -f conftest$$.o
- return
- fi
-
- # conftest #2: check if get_user_pages_remote() has write and
- # force arguments. Return if these arguments are present
- # Fall through to conftest #3 if these args are absent.
- echo "#define NV_GET_USER_PAGES_REMOTE_PRESENT" | append_conftest "functions"
- echo "$CONFTEST_PREAMBLE
- #include <linux/mm.h>
- long get_user_pages_remote(struct task_struct *tsk,
- struct mm_struct *mm,
- unsigned long start,
- unsigned long nr_pages,
- int write,
- int force,
- struct page **pages,
- struct vm_area_struct **vmas) {
- 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_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
- echo "#define NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
- rm -f conftest$$.o
- return
- fi
-
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_WRITE_AND_FORCE_ARGS" | append_conftest "functions"
-
- #
- # conftest #3: check if get_user_pages_remote() has locked argument
- # Return if these arguments are present. Fall through to conftest #4
- # if these args are absent.
- #
- echo "$CONFTEST_PREAMBLE
- #include <linux/mm.h>
- long get_user_pages_remote(struct task_struct *tsk,
- struct mm_struct *mm,
- unsigned long start,
- unsigned long nr_pages,
- unsigned int gup_flags,
- struct page **pages,
- struct vm_area_struct **vmas,
- int *locked) {
- 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_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
- echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
- rm -f conftest$$.o
- return
- fi
-
- #
- # conftest #4: check if get_user_pages_remote() does not take
- # tsk argument.
- #
- echo "$CONFTEST_PREAMBLE
- #include <linux/mm.h>
- long get_user_pages_remote(struct mm_struct *mm,
- unsigned long start,
- unsigned long nr_pages,
- unsigned int gup_flags,
- struct page **pages,
- struct vm_area_struct **vmas,
- int *locked) {
- return 0;
- }" > conftest$$.c
-
- $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
- rm -f conftest$$.c
-
- if [ -f conftest$$.o ]; then
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
- echo "#define NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
- rm -f conftest$$.o
- else
-
- echo "#define NV_GET_USER_PAGES_REMOTE_HAS_TSK_ARG" | append_conftest "functions"
- echo "#undef NV_GET_USER_PAGES_REMOTE_HAS_LOCKED_ARG" | append_conftest "functions"
- fi
- ;;
-
usleep_range)
#
# Determine if the function usleep_range() is present.
--
2.40.1