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>
This commit is contained in:
aszlig 2017-07-04 20:04:45 +02:00
parent f873ba8cc8
commit 12ee0fbd88
No known key found for this signature in database
GPG Key ID: 1DE8E48E57DB5436
3 changed files with 84 additions and 1 deletions

View File

@ -88,7 +88,7 @@ in stdenv.mkDerivation {
'';
patches = optional enableHardening ./hardened.patch
++ [ ./qtx11extras.patch ];
++ [ ./qtx11extras.patch ./linux-4.12.patch ];
postPatch = ''
sed -i -e 's|/sbin/ifconfig|${nettools}/bin/ifconfig|' \

View File

@ -62,6 +62,9 @@ stdenv.mkDerivation {
for i in *
do
cd $i
# Files within the guest additions ISO are using DOS line endings
sed -re '/^(@@|---|\+\+\+)/!s/$/\r/' ${../linux-4.12.patch} \
| patch -d vboxguest -p4
find . -type f | xargs sed 's/depmod -a/true/' -i
make
cd ..

View File

@ -0,0 +1,80 @@
commit 47fee9325e3b5feed0dbc4ba9e2de77c6d55e3bb
Author: vboxsync <vboxsync@cfe28804-0f27-0410-a406-dd0f0b0b656f>
Date: Wed May 17 09:42:23 2017 +0000
Runtime/r0drv: Linux 4.12 5-level page table adaptions
git-svn-id: https://www.virtualbox.org/svn/vbox/trunk@66927 cfe28804-0f27-0410-a406-dd0f0b0b656f
diff --git a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
index 28dc33f963..41ed058860 100644
--- a/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
+++ b/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
@@ -902,6 +902,9 @@ static struct page *rtR0MemObjLinuxVirtToPage(void *pv)
union
{
pgd_t Global;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+ p4d_t Four;
+#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
pud_t Upper;
#endif
@@ -917,12 +920,26 @@ static struct page *rtR0MemObjLinuxVirtToPage(void *pv)
u.Global = *pgd_offset(current->active_mm, ulAddr);
if (RT_UNLIKELY(pgd_none(u.Global)))
return NULL;
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+ u.Four = *p4d_offset(&u.Global, ulAddr);
+ if (RT_UNLIKELY(p4d_none(u.Four)))
+ return NULL;
+ if (p4d_large(u.Four))
+ {
+ pPage = p4d_page(u.Four);
+ AssertReturn(pPage, NULL);
+ pfn = page_to_pfn(pPage); /* doing the safe way... */
+ AssertCompile(P4D_SHIFT - PAGE_SHIFT < 31);
+ pfn += (ulAddr >> PAGE_SHIFT) & ((UINT32_C(1) << (P4D_SHIFT - PAGE_SHIFT)) - 1);
+ return pfn_to_page(pfn);
+ }
+ u.Upper = *pud_offset(&u.Four, ulAddr);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
u.Upper = *pud_offset(&u.Global, ulAddr);
+#endif
if (RT_UNLIKELY(pud_none(u.Upper)))
return NULL;
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
if (pud_large(u.Upper))
{
pPage = pud_page(u.Upper);
@@ -931,8 +948,8 @@ static struct page *rtR0MemObjLinuxVirtToPage(void *pv)
pfn += (ulAddr >> PAGE_SHIFT) & ((UINT32_C(1) << (PUD_SHIFT - PAGE_SHIFT)) - 1);
return pfn_to_page(pfn);
}
-# endif
-
+#endif
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
u.Middle = *pmd_offset(&u.Upper, ulAddr);
#else /* < 2.6.11 */
u.Middle = *pmd_offset(&u.Global, ulAddr);
diff --git a/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h b/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h
index 5afdee9e71..20aab0817f 100644
--- a/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h
+++ b/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h
@@ -159,6 +159,11 @@
# include <asm/tlbflush.h>
#endif
+/* for set_pages_x() */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+# include <asm/set_memory.h>
+#endif
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0)
# include <asm/smap.h>
#else