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
|
From bb580f7b601e5395a2f8fcb2485387035273320f Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Tue, 18 Aug 2020 17:49:34 +0800
Subject: [PATCH 2/3] fixes_for_module_memory
Upstream-Status: Backport [https://www.virtualbox.org/ticket/19644]
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
.../Runtime/r0drv/linux/alloc-r0drv-linux.c | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
index bbb8acc6..45cd34c7 100644
--- a/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
+++ b/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
@@ -153,6 +153,8 @@ RT_EXPORT_SYMBOL(RTR0MemExecDonate);
#ifdef RTMEMALLOC_EXEC_VM_AREA
+
+
/**
* Allocate executable kernel memory in the module range.
*
@@ -168,7 +170,12 @@ static PRTMEMHDR rtR0MemAllocExecVmArea(size_t cb)
struct vm_struct *pVmArea;
size_t iPage;
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
+ pVmArea = __get_vm_area_caller(cbAlloc, VM_ALLOC, MODULES_VADDR, MODULES_END,
+ __builtin_return_address(0));
+#else
pVmArea = __get_vm_area(cbAlloc, VM_ALLOC, MODULES_VADDR, MODULES_END);
+#endif
if (!pVmArea)
return NULL;
pVmArea->nr_pages = 0; /* paranoia? */
@@ -201,14 +208,21 @@ static PRTMEMHDR rtR0MemAllocExecVmArea(size_t cb)
# endif
pVmArea->nr_pages = cPages;
pVmArea->pages = papPages;
- if (!map_vm_area(pVmArea, PAGE_KERNEL_EXEC,
+# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0)
+ unsigned long start = (unsigned long)pVmArea->addr;
+ unsigned long size = get_vm_area_size(pVmArea);
+
+ if (!map_kernel_range(start, size, PAGE_KERNEL_EXEC, papPages))
+#else
+ if (!map_vm_area(pVmArea, PAGE_KERNEL_EXEC,
# if LINUX_VERSION_CODE < KERNEL_VERSION(3, 17, 0)
&papPagesIterator
# else
papPages
# endif
))
- {
+#endif
+ {
PRTMEMLNXHDREX pHdrEx = (PRTMEMLNXHDREX)pVmArea->addr;
pHdrEx->pVmArea = pVmArea;
pHdrEx->pvDummy = NULL;
--
2.18.2
|