]> git.pld-linux.org Git - packages/VirtualBox.git/commitdiff
- fix building kernel module for linux 5.6 auto/th/VirtualBox-6.1.4-2
authorJan Rękorajski <baggins@pld-linux.org>
Mon, 6 Apr 2020 20:22:12 +0000 (22:22 +0200)
committerJan Rękorajski <baggins@pld-linux.org>
Mon, 6 Apr 2020 20:22:12 +0000 (22:22 +0200)
- rel 2

VirtualBox.spec
kernel-5.6.patch [new file with mode: 0644]

index 84e1d51424a4127157cdb86ee7c09d1511546a9a..ffa8289078f9ca25a1a6e384c71475aeee2be1f9 100644 (file)
@@ -47,7 +47,7 @@ exit 1
 
 %define                qtver   5.6.0
 
-%define                rel             1
+%define                rel             2
 %define                pname           VirtualBox
 Summary:       VirtualBox - x86 hardware virtualizer
 Summary(pl.UTF-8):     VirtualBox - wirtualizator sprzętu x86
@@ -88,6 +88,7 @@ Patch15:      %{pname}-lightdm-1.19.2.patch
 Patch16:       %{pname}-no-vboxvideo.patch
 Patch17:       qt5-gl.patch
 Patch18:       eflags.ac.patch
+Patch19:       kernel-5.6.patch
 URL:           http://www.virtualbox.org/
 %if %{with userspace}
 %ifarch %{x8664}
@@ -550,6 +551,7 @@ echo override vboxguest %{_kernel_ver} misc > kernel/installed/etc/depmod.d/%{_k
 %patch16 -p0
 %patch17 -p1
 %patch18 -p1
+%patch19 -p0
 
 %{__sed} -i -e 's,@VBOX_DOC_PATH@,%{_docdir}/%{name}-%{version},' \
        -e 's/Categories=.*/Categories=Utility;Emulator;/' src/VBox/Installer/common/virtualbox.desktop.in
diff --git a/kernel-5.6.patch b/kernel-5.6.patch
new file mode 100644 (file)
index 0000000..a5462c3
--- /dev/null
@@ -0,0 +1,228 @@
+Index: include/iprt/time.h
+===================================================================
+--- include/iprt/time.h        (revision 83470)
++++ include/iprt/time.h        (revision 83471)
+@@ -359,6 +359,12 @@
+ /* PORTME: Add struct timeval guard macro here. */
+ #if defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
+  || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
++/*
++ * Starting with Linux kernel version 5.6-rc3, the struct timeval is no longer
++ * available to kernel code and must not be used in kernel code.
++ * Only 64-bit time-interfaces are allowed into the kernel.
++ */
++# if defined(RT_OS_LINUX) && (!defined(__KERNEL__) || !defined(_LINUX_TIME64_H))
+ /**
+  * Gets the time as POSIX timeval.
+  *
+@@ -392,6 +398,7 @@
+ {
+     return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
+ }
++# endif /* RT_OS_LINUX ... */
+ #endif /* various ways of detecting struct timeval */
+@@ -431,15 +438,19 @@
+ {
+     return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
+ }
++#endif /* various ways of detecting struct timespec */
+-
+-# ifdef _LINUX_TIME64_H
++#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H)
++/*
++ * Starting with Linux kernel version 5.6-rc3, the _STRUCT_TIMESPEC is only defined
++ * under !__KERNEL__ guard and _LINUX_TIME64_H does not define a corresponding
++ * _STRUCT_TIMESPEC64. Only 64-bit time-interfaces are now allowed into the kernel.
++ */
+ DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
+ {
+     return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
+ }
+-# endif
+-#endif /* various ways of detecting struct timespec */
++#endif /* RT_OS_LINUX && _LINUX_TIME64_H */
+Index: src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
+===================================================================
+--- src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c  (revision 83470)
++++ src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c  (revision 83471)
+@@ -1461,9 +1461,19 @@
+              * MMIO / physical memory.
+              */
+             Assert(pMemLnxToMap->Core.enmType == RTR0MEMOBJTYPE_PHYS && !pMemLnxToMap->Core.u.Phys.fAllocated);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
++            /*
++             * ioremap() defaults to no caching since the 2.6 kernels.
++             * ioremap_nocache() has been removed finally in 5.6-rc1.
++             */
+             pMemLnx->Core.pv = pMemLnxToMap->Core.u.Phys.uCachePolicy == RTMEM_CACHE_POLICY_MMIO
++                             ? ioremap(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub)
++                             : ioremap_cache(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub);
++#else /* KERNEL_VERSION < 2.6.25 */
++            pMemLnx->Core.pv = pMemLnxToMap->Core.u.Phys.uCachePolicy == RTMEM_CACHE_POLICY_MMIO
+                              ? ioremap_nocache(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub)
+                              : ioremap(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub);
++#endif /* KERNEL_VERSION < 2.6.25 */
+             if (pMemLnx->Core.pv)
+             {
+                 /** @todo fix protection. */
+Index: src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
+===================================================================
+--- src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c    (revision 83470)
++++ src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c    (revision 83471)
+@@ -38,12 +38,24 @@
+ DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void)
+ {
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16) /* This must match timer-r0drv-linux.c! */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+     /*
++     * Starting with kernel version 5.6-rc3 only 64-bit time interfaces
++     * are allowed in the kernel.
++     */
++    uint64_t u64;
++    struct timespec64 Ts = { 0, 0 };
++
++    ktime_get_ts64(&Ts);
++    u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec;
++    return u64;
++
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16) /* This must match timer-r0drv-linux.c! */
++    /*
+      * Use ktime_get_ts, this is also what clock_gettime(CLOCK_MONOTONIC,) is using.
+      */
+     uint64_t u64;
+-    struct timespec Ts;
++    struct timespec Ts = { 0, 0 };
+     ktime_get_ts(&Ts);
+     u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec;
+     return u64;
+Index: src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
+===================================================================
+--- src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c (revision 83470)
++++ src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c (revision 83471)
+@@ -842,15 +842,27 @@
+         rcLnx = pci_request_region(pPciDev, iRegion, "vboxpci");
+         if (!rcLnx)
+         {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
++            /*
++             * ioremap() defaults to no caching since the 2.6 kernels.
++             * ioremap_nocache() has been removed finally in 5.6-rc1.
++             */
++            RTR0PTR R0PtrMapping = ioremap(pci_resource_start(pPciDev, iRegion),
++                                           pci_resource_len(pPciDev, iRegion));
++#else /* KERNEL_VERSION < 2.6.25 */
+             /* For now no caching, try to optimize later. */
+             RTR0PTR R0PtrMapping = ioremap_nocache(pci_resource_start(pPciDev, iRegion),
+                                                    pci_resource_len(pPciDev, iRegion));
+-
++#endif /* KERNEL_VERSION < 2.6.25 */
+             if (R0PtrMapping != NIL_RTR0PTR)
+                 pIns->aRegionR0Mapping[iRegion] = R0PtrMapping;
+             else
+             {
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
++                vbpci_printk(KERN_DEBUG, pPciDev, "ioremap() failed\n");
++#else
+                 vbpci_printk(KERN_DEBUG, pPciDev, "ioremap_nocache() failed\n");
++#endif
+                 pci_release_region(pPciDev, iRegion);
+                 rc = VERR_MAP_FAILED;
+             }
+Index: include/iprt/time.h
+===================================================================
+--- include/iprt/time.h        (revision 83472)
++++ include/iprt/time.h        (revision 83473)
+@@ -357,14 +357,18 @@
+ /* PORTME: Add struct timeval guard macro here. */
+-#if defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
+- || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
+ /*
+  * Starting with Linux kernel version 5.6-rc3, the struct timeval is no longer
+  * available to kernel code and must not be used in kernel code.
+  * Only 64-bit time-interfaces are allowed into the kernel.
+  */
+-# if defined(RT_OS_LINUX) && (!defined(__KERNEL__) || !defined(_LINUX_TIME64_H))
++#if defined(RT_OS_LINUX) && (defined(__KERNEL__) || defined(_LINUX_TIME64_H))
++#define RTTIME_NO_TIMEVAL
++#endif
++#if !defined(RTTIME_NO_TIMEVAL) \
++ && (defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) \
++ || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
++ || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_)))
+ /**
+  * Gets the time as POSIX timeval.
+  *
+@@ -398,7 +402,6 @@
+ {
+     return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
+ }
+-# endif /* RT_OS_LINUX ... */
+ #endif /* various ways of detecting struct timeval */
+Index: include/iprt/time.h
+===================================================================
+--- include/iprt/time.h        (revision 83483)
++++ include/iprt/time.h        (revision 83484)
+@@ -406,8 +406,20 @@
+ /* PORTME: Add struct timespec guard macro here. */
+-#if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
+- || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
++/*
++ * Starting with Linux kernel version 5.6-rc3, the _STRUCT_TIMESPEC is only defined
++ * under !__KERNEL__ guard and _LINUX_TIME64_H does not define a corresponding
++ * _STRUCT_TIMESPEC64. Only 64-bit time-interfaces are now allowed into the kernel.
++ * We have to keep it for __KERNEL__ though to support older guest kernels (2.6.X)
++ * without _LINUX_TIME64_H.
++ */
++#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H)
++#define RTTIME_NO_TIMESPEC
++#endif
++#if !defined(RTTIME_NO_TIMESPEC) \
++ && (defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) \
++ || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
++ || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_)))
+ /**
+  * Gets the time as POSIX timespec.
+  *
+@@ -443,12 +455,7 @@
+ }
+ #endif /* various ways of detecting struct timespec */
+-#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H)
+-/*
+- * Starting with Linux kernel version 5.6-rc3, the _STRUCT_TIMESPEC is only defined
+- * under !__KERNEL__ guard and _LINUX_TIME64_H does not define a corresponding
+- * _STRUCT_TIMESPEC64. Only 64-bit time-interfaces are now allowed into the kernel.
+- */
++#if defined(RTTIME_NO_TIMESPEC)
+ DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
+ {
+     return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
+Index: src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
+===================================================================
+--- src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c    (revision 83483)
++++ src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c    (revision 83484)
+@@ -194,9 +194,9 @@
+     IPRT_LINUX_RESTORE_EFL_AC();
+ # ifdef _LINUX_TIME64_H
+     return RTTimeSpecSetTimespec64(pTime, &Ts);
+-#else
++# else
+     return RTTimeSpecSetTimespec(pTime, &Ts);
+-#endif
++# endif
+ #else   /* < 2.6.16 */
+     struct timeval Tv;
+     do_gettimeofday(&Tv);
This page took 0.037543 seconds and 4 git commands to generate.