]> git.pld-linux.org Git - packages/VirtualBox.git/commitdiff
fix build against kernel 5.4 (upstream patch borrowed from Arch); rel 2 auto/th/VirtualBox-6.0.14-2
authorJan Palus <atler@pld-linux.org>
Sat, 30 Nov 2019 14:54:29 +0000 (15:54 +0100)
committerJan Palus <atler@pld-linux.org>
Sat, 30 Nov 2019 14:54:29 +0000 (15:54 +0100)
VirtualBox.spec
linux-5.4.patch [new file with mode: 0644]

index 2ea779b487a7154b39763acb3fa93cb6a13d2603..34efdab972a5ba5985b77fd8709062ffaa2bd4fe 100644 (file)
@@ -42,7 +42,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
@@ -84,6 +84,7 @@ Patch14:      %{pname}-multipython.patch
 Patch15:       %{pname}-lightdm-1.19.2.patch
 Patch16:       %{pname}-no-vboxvideo.patch
 Patch17:       qt5-gl.patch
+Patch18:       linux-5.4.patch
 URL:           http://www.virtualbox.org/
 %if %{with userspace}
 %ifarch %{x8664}
@@ -563,6 +564,7 @@ echo override vboxguest %{_kernel_ver} misc > PLD-MODULE-BUILD/installed/etc/dep
 %patch15 -p0
 %patch16 -p0
 %patch17 -p1
