summarylogtreecommitdiffstats
path: root/016-linux-5-4.patch
diff options
context:
space:
mode:
authorDaniel Bermond2019-12-03 01:32:53 +0000
committerDaniel Bermond2019-12-03 01:32:53 +0000
commitfe572a9c209f8a979a99ea2ff5fe3850a6525423 (patch)
tree82fb4d6ee47bdf643c3d8d562853d34f4c4a6da8 /016-linux-5-4.patch
parentdbac723c01bbb4cc88555c4c3872a228977a1a6d (diff)
downloadaur-fe572a9c209f8a979a99ea2ff5fe3850a6525423.tar.gz
Add fix for linux 5.4
Diffstat (limited to '016-linux-5-4.patch')
-rw-r--r--016-linux-5-4.patch272
1 files changed, 272 insertions, 0 deletions
diff --git a/016-linux-5-4.patch b/016-linux-5-4.patch
new file mode 100644
index 000000000000..e29f715b7f9c
--- /dev/null
+++ b/016-linux-5-4.patch
@@ -0,0 +1,272 @@
+https://www.virtualbox.org/changeset/81586/vbox
+https://www.virtualbox.org/changeset/81587/vbox
+https://www.virtualbox.org/changeset/81649/vbox
+
+diff -u -r a/src/vboxhost/vboxdrv/include/iprt/cdefs.h b/src/vboxhost/vboxdrv/include/iprt/cdefs.h
+--- a/src/vboxhost/vboxdrv/include/iprt/cdefs.h 2019-10-10 18:25:42.000000000 +0000
++++ b/src/vboxhost/vboxdrv/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 a/src/vboxhost/vboxnetadp/include/iprt/cdefs.h b/src/vboxhost/vboxnetadp/include/iprt/cdefs.h
+--- a/src/vboxhost/vboxnetadp/include/iprt/cdefs.h 2019-10-10 18:25:42.000000000 +0000
++++ b/src/vboxhost/vboxnetadp/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 a/src/vboxhost/vboxnetflt/include/iprt/cdefs.h b/src/vboxhost/vboxnetflt/include/iprt/cdefs.h
+--- a/src/vboxhost/vboxnetflt/include/iprt/cdefs.h 2019-10-10 18:25:42.000000000 +0000
++++ b/src/vboxhost/vboxnetflt/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 a/src/vboxhost/vboxpci/include/iprt/cdefs.h b/src/vboxhost/vboxpci/include/iprt/cdefs.h
+--- a/src/vboxhost/vboxpci/include/iprt/cdefs.h 2019-10-10 18:25:42.000000000 +0000
++++ b/src/vboxhost/vboxpci/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 a/src/vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c b/src/vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c
+--- a/src/vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c 2019-10-10 18:35:33.000000000 +0000
++++ b/src/vboxhost/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 a/src/vboxhost/vboxdrv/r0drv/linux/alloc-r0drv-linux.c b/src/vboxhost/vboxdrv/r0drv/linux/alloc-r0drv-linux.c
+--- a/src/vboxhost/vboxdrv/r0drv/linux/alloc-r0drv-linux.c 2019-10-10 18:36:16.000000000 +0000
++++ b/src/vboxhost/vboxdrv/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 a/src/vboxhost/vboxdrv/r0drv/linux/memobj-r0drv-linux.c b/src/vboxhost/vboxdrv/r0drv/linux/memobj-r0drv-linux.c
+--- a/src/vboxhost/vboxdrv/r0drv/linux/memobj-r0drv-linux.c 2019-10-10 18:36:16.000000000 +0000
++++ b/src/vboxhost/vboxdrv/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 a/src/vboxhost/vboxdrv/r0drv/linux/the-linux-kernel.h b/src/vboxhost/vboxdrv/r0drv/linux/the-linux-kernel.h
+--- a/src/vboxhost/vboxdrv/r0drv/linux/the-linux-kernel.h 2019-10-10 18:36:16.000000000 +0000
++++ b/src/vboxhost/vboxdrv/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 a/src/vboxhost/vboxdrv/r0drv/linux/thread2-r0drv-linux.c b/src/vboxhost/vboxdrv/r0drv/linux/thread2-r0drv-linux.c
+--- a/src/vboxhost/vboxdrv/r0drv/linux/thread2-r0drv-linux.c 2019-10-10 18:36:16.000000000 +0000
++++ b/src/vboxhost/vboxdrv/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)
+ {