[vbox-dev] VirtualBox 6.0 - build fix for Linux 5.1

Larry Finger Larry.Finger at lwfinger.net
Wed Mar 20 19:39:00 UTC 2019


On 3/14/19 3:57 PM, Valdis Klētnieks wrote:
> Sayeth Linus:
> 
> commit 736706bee3298208343a76096370e4f6a5c55915
> Author: Linus Torvalds <torvalds at linux-foundation.org>
> Date:   Mon Mar 4 10:39:05 2019 -0800
> 
>      get rid of legacy 'get_ds()' function
>      
>      Every in-kernel use of this function defined it to KERNEL_DS (either as
>      an actual define, or as an inline function).  It's an entirely
>      historical artifact, and long long long ago used to actually read the
>      segment selector valueof '%ds' on x86.
>      
>      Which in the kernel is always KERNEL_DS.
> 
> No kernel release versioning on the patch, as the define was in the tree
> when Linus did the initial import into git for v2.6.12-rc2 back in April 2005.
> If you're trying to build this on a kernel older than that, this is the least of
> your problems. :)
> 
> --- vboxhost/vboxpci/linux/VBoxPci-linux.c.dist	2019-03-14 16:37:18.758730554 -0400
> +++vboxhost/vboxpci/linux/VBoxPci-linux.c	2019-03-14 16:37:46.354160251 -0400
> @@ -372,7 +372,7 @@ static int vboxPciFileWrite(struct file*
>       mm_segment_t fs_save;
>   
>       fs_save = get_fs();
> -    set_fs(get_ds());
> +    set_fs(KERNEL_DS);
>   #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
>       ret = kernel_write(file, data, size, &offset);
>   #else

On openSUSE, I found two additional incompatibilities with kernel 5.1. My 
resulting patch with MIT license is

Index: VirtualBox-6.0.4/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
===================================================================
--- VirtualBox-6.0.4.orig/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
+++ VirtualBox-6.0.4/src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
@@ -38,6 +38,9 @@
  #include <iprt/process.h>
  #include <iprt/string.h>
  #include "internal/memobj.h"
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
+#include <uapi/linux/mman.h>
+#endif


 
/*********************************************************************************************************************************
Index: VirtualBox-6.0.4/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
===================================================================
--- VirtualBox-6.0.4.orig/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
+++ VirtualBox-6.0.4/src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
@@ -372,7 +372,7 @@ static int vboxPciFileWrite(struct file*
      mm_segment_t fs_save;

      fs_save = get_fs();
-    set_fs(get_ds());
+    set_fs(KERNEL_DS);
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 14, 0)
      ret = kernel_write(file, data, size, &offset);
  #else
Index: VirtualBox-6.0.4/src/VBox/Additions/linux/sharedfolders/regops.c
===================================================================
--- VirtualBox-6.0.4.orig/src/VBox/Additions/linux/sharedfolders/regops.c
+++ VirtualBox-6.0.4/src/VBox/Additions/linux/sharedfolders/regops.c
@@ -588,7 +588,9 @@ static int sf_reg_release(struct inode *
         return 0;
  }

-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
+static vm_fault_t sf_reg_fault(struct vm_fault *vmf)
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
  static int sf_reg_fault(struct vm_fault *vmf)
  #elif LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 25)
  static int sf_reg_fault(struct vm_area_struct *vma, struct vm_fault *vmf)

Larry



More information about the vbox-dev mailing list