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
|
From c3a26ae7fc4a5ca857f829c1943abcf3c1d4d173 Mon Sep 17 00:00:00 2001
From: BlackEagle <ike.devolder@gmail.com>
Date: Thu, 6 Aug 2020 12:35:38 +0200
Subject: [PATCH 2/2] kernel-5.8.patch
Signed-off-by: BlackEagle <ike.devolder@gmail.com>
---
kernel/common/inc/nv-linux.h | 6 +++++
kernel/common/inc/nv-mm.h | 4 ++++
kernel/conftest.sh | 43 ++++++++++++++++++++++++++++++++++++
kernel/nvidia/nvidia.Kbuild | 2 ++
4 files changed, 55 insertions(+)
diff --git a/kernel/common/inc/nv-linux.h b/kernel/common/inc/nv-linux.h
index ce6f891..872c4ca 100644
--- a/kernel/common/inc/nv-linux.h
+++ b/kernel/common/inc/nv-linux.h
@@ -535,7 +535,13 @@ extern int nv_pat_mode;
static inline void *nv_vmalloc(unsigned long size)
{
+#if NV_VMALLOC_ARGUMENT_COUNT_ARGUMENT_COUNT == 3
void *ptr = __vmalloc(size, GFP_KERNEL, PAGE_KERNEL);
+#elif NV_VMALLOC_ARGUMENT_COUNT_ARGUMENT_COUNT == 2
+ void *ptr = __vmalloc(size, GFP_KERNEL);
+#else
+#error "NV_VMALLOC_ARGUMENT_COUNT_ARGUMENT_COUNT value unrecognized!"
+#endif
if (ptr)
NV_MEMDBG_ADD(ptr, size);
return ptr;
diff --git a/kernel/common/inc/nv-mm.h b/kernel/common/inc/nv-mm.h
index 1270bf3..dfcd12b 100644
--- a/kernel/common/inc/nv-mm.h
+++ b/kernel/common/inc/nv-mm.h
@@ -25,6 +25,10 @@
#include "conftest.h"
+#if defined(NV_MM_STRUCT_HAS_MMAP_LOCK)
+#define mmap_sem mmap_lock
+#endif
+
#if !defined(NV_VM_FAULT_T_IS_PRESENT)
typedef int vm_fault_t;
#endif
diff --git a/kernel/conftest.sh b/kernel/conftest.sh
index 0778ba1..7d5821a 100755
--- a/kernel/conftest.sh
+++ b/kernel/conftest.sh
@@ -2629,6 +2629,49 @@ compile_test() {
compile_check_conftest "$CODE" "NV_VZALLOC_PRESENT" "" "functions"
;;
+ vmalloc_argument_count)
+ #
+ # Determine how many arguments __vmalloc takes.
+ #
+ # Changed by commit fc3af83c4fca ("mm: remove the pgprot argument
+ # to __vmalloc")
+ #
+ echo "$CONFTEST_PREAMBLE
+ #include <linux/mm.h>
+ #include <linux/vmalloc.h>
+ void conftest_vmalloc_argument_count(void) {
+ __vmalloc(0, GFP_KERNEL, PAGE_KERNEL);
+ }" > conftest$$.c
+
+ $CC $CFLAGS -c conftest$$.c > /dev/null 2>&1
+ rm -f conftest$$.c
+
+ if [ -f conftest$$.o ]; then
+ echo "#define NV_VMALLOC_ARGUMENT_COUNT_ARGUMENT_COUNT 3" | append_conftest "functions"
+ else
+ echo "#define NV_VMALLOC_ARGUMENT_COUNT_ARGUMENT_COUNT 2" | append_conftest "functions"
+ fi
+
+ rm -f conftest$$.o
+ ;;
+
+ mm_struct_has_mmap_lock)
+ #
+ # Determine if the mm_struct structure has 'mmap_lock'.
+ #
+ # Changed by commit ea7b54944ef9 ("mmap locking API: rename mmap_sem
+ # to mmap_lock")
+ #
+ CODE="
+ #include <linux/mm.h>
+
+ int conftest_mm_struct_has_mmap_lock(void) {
+ return offsetof(struct mm_struct, mmap_lock);
+ }"
+
+ compile_check_conftest "$CODE" "NV_MM_STRUCT_HAS_MMAP_LOCK" "" "types"
+ ;;
+
drm_driver_has_set_busid)
#
# Determine if the drm_driver structure has a 'set_busid' callback
diff --git a/kernel/nvidia/nvidia.Kbuild b/kernel/nvidia/nvidia.Kbuild
index 63e369f..5b45144 100644
--- a/kernel/nvidia/nvidia.Kbuild
+++ b/kernel/nvidia/nvidia.Kbuild
@@ -158,6 +158,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += jiffies_to_timespec
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_raw_ts64
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ktime_get_real_ts64
NV_CONFTEST_FUNCTION_COMPILE_TESTS += ioremap_nocache
+NV_CONFTEST_FUNCTION_COMPILE_TESTS += vmalloc_argument_count
NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_gpl_of_node_to_nid
NV_CONFTEST_SYMBOL_COMPILE_TESTS += is_export_symbol_present_swiotlb_map_sg_attrs
@@ -196,6 +197,7 @@ NV_CONFTEST_TYPE_COMPILE_TESTS += timeval
NV_CONFTEST_TYPE_COMPILE_TESTS += kmem_cache_has_kobj_remove_work
NV_CONFTEST_TYPE_COMPILE_TESTS += sysfs_slab_unlink
NV_CONFTEST_TYPE_COMPILE_TESTS += pci_dev_has_skip_bus_pm
+NV_CONFTEST_TYPE_COMPILE_TESTS += mm_struct_has_mmap_lock
NV_CONFTEST_GENERIC_COMPILE_TESTS += dom0_kernel_present
NV_CONFTEST_GENERIC_COMPILE_TESTS += nvidia_vgpu_kvm_build
--
2.28.0
|