Skip to content

Commit 7bb59ef

Browse files
aszligNeQuissimus
authored andcommittedJul 4, 2017
virtualbox: Add patch for Linux 4.12
Compiling the kernel modules on Linux 4.12 fails, so I've included an upstream patch from: https://www.virtualbox.org/changeset/66927/vbox The patch is applied against the guest additions as well, where we need to transform the patch a bit so that we get CR LF line endings (DOS format), which is what is the case for the guest additions ISO. I've tested this with all the subtests of the "virtualbox" NixOS VM tests and they all succeed on x86_64-linux. Signed-off-by: aszlig <aszlig@redmoonstudios.org> (cherry picked from commit 12ee0fb)
1 parent 83d40b4 commit 7bb59ef

File tree

3 files changed

+84
-1
lines changed

3 files changed

+84
-1
lines changed
 

‎pkgs/applications/virtualization/virtualbox/default.nix

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ in stdenv.mkDerivation {
8888
'';
8989

9090
patches = optional enableHardening ./hardened.patch
91-
++ [ ./qtx11extras.patch ];
91+
++ [ ./qtx11extras.patch ./linux-4.12.patch ];
9292

9393
postPatch = ''
9494
sed -i -e 's|/sbin/ifconfig|${nettools}/bin/ifconfig|' \

‎pkgs/applications/virtualization/virtualbox/guest-additions/default.nix

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ stdenv.mkDerivation {
6262
for i in *
6363
do
6464
cd $i
65+
# Files within the guest additions ISO are using DOS line endings
66+
sed -re '/^(@@|---|\+\+\+)/!s/$/\r/' ${../linux-4.12.patch} \
67+
| patch -d vboxguest -p4
6568
find . -type f | xargs sed 's/depmod -a/true/' -i
6669
make
6770
cd ..
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
commit 47fee9325e3b5feed0dbc4ba9e2de77c6d55e3bb
2+
Author: vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>
3+
Date: Wed May 17 09:42:23 2017 +0000
4+
5+
Runtime/r0drv: Linux 4.12 5-level page table adaptions
6+
7+
8+
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@66927 cfe28804-0f27-0410-a406-dd0f0b0b656f
9+
10+
diff --git a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
11+
index 28dc33f963..41ed058860 100644
12+
--- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
13+
+++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
14+
@@ -902,6 +902,9 @@ static struct page *rtR0MemObjLinuxVirtToPage(void *pv)
15+
union
16+
{
17+
pgd_t Global;
18+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
19+
+ p4d_t Four;
20+
+#endif
21+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
22+
pud_t Upper;
23+
#endif
24+
@@ -917,12 +920,26 @@ static struct page *rtR0MemObjLinuxVirtToPage(void *pv)
25+
u.Global = *pgd_offset(current->active_mm, ulAddr);
26+
if (RT_UNLIKELY(pgd_none(u.Global)))
27+
return NULL;
28+
-
29+
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
30+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
31+
+ u.Four = *p4d_offset(&u.Global, ulAddr);
32+
+ if (RT_UNLIKELY(p4d_none(u.Four)))
33+
+ return NULL;
34+
+ if (p4d_large(u.Four))
35+
+ {
36+
+ pPage = p4d_page(u.Four);
37+
+ AssertReturn(pPage, NULL);
38+
+ pfn = page_to_pfn(pPage); /* doing the safe way... */
39+
+ AssertCompile(P4D_SHIFT - PAGE_SHIFT < 31);
40+
+ pfn += (ulAddr >> PAGE_SHIFT) & ((UINT32_C(1) << (P4D_SHIFT - PAGE_SHIFT)) - 1);
41+
+ return pfn_to_page(pfn);
42+
+ }
43+
+ u.Upper = *pud_offset(&u.Four, ulAddr);
44+
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
45+
u.Upper = *pud_offset(&u.Global, ulAddr);
46+
+#endif
47+
if (RT_UNLIKELY(pud_none(u.Upper)))
48+
return NULL;
49+
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
50+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
51+
if (pud_large(u.Upper))
52+
{
53+
pPage = pud_page(u.Upper);
54+
@@ -931,8 +948,8 @@ static struct page *rtR0MemObjLinuxVirtToPage(void *pv)
55+
pfn += (ulAddr >> PAGE_SHIFT) & ((UINT32_C(1) << (PUD_SHIFT - PAGE_SHIFT)) - 1);
56+
return pfn_to_page(pfn);
57+
}
58+
-# endif
59+
-
60+
+#endif
61+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
62+
u.Middle = *pmd_offset(&u.Upper, ulAddr);
63+
#else /* < 2.6.11 */
64+
u.Middle = *pmd_offset(&u.Global, ulAddr);
65+
diff --git a/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h b/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h
66+
index 5afdee9e71..20aab0817f 100644
67+
--- a/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h
68+
+++ b/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h
69+
@@ -159,6 +159,11 @@
70+
# include <asm/tlbflush.h>
71+
#endif
72+
73+
+/* for set_pages_x() */
74+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
75+
+# include <asm/set_memory.h>
76+
+#endif
77+
+
78+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
79+
# include <asm/smap.h>
80+
#else

0 commit comments

Comments
 (0)
Please sign in to comment.