Article 4W3AN VirtualBox on Kernel 5.4.x

VirtualBox on Kernel 5.4.x

by
rahrah
from LinuxQuestions.org on (#4W3AN)
Hi,

Virtualbox 6.0.14 kernel modules did not compile against the latest 5.4.x kernel in slackware-current. The attached patch worked for me.

There are multiple copies of cdefs.h and the-linux-kernel.h, os if your copies aren't hard linked, you may have to copy the patched file over the other copies.

More details can be found here:

https://www.virtualbox.org/ticket/18...=0&cnum_hist=2

I note there are other builds on the VB site that that fix this, too.

Cheers,

===Rich

Code:diff -ur vboxhost.old/vboxdrv/include/iprt/cdefs.h vboxhost/vboxdrv/include/iprt/cdefs.h
--- vboxhost.old/vboxdrv/include/iprt/cdefs.h 2019-02-02 12:26:56.000000000 +0000
+++ vboxhost/vboxdrv/include/iprt/cdefs.h 2019-12-02 23:07:00.385091894 +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 -ur vboxhost.old/vboxdrv/r0drv/linux/the-linux-kernel.h vboxhost/vboxdrv/r0drv/linux/the-linux-kernel.h
--- vboxhost.old/vboxdrv/r0drv/linux/the-linux-kernel.h 2019-09-11 10:59:56.000000000 +0100
+++ vboxhost/vboxdrv/r0drv/linux/the-linux-kernel.h 2019-12-02 23:34:24.912085621 +0000
@@ -336,7 +336,11 @@
# endif
#endif

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+/* XXX The 5.4 kernel has no interface anymore to make kernel pages execcutable */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 4, 0)
+# define MY_SET_PAGES_EXEC(pPages, cPages) do {} while (0)
+# define MY_SET_PAGES_NOEXEC(pPages, cPages) do {} while (0)
+#elif 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)
#else

diff -ur vboxhost.old/vboxdrv/r0drv/linux/thread2-r0drv-linux.c vboxhost/vboxdrv/r0drv/linux/thread2-r0drv-linux.c
--- vboxhost.old/vboxdrv/r0drv/linux/thread2-r0drv-linux.c 2019-01-23 11:39:29.000000000 +0000
+++ vboxhost/vboxdrv/r0drv/linux/thread2-r0drv-linux.c 2019-12-02 23:35:58.608085263 +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

RTDECL(RTTHREAD) RTThreadSelf(void)
{

diff -ur vboxhost.old/vboxnetflt/linux/VBoxNetFlt-linux.c vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c
--- vboxhost.old/vboxnetflt/linux/VBoxNetFlt-linux.c 2019-09-12 13:21:27.000000000 +0100
+++ vboxhost/vboxnetflt/linux/VBoxNetFlt-linux.c 2019-12-02 23:31:34.265086272 +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,14 @@
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);latest?d=yIl2AUoC8zA latest?i=a85KF--SylY:uHlEAoYSdlc:F7zBnMy latest?i=a85KF--SylY:uHlEAoYSdlc:V_sGLiP latest?d=qj6IDK7rITs latest?i=a85KF--SylY:uHlEAoYSdlc:gIN9vFwa85KF--SylY
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments