summarylogtreecommitdiffstats
path: root/0013-kernel-6.3.patch
blob: 86bdc01f99174a3c63943631ad43dfee90dc78e7 (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
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
--- a/kernel/nv-mmap.c	2023-05-03 11:48:48.481814709 +0200
+++ b/kernel/nv-mmap.c	2023-05-03 11:51:39.220313386 +0200
@@ -312,7 +312,11 @@
             goto done;
         }
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+        vm_flags_set(vma, VM_IO);
+#else
         vma->vm_flags |= VM_IO;
+#endif
     }
     else
     {
@@ -363,8 +367,13 @@
 
         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);
+#else
         vma->vm_flags |= (VM_IO | VM_LOCKED | VM_RESERVED);
         vma->vm_flags |= (VM_DONTEXPAND | VM_DONTDUMP);
+#endif
     }
 
     if (status == 0)
@@ -374,8 +383,13 @@
         if ((prot & NV_PROTECT_WRITEABLE) == 0)
         {
             vma->vm_page_prot = NV_PGPROT_READ_ONLY(vma->vm_page_prot);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+            vm_flags_clear(vma, VM_WRITE);
+            vm_flags_clear(vma, VM_MAYWRITE);
+#else
             vma->vm_flags &= ~VM_WRITE;
             vma->vm_flags &= ~VM_MAYWRITE;
+#endif
         }
 
         vma->vm_ops = &nv_vm_ops;
--- a/kernel/uvm/nvidia_uvm_lite.c	2023-05-03 12:00:17.508256190 +0200
+++ b/kernel/uvm/nvidia_uvm_lite.c	2023-05-03 12:03:59.160897071 +0200
@@ -1524,10 +1524,17 @@
 
         vma->vm_ops   = &uvmlite_vma_ops;
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+        // Prohibit copying the vma on fork().
+        vm_flags_set(vma, VM_DONTCOPY);
+        // Prohibt mremap() that would expand the vma.
+        vm_flags_set(vma, VM_DONTEXPAND);
+#else
         // Prohibit copying the vma on fork().
         vma->vm_flags |= VM_DONTCOPY;
         // Prohibt mremap() that would expand the vma.
         vma->vm_flags |= VM_DONTEXPAND;
+#endif
 
         // Other cases of vma modification are detected in _mmap_open().
 
@@ -1546,9 +1553,15 @@
             return -EINVAL;
 
         vma->vm_ops = &counters_vma_ops;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+        vm_flags_clear(vma, VM_MAYWRITE);
+        // prevent vm_insert_page from modifying the vma's flags:
+        vm_flags_set(vma, VM_MIXEDMAP);
+#else
         vma->vm_flags &= ~VM_MAYWRITE;
         // prevent vm_insert_page from modifying the vma's flags:
         vma->vm_flags |= VM_MIXEDMAP;
+#endif
         ret = 0;
     }
     UVM_DBG_PRINT_RL("vma 0x%p [0x%p, 0x%p) ret %d pgoff"
@@ -2527,8 +2540,13 @@
     // Subsequent access from userspace after the pages are unmapped will cause
     // 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);
+#else
     vma->vm_flags &= ~(VM_READ|VM_MAYREAD);
     vma->vm_flags &= ~(VM_WRITE|VM_MAYWRITE);
+#endif
 }
 
 //
@@ -2536,8 +2554,13 @@
 //
 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);
+#else
     vma->vm_flags |= (VM_READ|VM_MAYREAD);
     vma->vm_flags |= (VM_WRITE|VM_MAYWRITE);
+#endif
 }
 
 //