+%patch18 -p1
 
 %{__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/linux-5.4.patch b/linux-5.4.patch
new file mode 100644 (file)
index 0000000..a61e587
--- /dev/null
@@ -0,0 +1,289 @@
+https://www.virtualbox.org/changeset/81586/vbox
+https://www.virtualbox.org/changeset/81587/vbox
+https://www.virtualbox.org/changeset/81649/vbox
+
+diff -u -r VirtualBox-6.0.14/include/iprt/cdefs.h VirtualBox-6.0.14-5.4/include/iprt/cdefs.h
+--- VirtualBox-6.0.14/include/iprt/cdefs.h     2019-10-10 18:25:42.000000000 +0000
++++ VirtualBox-6.0.14-5.4/include/iprt/cdefs.h 2019-11-26 10:08:56.314644140 +0000
+@@ -1166,7 +1166,7 @@
+  * Tell the compiler that we're falling through to the next case in a switch.
+  * @sa RT_FALL_THRU  */
+ #if RT_GNUC_PREREQ(7, 0)
+-# define RT_FALL_THROUGH()      __attribute__((fallthrough))
++# define RT_FALL_THROUGH()      __attribute__((__fallthrough__))
+ #else
+ # define RT_FALL_THROUGH()      (void)0
+ #endif
+diff -u -r VirtualBox-6.0.14/src/VBox/Additions/linux/drm/vbox_drv.c VirtualBox-6.0.14-5.4/src/VBox/Additions/linux/drm/vbox_drv.c
+--- VirtualBox-6.0.14/src/VBox/Additions/linux/drm/vbox_drv.c  2019-10-10 18:28:09.000000000 +0000
++++ VirtualBox-6.0.14-5.4/src/VBox/Additions/linux/drm/vbox_drv.c      2019-11-26 10:08:56.324644270 +0000
+@@ -270,12 +270,16 @@
+ }
+ static struct drm_driver driver = {
++#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)
+       .driver_features =
+           DRIVER_MODESET | DRIVER_GEM | DRIVER_HAVE_IRQ |
+-#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) && !defined(RHEL_81)
++# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 1, 0) && !defined(RHEL_81)
+           DRIVER_IRQ_SHARED |
+-#endif
++# endif /* < KERNEL_VERSION(5, 1, 0) && !defined(RHEL_81) */
+           DRIVER_PRIME,
++#else /* >= KERNEL_VERSION(5, 4, 0) */
++      .driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_HAVE_IRQ,
++#endif /* < KERNEL_VERSION(5, 4, 0) */
+       .dev_priv_size = 0,
+       .load = vbox_driver_load,
+diff -u -r VirtualBox-6.0.14/src/VBox/Additions/linux/drm/vbox_main.c VirtualBox-6.0.14-5.4/src/VBox/Additions/linux/drm/vbox_main.c
+--- VirtualBox-6.0.14/src/VBox/Additions/linux/drm/vbox_main.c 2019-10-10 18:28:09.000000000 +0000
++++ VirtualBox-6.0.14-5.4/src/VBox/Additions/linux/drm/vbox_main.c     2019-11-26 10:08:56.324644270 +0000
+@@ -616,11 +616,13 @@
+ static inline u64 vbox_bo_mmap_offset(struct vbox_bo *bo)
+ {
+-#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) && !defined(RHEL_70)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
++      return drm_vma_node_offset_addr(&bo->bo.base.vma_node);
++#elif LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0) && !defined(RHEL_70)
+       return bo->bo.addr_space_offset;
+ #else
+       return drm_vma_node_offset_addr(&bo->bo.vma_node);
+-#endif
++#endif /* >= KERNEL_VERSION(5, 4, 0) */
+ }
+ int
+diff -u -r VirtualBox-6.0.14/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c VirtualBox-6.0.14-5.4/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
+--- VirtualBox-6.0.14/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c 2019-10-10 18:35:33.000000000 +0000
++++ VirtualBox-6.0.14-5.4/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c     2019-11-26 10:08:56.321310893 +0000
+@@ -924,8 +924,13 @@
+     for (i = 0; i < skb_shinfo(pBuf)->nr_frags; i++)
+     {
+         skb_frag_t *pFrag = &skb_shinfo(pBuf)->frags[i];
++# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
++        pSG->aSegs[iSeg].cb = pFrag->bv_len;
++        pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->bv_offset;
++# else /* < KERNEL_VERSION(5, 4, 0) */
+         pSG->aSegs[iSeg].cb = pFrag->size;
+         pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->page_offset;
++# endif /* >= KERNEL_VERSION(5, 4, 0) */
+         Log6((" %p", pSG->aSegs[iSeg].pv));
+         pSG->aSegs[iSeg++].Phys = NIL_RTHCPHYS;
+         Assert(iSeg <= pSG->cSegsAlloc);
+@@ -940,8 +945,13 @@
+         for (i = 0; i < skb_shinfo(pFragBuf)->nr_frags; i++)
+         {
+             skb_frag_t *pFrag = &skb_shinfo(pFragBuf)->frags[i];
++# if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
++            pSG->aSegs[iSeg].cb = pFrag->bv_len;
++            pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->bv_offset;
++# else /* < KERNEL_VERSION(5, 4, 0) */
+             pSG->aSegs[iSeg].cb = pFrag->size;
+             pSG->aSegs[iSeg].pv = VBOX_SKB_KMAP_FRAG(pFrag) + pFrag->page_offset;
++# endif /* >= KERNEL_VERSION(5, 4, 0) */
+             Log6((" %p", pSG->aSegs[iSeg].pv));
+             pSG->aSegs[iSeg++].Phys = NIL_RTHCPHYS;
+             Assert(iSeg <= pSG->cSegsAlloc);
+diff -u -r VirtualBox-6.0.14/src/VBox/Runtime/common/fs/ntfsvfs.cpp VirtualBox-6.0.14-5.4/src/VBox/Runtime/common/fs/ntfsvfs.cpp
+--- VirtualBox-6.0.14/src/VBox/Runtime/common/fs/ntfsvfs.cpp   2019-10-10 18:36:03.000000000 +0000
++++ VirtualBox-6.0.14-5.4/src/VBox/Runtime/common/fs/ntfsvfs.cpp       2019-11-26 10:08:56.317977517 +0000
+@@ -1052,7 +1052,7 @@
+                     case 4: cClustersInRun |= (uint32_t)pbPairs[offPairs + 3] << 24; RT_FALL_THRU();
+                     case 3: cClustersInRun |= (uint32_t)pbPairs[offPairs + 2] << 16; RT_FALL_THRU();
+                     case 2: cClustersInRun |= (uint16_t)pbPairs[offPairs + 1] <<  8; RT_FALL_THRU();
+-                    case 1: cClustersInRun |= (uint16_t)pbPairs[offPairs + 0] <<  0; RT_FALL_THRU();
++                    case 1: cClustersInRun |= (uint16_t)pbPairs[offPairs + 0] <<  0;
+                 }
+                 offPairs += cbRunField;
+                 AssertBreakStmt(cClustersInRun <= cMaxClustersInRun,
+diff -u -r VirtualBox-6.0.14/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c VirtualBox-6.0.14-5.4/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c
+--- VirtualBox-6.0.14/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c 2019-10-10 18:36:16.000000000 +0000
++++ VirtualBox-6.0.14-5.4/src/VBox/Runtime/r0drv/linux/alloc-r0drv-linux.c     2019-11-26 10:24:51.692930759 +0000
+@@ -443,9 +443,6 @@
+             }
+             SetPageReserved(&paPages[iPage]);
+-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 20) /** @todo find the exact kernel where change_page_attr was introduced. */
+-            MY_SET_PAGES_EXEC(&paPages[iPage], 1);
+-#endif
+         }
+         *pPhys = page_to_phys(paPages);
+         pvRet = phys_to_virt(page_to_phys(paPages));
+@@ -491,9 +488,6 @@
+         for (iPage = 0; iPage < cPages; iPage++)
+         {
+             ClearPageReserved(&paPages[iPage]);
+-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 4, 20) /** @todo find the exact kernel where change_page_attr was introduced. */
+-            MY_SET_PAGES_NOEXEC(&paPages[iPage], 1);
+-#endif
+         }
+         __free_pages(paPages, cOrder);
+         IPRT_LINUX_RESTORE_EFL_AC();
+diff -u -r VirtualBox-6.0.14/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c VirtualBox-6.0.14-5.4/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
+--- VirtualBox-6.0.14/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c        2019-10-10 18:36:16.000000000 +0000
++++ VirtualBox-6.0.14-5.4/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c    2019-11-26 10:09:28.805069152 +0000
+@@ -86,6 +86,8 @@
+     /** Set if the allocation is contiguous.
+      * This means it has to be given back as one chunk. */
+     bool                fContiguous;
++    /** Set if executable allocation. */
++    bool                fExecutable;
+     /** Set if we've vmap'ed the memory into ring-0. */
+     bool                fMappedToRing0;
+     /** The pages in the apPages array. */
+@@ -289,10 +291,11 @@
+  *                      Only valid if fContiguous == true, ignored otherwise.
+  * @param   fFlagsLnx   The page allocation flags (GPFs).
+  * @param   fContiguous Whether the allocation must be contiguous.
++ * @param   fExecutable Whether the memory must be executable.
+  * @param   rcNoMem     What to return when we're out of pages.
+  */
+ static int rtR0MemObjLinuxAllocPages(PRTR0MEMOBJLNX *ppMemLnx, RTR0MEMOBJTYPE enmType, size_t cb,
+-                                     size_t uAlignment, gfp_t fFlagsLnx, bool fContiguous, int rcNoMem)
++                                     size_t uAlignment, gfp_t fFlagsLnx, bool fContiguous, bool fExecutable, int rcNoMem)
+ {
+     size_t          iPage;
+     size_t const    cPages = cb >> PAGE_SHIFT;
+@@ -371,7 +374,8 @@
+     for (iPage = 0; iPage < cPages; iPage++)
+     {
+         pMemLnx->apPages[iPage] = &paPages[iPage];
+-        MY_SET_PAGES_EXEC(pMemLnx->apPages[iPage], 1);
++        if (fExecutable)
++            MY_SET_PAGES_EXEC(pMemLnx->apPages[iPage], 1);
+         if (PageHighMem(pMemLnx->apPages[iPage]))
+             BUG();
+     }
+@@ -379,6 +383,7 @@
+     fContiguous = true;
+ #endif /* < 2.4.22 */
+     pMemLnx->fContiguous = fContiguous;
++    pMemLnx->fExecutable = fExecutable;
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
+     /*
+@@ -409,7 +414,7 @@
+              * This should never happen!
+              */
+             printk("rtR0MemObjLinuxAllocPages(cb=0x%lx, uAlignment=0x%lx): alloc_pages(..., %d) returned physical memory at 0x%lx!\n",
+-                    (unsigned long)cb, (unsigned long)uAlignment, rtR0MemObjLinuxOrder(cPages), (unsigned long)page_to_phys(pMemLnx->apPages[0]));
++                   (unsigned long)cb, (unsigned long)uAlignment, rtR0MemObjLinuxOrder(cPages), (unsigned long)page_to_phys(pMemLnx->apPages[0]));
+             rtR0MemObjLinuxFreePages(pMemLnx);
+             return rcNoMem;
+         }
+@@ -438,14 +443,12 @@
+         while (iPage-- > 0)
+         {
+ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
+-            /*
+-             * See SetPageReserved() in rtR0MemObjLinuxAllocPages()
+-             */
++            /* See SetPageReserved() in rtR0MemObjLinuxAllocPages() */
+             ClearPageReserved(pMemLnx->apPages[iPage]);
+ #endif
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
+-#else
+-            MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1);
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 4, 22)
++            if (pMemLnx->fExecutable)
++                MY_SET_PAGES_NOEXEC(pMemLnx->apPages[iPage], 1);
+ #endif
+         }
+@@ -662,10 +665,10 @@
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 4, 22)
+     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_HIGHUSER,
+-                                   false /* non-contiguous */, VERR_NO_MEMORY);
++                                   false /* non-contiguous */, fExecutable, VERR_NO_MEMORY);
+ #else
+     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_PAGE, cb, PAGE_SIZE, GFP_USER,
+-                                   false /* non-contiguous */, VERR_NO_MEMORY);
++                                   false /* non-contiguous */, fExecutable, VERR_NO_MEMORY);
+ #endif
+     if (RT_SUCCESS(rc))
+     {
+@@ -696,19 +699,19 @@
+ #if (defined(RT_ARCH_AMD64) || defined(CONFIG_X86_PAE)) && defined(GFP_DMA32)
+     /* ZONE_DMA32: 0-4GB */
+     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_DMA32,
+-                                   false /* non-contiguous */, VERR_NO_LOW_MEMORY);
++                                   false /* non-contiguous */, fExecutable, VERR_NO_LOW_MEMORY);
+     if (RT_FAILURE(rc))
+ #endif
+ #ifdef RT_ARCH_AMD64
+         /* ZONE_DMA: 0-16MB */
+         rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_DMA,
+-                                       false /* non-contiguous */, VERR_NO_LOW_MEMORY);
++                                       false /* non-contiguous */, fExecutable, VERR_NO_LOW_MEMORY);
+ #else
+ # ifdef CONFIG_X86_PAE
+ # endif
+         /* ZONE_NORMAL: 0-896MB */
+         rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_LOW, cb, PAGE_SIZE, GFP_USER,
+-                                       false /* non-contiguous */, VERR_NO_LOW_MEMORY);
++                                       false /* non-contiguous */, fExecutable, VERR_NO_LOW_MEMORY);
+ #endif
+     if (RT_SUCCESS(rc))
+     {
+@@ -738,17 +741,17 @@
+ #if (defined(RT_ARCH_AMD64) || defined(CONFIG_X86_PAE)) && defined(GFP_DMA32)
+     /* ZONE_DMA32: 0-4GB */
+     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_DMA32,
+-                                   true /* contiguous */, VERR_NO_CONT_MEMORY);
++                                   true /* contiguous */, fExecutable, VERR_NO_CONT_MEMORY);
+     if (RT_FAILURE(rc))
+ #endif
+ #ifdef RT_ARCH_AMD64
+         /* ZONE_DMA: 0-16MB */
+         rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_DMA,
+-                                       true /* contiguous */, VERR_NO_CONT_MEMORY);
++                                       true /* contiguous */, fExecutable, VERR_NO_CONT_MEMORY);
+ #else
+         /* ZONE_NORMAL (32-bit hosts): 0-896MB */
+         rc = rtR0MemObjLinuxAllocPages(&pMemLnx, RTR0MEMOBJTYPE_CONT, cb, PAGE_SIZE, GFP_USER,
+-                                       true /* contiguous */, VERR_NO_CONT_MEMORY);
++                                       true /* contiguous */, fExecutable, VERR_NO_CONT_MEMORY);
+ #endif
+     if (RT_SUCCESS(rc))
+     {
+@@ -795,7 +798,7 @@
+     rc = rtR0MemObjLinuxAllocPages(&pMemLnx, enmType, cb, uAlignment, fGfp,
+                                    enmType == RTR0MEMOBJTYPE_PHYS /* contiguous / non-contiguous */,
+-                                   VERR_NO_PHYS_MEMORY);
++                                   false /*fExecutable*/, VERR_NO_PHYS_MEMORY);
+     if (RT_FAILURE(rc))
+         return rc;
+diff -u -r VirtualBox-6.0.14/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h VirtualBox-6.0.14-5.4/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h
+--- VirtualBox-6.0.14/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h  2019-10-10 18:36:16.000000000 +0000
++++ VirtualBox-6.0.14-5.4/src/VBox/Runtime/r0drv/linux/the-linux-kernel.h      2019-11-26 10:09:39.218538652 +0000
+@@ -337,8 +337,10 @@
+ #endif
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+-# define MY_SET_PAGES_EXEC(pPages, cPages)    set_pages_x(pPages, cPages)
+-# define MY_SET_PAGES_NOEXEC(pPages, cPages)  set_pages_nx(pPages, cPages)
++# if LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0) /* The interface was removed, but we only need it for < 2.4.22, so who cares. */
++#  define MY_SET_PAGES_EXEC(pPages, cPages)     set_pages_x(pPages, cPages)
++#  define MY_SET_PAGES_NOEXEC(pPages, cPages)   set_pages_nx(pPages, cPages)
++# endif
+ #else
+ # define MY_SET_PAGES_EXEC(pPages, cPages) \
+     do { \
+diff -u -r VirtualBox-6.0.14/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c VirtualBox-6.0.14-5.4/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c
+--- VirtualBox-6.0.14/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c       2019-10-10 18:36:16.000000000 +0000
++++ VirtualBox-6.0.14-5.4/src/VBox/Runtime/r0drv/linux/thread2-r0drv-linux.c   2019-11-26 10:08:56.321310893 +0000
+@@ -36,6 +36,9 @@
+ #include <iprt/errcore.h>
+ #include "internal/thread.h"
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
++    #include <uapi/linux/sched/types.h>
++#endif /* >= KERNEL_VERSION(4, 11, 0) */
+ RTDECL(RTTHREAD) RTThreadSelf(void)
+ {
This page took 0.042982 seconds and 4 git commands to generate.