commit 776f4611e4bf7d93f46be3aef10fac890e45d975
Author: Sérgio M. Basto <sergio(a)serjux.com>
Date: Fri Jun 30 15:53:03 2017 +0100
Add patch for kernel 4.12
VirtualBox-kmod.spec | 7 +-
vbox_fix_for_kernel_4.12_rf.patch | 262 ++++++++++++++++++++++++++++++++++++++
2 files changed, 268 insertions(+), 1 deletion(-)
---
diff --git a/VirtualBox-kmod.spec b/VirtualBox-kmod.spec
index 3ff54d8..c0ccd8f 100644
--- a/VirtualBox-kmod.spec
+++ b/VirtualBox-kmod.spec
@@ -30,7 +30,7 @@
Name: VirtualBox-kmod
Version: 5.1.22
#Release: 1%%{?prerel:.%%{prerel}}%%{?dist}
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: Kernel module for VirtualBox
Group: System Environment/Kernel
@@ -38,6 +38,7 @@ License: GPLv2 or CDDL
URL:
http://www.virtualbox.org/wiki/VirtualBox
# This filters out the XEN kernel, since we don't run on XEN
Source1: VirtualBox-kmod-excludekernel-filter.txt
+patch1: vbox_fix_for_kernel_4.12_rf.patch
%global AkmodsBuildRequires %{_bindir}/kmodtool, VirtualBox-kmodsrc >=
%{version}%{vboxreltag}, xz, time
BuildRequires: %{AkmodsBuildRequires}
@@ -60,6 +61,7 @@ Kernel module for VirtualBox
%prep
%setup -T -c
tar --use-compress-program xz -xf
%{_datadir}/%{name}-%{version}/%{name}-%{version}.tar.xz
+%patch1 -p1
# error out if there was something wrong with kmodtool
%{?kmodtool_check}
@@ -108,6 +110,9 @@ DIRS=$(ls %{name}-%{version} |wc -l)
%changelog
+* Fri Jun 30 2017 Sérgio Basto <sergio(a)serjux.com> - 5.1.22-3
+- Add patch for kernel 4.12
+
* Wed Jun 28 2017 Nicolas Chauvet <kwizart(a)gmail.com> - 5.1.22-2
- Allow to build pre-built kmod on el
diff --git a/vbox_fix_for_kernel_4.12_rf.patch b/vbox_fix_for_kernel_4.12_rf.patch
new file mode 100644
index 0000000..5d51801
--- /dev/null
+++ b/vbox_fix_for_kernel_4.12_rf.patch
@@ -0,0 +1,262 @@
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxdrv/linux/SUPDrv-linux.c
./VirtualBox-kmod-5.1.22/vboxdrv/linux/SUPDrv-linux.c
+--- ./VirtualBox-kmod-5.1.22.orig/vboxdrv/linux/SUPDrv-linux.c 2017-06-16
10:06:54.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxdrv/linux/SUPDrv-linux.c 2017-06-30 15:12:13.603017580
+0100
+@@ -1403,7 +1403,7 @@ RTDECL(int) SUPR0Printf(const char *pszF
+ SUPR0DECL(uint32_t) SUPR0GetKernelFeatures(void)
+ {
+ uint32_t fFlags = 0;
+-#ifdef CONFIG_PAX_KERNEXEC
++#if defined(CONFIG_PAX_KERNEXEC) || LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
+ fFlags |= SUPKERNELFEATURES_GDT_READ_ONLY;
+ #endif
+ #if defined(VBOX_STRICT) || defined(VBOX_WITH_EFLAGS_AC_SET_IN_VBOXDRV)
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxdrv/r0drv/linux/alloc-r0drv-linux.c
./VirtualBox-kmod-5.1.22/vboxdrv/r0drv/linux/alloc-r0drv-linux.c
+--- ./VirtualBox-kmod-5.1.22.orig/vboxdrv/r0drv/linux/alloc-r0drv-linux.c 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxdrv/r0drv/linux/alloc-r0drv-linux.c 2017-06-30
15:09:16.396055483 +0100
+@@ -35,6 +35,9 @@
+ #include <iprt/assert.h>
+ #include <iprt/err.h>
+ #include "r0drv/alloc-r0drv.h"
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++#include <asm/set_memory.h>
++#endif
+
+
+ #if (defined(RT_ARCH_AMD64) || defined(DOXYGEN_RUNNING)) &&
!defined(RTMEMALLOC_EXEC_HEAP)
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxdrv/r0drv/linux/memobj-r0drv-linux.c
./VirtualBox-kmod-5.1.22/vboxdrv/r0drv/linux/memobj-r0drv-linux.c
+--- ./VirtualBox-kmod-5.1.22.orig/vboxdrv/r0drv/linux/memobj-r0drv-linux.c 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxdrv/r0drv/linux/memobj-r0drv-linux.c 2017-06-30
15:14:27.621501849 +0100
+@@ -899,6 +899,9 @@ static struct page *rtR0MemObjLinuxVirtT
+ unsigned long pfn;
+ struct page *pPage;
+ pte_t *pEntry;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++ p4d_t p4d;
++#endif
+ union
+ {
+ pgd_t Global;
+@@ -917,9 +920,18 @@ static struct page *rtR0MemObjLinuxVirtT
+ u.Global = *pgd_offset(current->active_mm, ulAddr);
+ if (RT_UNLIKELY(pgd_none(u.Global)))
+ return NULL;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++ p4d = *p4d_offset(&u.Global, ulAddr);
++ if (RT_UNLIKELY(p4d_none(p4d) || p4d_large(p4d) || !p4d_present(p4d)))
++ return NULL;
++#endif
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++ u.Upper = *pud_offset(&p4d, ulAddr);
++#else
+ 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)
+@@ -1463,13 +1475,23 @@ static int rtR0MemObjLinuxFixPte(struct
+ {
+ int rc = -ENOMEM;
+ pgd_t *pgd;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++ p4d_t *p4d;
++#endif
+
+ spin_lock(&mm->page_table_lock);
+
+ pgd = pgd_offset(mm, ulAddr);
+ if (!pgd_none(*pgd) && !pgd_bad(*pgd))
+ {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++ p4d = p4d_offset(*pgd, ulAddr);
++ if (p4d_none(*p4d))
++ goto exit;
++ pmd_t *pmd = pmd_offset(p4d, ulAddr);
++#else
+ pmd_t *pmd = pmd_offset(pgd, ulAddr);
++#endif
+ if (!pmd_none(*pmd))
+ {
+ pte_t *ptep = pte_offset_map(pmd, ulAddr);
+@@ -1487,6 +1509,9 @@ static int rtR0MemObjLinuxFixPte(struct
+ }
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++exit:
++#endif
+ spin_unlock(&mm->page_table_lock);
+ return rc;
+ }
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxdrv/r0drv/linux/the-linux-kernel.h
./VirtualBox-kmod-5.1.22/vboxdrv/r0drv/linux/the-linux-kernel.h
+--- ./VirtualBox-kmod-5.1.22.orig/vboxdrv/r0drv/linux/the-linux-kernel.h 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxdrv/r0drv/linux/the-linux-kernel.h 2017-06-30
15:17:29.999522197 +0100
+@@ -320,6 +320,9 @@ DECLINLINE(unsigned long) msecs_to_jiffi
+ #endif
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++#include <asm/cacheflush.h>
++#endif
+ # define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
+ # define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
+ #else
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxguest/r0drv/linux/alloc-r0drv-linux.c
./VirtualBox-kmod-5.1.22/vboxguest/r0drv/linux/alloc-r0drv-linux.c
+--- ./VirtualBox-kmod-5.1.22.orig/vboxguest/r0drv/linux/alloc-r0drv-linux.c 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxguest/r0drv/linux/alloc-r0drv-linux.c 2017-06-30
15:09:16.396055483 +0100
+@@ -35,6 +35,9 @@
+ #include <iprt/assert.h>
+ #include <iprt/err.h>
+ #include "r0drv/alloc-r0drv.h"
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++#include <asm/set_memory.h>
++#endif
+
+
+ #if (defined(RT_ARCH_AMD64) || defined(DOXYGEN_RUNNING)) &&
!defined(RTMEMALLOC_EXEC_HEAP)
+Only in ./VirtualBox-kmod-5.1.22/vboxguest/r0drv/linux: alloc-r0drv-linux.c.rej
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxguest/r0drv/linux/memobj-r0drv-linux.c
./VirtualBox-kmod-5.1.22/vboxguest/r0drv/linux/memobj-r0drv-linux.c
+--- ./VirtualBox-kmod-5.1.22.orig/vboxguest/r0drv/linux/memobj-r0drv-linux.c 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxguest/r0drv/linux/memobj-r0drv-linux.c 2017-06-30
15:08:32.185566058 +0100
+@@ -899,6 +899,9 @@ static struct page *rtR0MemObjLinuxVirtT
+ unsigned long pfn;
+ struct page *pPage;
+ pte_t *pEntry;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++ p4d_t p4d;
++#endif
+ union
+ {
+ pgd_t Global;
+@@ -917,9 +920,18 @@ static struct page *rtR0MemObjLinuxVirtT
+ u.Global = *pgd_offset(current->active_mm, ulAddr);
+ if (RT_UNLIKELY(pgd_none(u.Global)))
+ return NULL;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++ p4d = *p4d_offset(&u.Global, ulAddr);
++ if (RT_UNLIKELY(p4d_none(p4d) || p4d_large(p4d) || !p4d_present(p4d)))
++ return NULL;
++#endif
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 11)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++ u.Upper = *pud_offset(&p4d, ulAddr);
++#else
+ 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)
+@@ -1463,13 +1475,23 @@ static int rtR0MemObjLinuxFixPte(struct
+ {
+ int rc = -ENOMEM;
+ pgd_t *pgd;
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++ p4d_t *p4d;
++#endif
+
+ spin_lock(&mm->page_table_lock);
+
+ pgd = pgd_offset(mm, ulAddr);
+ if (!pgd_none(*pgd) && !pgd_bad(*pgd))
+ {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++ p4d = p4d_offset(*pgd, ulAddr);
++ if (p4d_none(*p4d))
++ goto exit;
++ pmd_t *pmd = pmd_offset(p4d, ulAddr);
++#else
+ pmd_t *pmd = pmd_offset(pgd, ulAddr);
++#endif
+ if (!pmd_none(*pmd))
+ {
+ pte_t *ptep = pte_offset_map(pmd, ulAddr);
+@@ -1487,6 +1509,9 @@ static int rtR0MemObjLinuxFixPte(struct
+ }
+ }
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++exit:
++#endif
+ spin_unlock(&mm->page_table_lock);
+ return rc;
+ }
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxguest/r0drv/linux/the-linux-kernel.h
./VirtualBox-kmod-5.1.22/vboxguest/r0drv/linux/the-linux-kernel.h
+--- ./VirtualBox-kmod-5.1.22.orig/vboxguest/r0drv/linux/the-linux-kernel.h 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxguest/r0drv/linux/the-linux-kernel.h 2017-06-30
15:08:32.271567010 +0100
+@@ -320,6 +320,9 @@ DECLINLINE(unsigned long) msecs_to_jiffi
+ #endif
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++#include <asm/cacheflush.h>
++#endif
+ # define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
+ # define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
+ #else
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxnetadp/r0drv/linux/the-linux-kernel.h
./VirtualBox-kmod-5.1.22/vboxnetadp/r0drv/linux/the-linux-kernel.h
+--- ./VirtualBox-kmod-5.1.22.orig/vboxnetadp/r0drv/linux/the-linux-kernel.h 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxnetadp/r0drv/linux/the-linux-kernel.h 2017-06-30
15:17:29.999522197 +0100
+@@ -320,6 +320,9 @@ DECLINLINE(unsigned long) msecs_to_jiffi
+ #endif
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++#include <asm/cacheflush.h>
++#endif
+ # define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
+ # define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
+ #else
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxnetflt/r0drv/linux/the-linux-kernel.h
./VirtualBox-kmod-5.1.22/vboxnetflt/r0drv/linux/the-linux-kernel.h
+--- ./VirtualBox-kmod-5.1.22.orig/vboxnetflt/r0drv/linux/the-linux-kernel.h 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxnetflt/r0drv/linux/the-linux-kernel.h 2017-06-30
15:17:29.999522197 +0100
+@@ -320,6 +320,9 @@ DECLINLINE(unsigned long) msecs_to_jiffi
+ #endif
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++#include <asm/cacheflush.h>
++#endif
+ # define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
+ # define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
+ #else
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxpci/r0drv/linux/the-linux-kernel.h
./VirtualBox-kmod-5.1.22/vboxpci/r0drv/linux/the-linux-kernel.h
+--- ./VirtualBox-kmod-5.1.22.orig/vboxpci/r0drv/linux/the-linux-kernel.h 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxpci/r0drv/linux/the-linux-kernel.h 2017-06-30
15:17:29.999522197 +0100
+@@ -320,6 +320,9 @@ DECLINLINE(unsigned long) msecs_to_jiffi
+ #endif
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++#include <asm/cacheflush.h>
++#endif
+ # define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
+ # define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
+ #else
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxsf/r0drv/linux/the-linux-kernel.h
./VirtualBox-kmod-5.1.22/vboxsf/r0drv/linux/the-linux-kernel.h
+--- ./VirtualBox-kmod-5.1.22.orig/vboxsf/r0drv/linux/the-linux-kernel.h 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxsf/r0drv/linux/the-linux-kernel.h 2017-06-30
15:17:29.999522197 +0100
+@@ -320,6 +320,9 @@ DECLINLINE(unsigned long) msecs_to_jiffi
+ #endif
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++#include <asm/cacheflush.h>
++#endif
+ # define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
+ # define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
+ #else
+diff -rup ./VirtualBox-kmod-5.1.22.orig/vboxvideo/include/the-linux-kernel.h
./VirtualBox-kmod-5.1.22/vboxvideo/include/the-linux-kernel.h
+--- ./VirtualBox-kmod-5.1.22.orig/vboxvideo/include/the-linux-kernel.h 2017-04-28
16:04:49.000000000 +0100
++++ ./VirtualBox-kmod-5.1.22/vboxvideo/include/the-linux-kernel.h 2017-06-30
15:17:29.999522197 +0100
+@@ -320,6 +320,9 @@ DECLINLINE(unsigned long) msecs_to_jiffi
+ #endif
+
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
++#include <asm/cacheflush.h>
++#endif
+ # define MY_SET_PAGES_EXEC(pPages, cPages) set_pages_x(pPages, cPages)
+ # define MY_SET_PAGES_NOEXEC(pPages, cPages) set_pages_nx(pPages, cPages)
+ #else