summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHongxu Jia <hongxu.jia@windriver.com>2020-08-19 11:19:06 +0800
committerArmin Kuster <akuster808@gmail.com>2021-07-19 16:17:21 -0700
commit8d62c9d4c949341515df2b808b17d6744fde2a7e (patch)
treec40ad38091334f7991360213f103c34481534615
parent2fe2ea3f159ee183a41b9aa83dd489fbc2cee41c (diff)
downloadmeta-openembedded-8d62c9d4c949341515df2b808b17d6744fde2a7e.tar.gz
vboxguestdrivers: fix failed to compile with kernel 5.8.0
Backport patches from upstream [1] to fix the issue It also requires to apply a patch on 5.8 kernel [2] [1] https://www.virtualbox.org/ticket/19644 [2] https://www.virtualbox.org/raw-attachment/ticket/19644/local_patches Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com> Signed-off-by: Khem Raj <raj.khem@gmail.com> (cherry picked from commit 9c10ed4baa95648b7735757121e3af8b0aeb8e06) Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r--meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0001-fixes_for_mm_struct.patch176
-rw-r--r--meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0002-fixes_for_module_memory.patch65
-rw-r--r--meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0003-fixes_for_changes_in_cpu_tlbstate.patch39
-rw-r--r--meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/kernel-5.8-4.patch19
-rw-r--r--meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_6.1.12.bb7
5 files changed, 305 insertions, 1 deletions
diff --git a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0001-fixes_for_mm_struct.patch b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0001-fixes_for_mm_struct.patch
new file mode 100644
index 000000000..1ad5ce51b
--- /dev/null
+++ b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0001-fixes_for_mm_struct.patch
@@ -0,0 +1,176 @@
1From 98070c936931879d2b8e22939724b5a0689721d0 Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Tue, 18 Aug 2020 17:48:29 +0800
4Subject: [PATCH 1/3] fixes_for_mm_struct
5
6Upstream-Status: Backport [https://www.virtualbox.org/ticket/19644]
7
8Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
9---
10 .../Runtime/r0drv/linux/memobj-r0drv-linux.c | 74 +++++++++++++++++--
11 1 file changed, 67 insertions(+), 7 deletions(-)
12
13diff --git a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
14index 37389bcc..cdc7e8e6 100644
15--- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
16+++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
17@@ -222,9 +222,17 @@ static void *rtR0MemObjLinuxDoMmap(RTR3PTR R3PtrFixed, size_t cb, size_t uAlignm
18 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
19 ulAddr = vm_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0);
20 #else
21+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
22 down_write(&pTask->mm->mmap_sem);
23+#else
24+ down_write(&pTask->mm->mmap_lock);
25+#endif
26 ulAddr = do_mmap(NULL, R3PtrFixed, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS | MAP_FIXED, 0);
27+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
28 up_write(&pTask->mm->mmap_sem);
29+#else
30+ up_write(&pTask->mm->mmap_lock);
31+#endif
32 #endif
33 }
34 else
35@@ -232,9 +240,17 @@ static void *rtR0MemObjLinuxDoMmap(RTR3PTR R3PtrFixed, size_t cb, size_t uAlignm
36 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 5, 0)
37 ulAddr = vm_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0);
38 #else
39+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
40 down_write(&pTask->mm->mmap_sem);
41+#else
42+ down_write(&pTask->mm->mmap_lock);
43+#endif
44 ulAddr = do_mmap(NULL, 0, cb, fLnxProt, MAP_SHARED | MAP_ANONYMOUS, 0);
45+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
46 up_write(&pTask->mm->mmap_sem);
47+#else
48+ up_write(&pTask->mm->mmap_lock);
49+#endif
50 #endif
51 if ( !(ulAddr & ~PAGE_MASK)
52 && (ulAddr & (uAlignment - 1)))
53@@ -269,13 +285,29 @@ static void rtR0MemObjLinuxDoMunmap(void *pv, size_t cb, struct task_struct *pTa
54 Assert(pTask == current); RT_NOREF_PV(pTask);
55 vm_munmap((unsigned long)pv, cb);
56 #elif defined(USE_RHEL4_MUNMAP)
57+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
58 down_write(&pTask->mm->mmap_sem);
59+#else
60+ down_write(&pTask->mm->mmap_lock);
61+#endif
62 do_munmap(pTask->mm, (unsigned long)pv, cb, 0); /* should it be 1 or 0? */
63+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
64 up_write(&pTask->mm->mmap_sem);
65 #else
66+ up_write(&pTask->mm->mmap_lock);
67+#endif
68+#else
69+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
70 down_write(&pTask->mm->mmap_sem);
71+#else
72+ down_write(&pTask->mm->mmap_lock);
73+#endif
74 do_munmap(pTask->mm, (unsigned long)pv, cb);
75+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
76 up_write(&pTask->mm->mmap_sem);
77+#else
78+ up_write(&pTask->mm->mmap_lock);
79+#endif
80 #endif
81 }
82
83@@ -593,7 +625,11 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
84 size_t iPage;
85 Assert(pTask);
86 if (pTask && pTask->mm)
87- down_read(&pTask->mm->mmap_sem);
88+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
89+ down_read(&pTask->mm->mmap_sem);
90+#else
91+ down_read(&pTask->mm->mmap_lock);
92+#endif
93
94 iPage = pMemLnx->cPages;
95 while (iPage-- > 0)
96@@ -608,7 +644,11 @@ DECLHIDDEN(int) rtR0MemObjNativeFree(RTR0MEMOBJ pMem)
97 }
98
99 if (pTask && pTask->mm)
100- up_read(&pTask->mm->mmap_sem);
101+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
102+ up_read(&pTask->mm->mmap_sem);
103+#else
104+ up_read(&pTask->mm->mmap_lock);
105+#endif
106 }
107 /* else: kernel memory - nothing to do here. */
108 break;
109@@ -1076,7 +1116,11 @@ DECLHIDDEN(int) rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3P
110 papVMAs = (struct vm_area_struct **)RTMemAlloc(sizeof(*papVMAs) * cPages);
111 if (papVMAs)
112 {
113- down_read(&pTask->mm->mmap_sem);
114+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
115+ down_read(&pTask->mm->mmap_sem);
116+#else
117+ down_read(&pTask->mm->mmap_lock);
118+#endif
119
120 /*
121 * Get user pages.
122@@ -1162,7 +1206,11 @@ DECLHIDDEN(int) rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3P
123 papVMAs[rc]->vm_flags |= VM_DONTCOPY | VM_LOCKED;
124 }
125
126- up_read(&pTask->mm->mmap_sem);
127+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
128+ up_read(&pTask->mm->mmap_sem);
129+#else
130+ up_read(&pTask->mm->mmap_lock);
131+#endif
132
133 RTMemFree(papVMAs);
134
135@@ -1189,7 +1237,11 @@ DECLHIDDEN(int) rtR0MemObjNativeLockUser(PPRTR0MEMOBJINTERNAL ppMem, RTR3PTR R3P
136 #endif
137 }
138
139- up_read(&pTask->mm->mmap_sem);
140+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
141+ up_read(&pTask->mm->mmap_sem);
142+#else
143+ up_read(&pTask->mm->mmap_lock);
144+#endif
145
146 RTMemFree(papVMAs);
147 rc = VERR_LOCK_FAILED;
148@@ -1604,7 +1656,11 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ p
149 const size_t cPages = (offSub + cbSub) >> PAGE_SHIFT;
150 size_t iPage;
151
152- down_write(&pTask->mm->mmap_sem);
153+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
154+ down_write(&pTask->mm->mmap_sem);
155+#else
156+ down_write(&pTask->mm->mmap_lock);
157+#endif
158
159 rc = VINF_SUCCESS;
160 if (pMemLnxToMap->cPages)
161@@ -1721,7 +1777,11 @@ DECLHIDDEN(int) rtR0MemObjNativeMapUser(PPRTR0MEMOBJINTERNAL ppMem, RTR0MEMOBJ p
162 }
163 #endif /* CONFIG_NUMA_BALANCING */
164
165- up_write(&pTask->mm->mmap_sem);
166+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
167+ up_write(&pTask->mm->mmap_sem);
168+#else
169+ up_write(&pTask->mm->mmap_lock);
170+#endif
171
172 if (RT_SUCCESS(rc))
173 {
174--
1752.18.2
176
diff --git a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0002-fixes_for_module_memory.patch b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0002-fixes_for_module_memory.patch
new file mode 100644
index 000000000..a3cfc3b37
--- /dev/null
+++ b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0002-fixes_for_module_memory.patch
@@ -0,0 +1,65 @@
1From bb580f7b601e5395a2f8fcb2485387035273320f Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Tue, 18 Aug 2020 17:49:34 +0800
4Subject: [PATCH 2/3] fixes_for_module_memory
5
6Upstream-Status: Backport [https://www.virtualbox.org/ticket/19644]
7
8Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
9---
10 .../Runtime/r0drv/linux/alloc-r0drv-linux.c | 18 ++++++++++++++++--
11 1 file changed, 16 insertions(+), 2 deletions(-)
12
13diff --git a/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
14index bbb8acc6..45cd34c7 100644
15--- a/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
16+++ b/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
17@@ -153,6 +153,8 @@ RT_EXPORT_SYMBOL(RTR0MemExecDonate);
18
19
20 #ifdef RTMEMALLOC_EXEC_VM_AREA
21+
22+
23 /**
24 * Allocate executable kernel memory in the module range.
25 *
26@@ -168,7 +170,12 @@ static PRTMEMHDR rtR0MemAllocExecVmArea(size_t cb)
27 struct vm_struct *pVmArea;
28 size_t iPage;
29
30+# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
31+ pVmArea = __get_vm_area_caller(cbAlloc, VM_ALLOC, MODULES_VADDR, MODULES_END,
32+ __builtin_return_address(0));
33+#else
34 pVmArea = __get_vm_area(cbAlloc, VM_ALLOC, MODULES_VADDR, MODULES_END);
35+#endif
36 if (!pVmArea)
37 return NULL;
38 pVmArea->nr_pages = 0; /* paranoia? */
39@@ -201,14 +208,21 @@ static PRTMEMHDR rtR0MemAllocExecVmArea(size_t cb)
40 # endif
41 pVmArea->nr_pages = cPages;
42 pVmArea->pages = papPages;
43- if (!map_vm_area(pVmArea, PAGE_KERNEL_EXEC,
44+# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
45+ unsigned long start = (unsigned long)pVmArea->addr;
46+ unsigned long size = get_vm_area_size(pVmArea);
47+
48+ if (!map_kernel_range(start, size, PAGE_KERNEL_EXEC, papPages))
49+#else
50+ if (!map_vm_area(pVmArea, PAGE_KERNEL_EXEC,
51 # if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
52 &papPagesIterator
53 # else
54 papPages
55 # endif
56 ))
57- {
58+#endif
59+ {
60 PRTMEMLNXHDREX pHdrEx = (PRTMEMLNXHDREX)pVmArea->addr;
61 pHdrEx->pVmArea = pVmArea;
62 pHdrEx->pvDummy = NULL;
63--
642.18.2
65
diff --git a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0003-fixes_for_changes_in_cpu_tlbstate.patch b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0003-fixes_for_changes_in_cpu_tlbstate.patch
new file mode 100644
index 000000000..6a3e63f63
--- /dev/null
+++ b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/0003-fixes_for_changes_in_cpu_tlbstate.patch
@@ -0,0 +1,39 @@
1From 6089974a81b1b44e1d2dfa5af1fdc110dfee40c1 Mon Sep 17 00:00:00 2001
2From: Hongxu Jia <hongxu.jia@windriver.com>
3Date: Tue, 18 Aug 2020 17:51:24 +0800
4Subject: [PATCH 3/3] fixes_for_changes_in_cpu_tlbstate
5
6Upstream-Status: Backport [https://www.virtualbox.org/ticket/19644]
7
8Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
9---
10 src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c | 7 +++++++
11 1 file changed, 7 insertions(+)
12
13diff --git a/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c b/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
14index c7d0d99a..2e7aa6e1 100644
15--- a/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
16+++ b/src/VBox/HostDrivers/Support/linux/SUPDrv-linux.c
17@@ -757,12 +757,19 @@ EXPORT_SYMBOL(SUPDrvLinuxIDC);
18 RTCCUINTREG VBOXCALL supdrvOSChangeCR4(RTCCUINTREG fOrMask, RTCCUINTREG fAndMask)
19 {
20 #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 20, 0)
21+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
22 RTCCUINTREG uOld = this_cpu_read(cpu_tlbstate.cr4);
23+#else
24+ RTCCUINTREG uOld = __read_cr4();
25+#endif
26 RTCCUINTREG uNew = (uOld & fAndMask) | fOrMask;
27 if (uNew != uOld)
28 {
29+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
30 this_cpu_write(cpu_tlbstate.cr4, uNew);
31 __write_cr4(uNew);
32+#endif
33+ ASMSetCR4(uNew);
34 }
35 #else
36 RTCCUINTREG uOld = ASMGetCR4();
37--
382.18.2
39
diff --git a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/kernel-5.8-4.patch b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/kernel-5.8-4.patch
new file mode 100644
index 000000000..cb4148fc7
--- /dev/null
+++ b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers/kernel-5.8-4.patch
@@ -0,0 +1,19 @@
1Description: Fix kernel 5.8 forbidding use of vermagic.h header file
2Author: Gianfranco Costamagna <locutusofborg@debian.org>
3Origin: https://www.virtualbox.org/ticket/19644
4Bug-Ubuntu: https://launchpad.net/bugs/1884652
5Last-Update: 2020-08-10
6
7--- virtualbox-6.1.12-dfsg.orig/src/VBox/Additions/linux/sharedfolders/vfsmod.c
8+++ virtualbox-6.1.12-dfsg/src/VBox/Additions/linux/sharedfolders/vfsmod.c
9@@ -53,7 +53,9 @@
10 #include <linux/seq_file.h>
11 #include <linux/vfs.h>
12 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 5, 62)
13-# include <linux/vermagic.h>
14+# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
15+# include <linux/vermagic.h>
16+# endif
17 #endif
18 #include <VBox/err.h>
19 #include <iprt/path.h>
diff --git a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_6.1.12.bb b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_6.1.12.bb
index dfa15da2d..e57df58d6 100644
--- a/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_6.1.12.bb
+++ b/meta-oe/recipes-support/vboxguestdrivers/vboxguestdrivers_6.1.12.bb
@@ -12,12 +12,17 @@ COMPATIBLE_MACHINE = "(qemux86|qemux86-64)"
12VBOX_NAME = "VirtualBox-${PV}" 12VBOX_NAME = "VirtualBox-${PV}"
13 13
14SRC_URI = "http://download.virtualbox.org/virtualbox/${PV}/${VBOX_NAME}.tar.bz2 \ 14SRC_URI = "http://download.virtualbox.org/virtualbox/${PV}/${VBOX_NAME}.tar.bz2 \
15 file://0001-fixes_for_mm_struct.patch \
16 file://0002-fixes_for_module_memory.patch \
17 file://0003-fixes_for_changes_in_cpu_tlbstate.patch \
18 file://kernel-5.8-4.patch \
15 file://Makefile.utils \ 19 file://Makefile.utils \
16" 20"
17SRC_URI[md5sum] = "3c351f7fd6376e0bb3c8489505a9450c" 21SRC_URI[md5sum] = "3c351f7fd6376e0bb3c8489505a9450c"
18SRC_URI[sha256sum] = "05eff0321daa72f6d00fb121a6b4211f39964778823806fa0b7b751667dec362" 22SRC_URI[sha256sum] = "05eff0321daa72f6d00fb121a6b4211f39964778823806fa0b7b751667dec362"
19 23
20S = "${WORKDIR}/vbox_module" 24S ?= "${WORKDIR}/vbox_module"
25S_task-patch = "${WORKDIR}/${VBOX_NAME}"
21 26
22export BUILD_TARGET_ARCH="${ARCH}" 27export BUILD_TARGET_ARCH="${ARCH}"
23export BUILD_TARGET_ARCH_x86-64="amd64" 28export BUILD_TARGET_ARCH_x86-64="amd64"