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
|
--- a/kernel/conftest.sh 2025-07-27 23:48:51.829248168 +0000
+++ b/kernel/conftest.sh 2025-07-27 23:52:39.483549229 +0000
@@ -196,7 +196,7 @@
}
build_cflags() {
- BASE_CFLAGS="-std=gnu17 -O2 -Wno-implicit-function-declaration -Wno-incompatible-pointer-types -D__KERNEL__ \
+ BASE_CFLAGS="-I${SCRIPTDIR} -std=gnu17 -O2 -Wno-implicit-function-declaration -Wno-incompatible-pointer-types -D__KERNEL__ \
-DKBUILD_BASENAME=\"#conftest$$\" -DKBUILD_MODNAME=\"#conftest$$\" \
-nostdinc -isystem $ISYSTEM"
--- a/kernel/Makefile 2025-07-27 23:48:51.675247965 +0000
+++ b/kernel/Makefile 2025-07-27 23:52:39.487837357 +0000
@@ -164,16 +164,16 @@
#
ifdef NV_BUILD_MODULE_INSTANCES
- EXTRA_CFLAGS += -DNV_BUILD_MODULE_INSTANCES=1
+ ccflags-y += -DNV_BUILD_MODULE_INSTANCES=1
ifneq ($(NV_MODULE_SUFFIX),frontend)
- EXTRA_CFLAGS += -DNV_MODULE_INSTANCE=$(NV_MODULE_SUFFIX)
+ ccflags-y += -DNV_MODULE_INSTANCE=$(NV_MODULE_SUFFIX)
endif
else
- EXTRA_CFLAGS += -DNV_MODULE_INSTANCE=0
- EXTRA_CFLAGS += -DNV_BUILD_MODULE_INSTANCES=0
+ ccflags-y += -DNV_MODULE_INSTANCE=0
+ ccflags-y += -DNV_BUILD_MODULE_INSTANCES=0
endif
-EXTRA_CFLAGS += -UDEBUG -U_DEBUG -DNDEBUG
+ccflags-y += -UDEBUG -U_DEBUG -DNDEBUG
#
# Include common definitions; we rely on the definition of the source path to
--- a/kernel/nv.c 2025-07-27 23:48:51.713423001 +0000
+++ b/kernel/nv.c 2025-07-27 23:52:39.488549236 +0000
@@ -2447,7 +2447,13 @@
nv_printf(NV_DBG_INFO, "NVRM: stopping rc timer\n");
nv->rc_timer_enabled = 0;
+// Rel. commit "treewide: Switch/rename to timer_delete[_sync]()" (Thomas Gleixner, 5 Apr 2025)
+// This provides a shim for ancient kernels before timer_delete_sync was introduced
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
+ timer_delete_sync(&nvl->rc_timer);
+#else
del_timer_sync(&nvl->rc_timer);
+#endif
nv_printf(NV_DBG_INFO, "NVRM: rc timer stopped\n");
return 0;
--- a/kernel/nvidia-modules-common.mk 2025-07-27 23:48:51.832248172 +0000
+++ b/kernel/nvidia-modules-common.mk 2025-07-27 23:54:45.204715783 +0000
@@ -37,8 +37,9 @@
# warning types that are of little interest to us.
#
-EXTRA_CFLAGS += -I$(src)
-EXTRA_CFLAGS += -Wall -MD $(DEFINES) $(INCLUDES) -Wsign-compare -Wno-cast-qual -Wno-error
+ccflags-y += -std=gnu17
+ccflags-y += -I$(src)
+ccflags-y += -Wall -MD $(DEFINES) $(INCLUDES) -Wno-cast-qual -Wno-error -Wno-format-extra-args
#
# Output directory for the build; default to the source directory if not set.
@@ -116,13 +117,13 @@
# NVIDIA specific CFLAGS and #define's.
#
-EXTRA_CFLAGS += -std=gnu17 -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"340.108\" -Wno-unused-function -Wuninitialized -fno-strict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE -D__linux__ -DNV_DEV_NAME=\"$(MODULE_NAME)\"
+ccflags-y += -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"340.108\" -Wno-unused-function -Wuninitialized -fno-strict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE -D__linux__ -DNV_DEV_NAME=\"$(MODULE_NAME)\"
#
# Detect SGI UV systems and apply system-specific optimizations.
#
ifneq ($(wildcard /proc/sgi_uv),)
- EXTRA_CFLAGS += -DNV_CONFIG_X86_UV
+ ccflags-y += -DNV_CONFIG_X86_UV
endif
#
@@ -306,6 +307,8 @@
# kernel interface is built.
#
+nvidia.o: override objtool-enabled =
+
$(KERNEL_GLUE_NAME): $(MODULE_OBJECT)
@$(LD) $(EXTRA_LDFLAGS) $(MODULE_COMMON_SCRIPT) -r -o $(KERNEL_GLUE_NAME) $(KERNEL_GLUE_OBJS)
--- a/kernel/nv-linux.h 2025-07-27 23:48:51.807560718 +0000
+++ b/kernel/nv-linux.h 2025-07-27 23:52:39.493549243 +0000
@@ -2303,4 +2303,39 @@
#endif
#endif
+static inline void nv_vm_flags_set(struct vm_area_struct *vma, vm_flags_t flags)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
+ // Rel. commit "mm: uninline the main body of vma_start_write()" (Suren Baghdasaryan, 13 Feb 2025)
+ // Since Linux 6.15, vm_flags_set and vm_flags_clear call a GPL-only symbol
+ // for locking (__vma_start_write), which can't be called from non-GPL code.
+ // However, it appears all uses on the driver are on VMAs being initially
+ // mapped / which are already locked, so we can use vm_flags_reset, which
+ // doesn't lock the VMA, but rather just asserts it is already write-locked.
+ vm_flags_reset(vma, vma->vm_flags | flags);
+#else
+ vm_flags_set(vma, flags);
+#endif
+}
+
+static inline void nv_vm_flags_clear(struct vm_area_struct *vma, vm_flags_t flags)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
+ // Rel. commit "mm: uninline the main body of vma_start_write()" (Suren Baghdasaryan, 13 Feb 2025)
+ // See above
+ vm_flags_reset(vma, vma->vm_flags & ~flags);
+#else
+ vm_flags_clear(vma, flags);
+#endif
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 2, 0)
+// Rel. commit "treewide: Switch/rename to timer_delete[_sync]()" (Thomas Gleixner, 5 Apr 2025)
+// This provides a shim for ancient kernels before timer_delete_sync was introduced
+static inline int timer_delete_sync(struct timer_list *timer)
+{
+ return del_timer_sync(timer);
+}
+#endif
+
#endif /* _NV_LINUX_H_ */
--- a/kernel/nv-mmap.c 2025-07-27 23:48:51.796004133 +0000
+++ b/kernel/nv-mmap.c 2025-07-27 23:52:39.498549249 +0000
@@ -313,7 +313,7 @@
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
- vm_flags_set(vma, VM_IO);
+ nv_vm_flags_set(vma, VM_IO);
#else
vma->vm_flags |= VM_IO;
#endif
@@ -368,8 +368,8 @@
NV_PRINT_AT(NV_DBG_MEMINFO, at);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
- vm_flags_set(vma, VM_IO | VM_LOCKED | VM_RESERVED);
- vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP);
+ nv_vm_flags_set(vma, VM_IO | VM_LOCKED | VM_RESERVED);
+ nv_vm_flags_set(vma, VM_DONTEXPAND | VM_DONTDUMP);
#else
vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED);
vma->vm_flags |= (VM_DONTEXPAND | VM_DONTDUMP);
--- a/kernel/uvm/nvidia_uvm_common.c 2019-12-11 22:04:24.000000000 +0000
+++ b/kernel/uvm/nvidia_uvm_common.c 2025-07-28 00:07:11.804439538 +0000
@@ -355,5 +355,6 @@
module_init(uvm_init);
module_exit(uvm_exit);
+MODULE_DESCRIPTION("NVIDIA GPU UVM kernel module");
MODULE_LICENSE("MIT");
MODULE_INFO(supported, "external");
--- a/kernel/uvm/nvidia_uvm_linux.h 2025-07-27 23:48:51.737065000 +0000
+++ b/kernel/uvm/nvidia_uvm_linux.h 2025-07-27 23:52:39.499549251 +0000
@@ -451,5 +451,31 @@
}
#endif
+static inline void nv_vm_flags_set(struct vm_area_struct *vma, vm_flags_t flags)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
+ // Rel. commit "mm: uninline the main body of vma_start_write()" (Suren Baghdasaryan, 13 Feb 2025)
+ // Since Linux 6.15, vm_flags_set and vm_flags_clear call a GPL-only symbol
+ // for locking (__vma_start_write), which can't be called from non-GPL code.
+ // However, it appears all uses on the driver are on VMAs being initially
+ // mapped / which are already locked, so we can use vm_flags_reset, which
+ // doesn't lock the VMA, but rather just asserts it is already write-locked.
+ vm_flags_reset(vma, vma->vm_flags | flags);
+#else
+ vm_flags_set(vma, flags);
+#endif
+}
+
+static inline void nv_vm_flags_clear(struct vm_area_struct *vma, vm_flags_t flags)
+{
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 15, 0)
+ // Rel. commit "mm: uninline the main body of vma_start_write()" (Suren Baghdasaryan, 13 Feb 2025)
+ // See above
+ vm_flags_reset(vma, vma->vm_flags & ~flags);
+#else
+ vm_flags_clear(vma, flags);
+#endif
+}
+
#endif // _NVIDIA_UVM_LINUX_H
--- a/kernel/uvm/nvidia_uvm_lite.c 2025-07-27 23:48:51.797446558 +0000
+++ b/kernel/uvm/nvidia_uvm_lite.c 2025-07-28 00:14:58.937339255 +0000
@@ -1526,9 +1526,9 @@
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
// Prohibit copying the vma on fork().
- vm_flags_set(vma, VM_DONTCOPY);
+ nv_vm_flags_set(vma, VM_DONTCOPY);
// Prohibt mremap() that would expand the vma.
- vm_flags_set(vma, VM_DONTEXPAND);
+ nv_vm_flags_set(vma, VM_DONTEXPAND);
#else
// Prohibit copying the vma on fork().
vma->vm_flags |= VM_DONTCOPY;
@@ -1554,9 +1554,9 @@
vma->vm_ops = &counters_vma_ops;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
- vm_flags_clear(vma, VM_MAYWRITE);
+ nv_vm_flags_clear(vma, VM_MAYWRITE);
// prevent vm_insert_page from modifying the vma's flags:
- vm_flags_set(vma, VM_MIXEDMAP);
+ nv_vm_flags_set(vma, VM_MIXEDMAP);
#else
vma->vm_flags &= ~VM_MAYWRITE;
// prevent vm_insert_page from modifying the vma's flags:
@@ -2541,8 +2541,8 @@
// a SIGSEGV.
//
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
- vm_flags_clear(vma, VM_READ|VM_MAYREAD);
- vm_flags_clear(vma, VM_WRITE|VM_MAYWRITE);
+ nv_vm_flags_clear(vma, VM_READ|VM_MAYREAD);
+ nv_vm_flags_clear(vma, VM_WRITE|VM_MAYWRITE);
#else
vma->vm_flags &= ~(VM_READ|VM_MAYREAD);
vma->vm_flags &= ~(VM_WRITE|VM_MAYWRITE);
@@ -2555,8 +2555,8 @@
static void _set_vma_accessible(struct vm_area_struct * vma)
{
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
- vm_flags_set(vma, VM_READ|VM_MAYREAD);
- vm_flags_set(vma, VM_WRITE|VM_MAYWRITE);
+ nv_vm_flags_set(vma, VM_READ|VM_MAYREAD);
+ nv_vm_flags_set(vma, VM_WRITE|VM_MAYWRITE);
#else
vma->vm_flags |= (VM_READ|VM_MAYREAD);
vma->vm_flags |= (VM_WRITE|VM_MAYWRITE);
|