[vbox-dev] compile patch for 5.1.6

Reinoud Koornstra reinoudkoornstra at gmail.com
Sun Aug 6 23:52:03 GMT 2017


Hello Everyone,

Currently virtualbox 5.1.6 fails to compile for kernel version 4.9 and up.
This is due to a change in get_user_pages api.
The ints for write and force have changed to gup_flags.
Please find the patch attach to fix this for linux 4.9 and up.
Last time I tried to sent it, it wasn't recognized as text, so i'll
paste it in now.
Thanks,

Reinoud.

--- source/r0drv/linux/memobj-r0drv-linux.c.orig 2017-08-01
15:57:35.175068385 -0700
+++ source/r0drv/linux/memobj-r0drv-linux.c 2017-08-01 15:55:43.357301836 -0700
@@ -1018,6 +1018,14 @@
     PRTR0MEMOBJLNX pMemLnx;
     int             rc      = VERR_NO_MEMORY;
     int  const      fWrite  = fAccess & RTMEM_PROT_WRITE ? 1 : 0;
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
+    unsigned int    flags   = 0;
+
+    if (fWrite) {
+ flags = FOLL_WRITE;
+ flags |= FOLL_FORCE;
+    }
+#endif

     /*
      * Check for valid task and size overflows.
@@ -1045,7 +1053,27 @@
         /*
          * Get user pages.
          */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
+        if (R0Process == RTR0ProcHandleSelf())
+            rc = get_user_pages(R3Ptr,                  /* Where from. */
+                                cPages,                 /* How many pages. */
+                                flags,                  /* gup_flags. */
+                                &pMemLnx->apPages[0],   /* Page array. */
+                                papVMAs);               /* vmas */
+        /*
+         * Actually this should not happen at the moment as call this function
+         * only for our own process.
+         */
+        else
+            rc = get_user_pages_remote(
+                                pTask,                  /* Task for
fault accounting. */
+                                pTask->mm,              /* Whose pages. */
+                                R3Ptr,                  /* Where from. */
+                                cPages,                 /* How many pages. */
+                                flags,                  /* gup_flags. */
+                                &pMemLnx->apPages[0],   /* Page array. */
+                                papVMAs);               /* vmas */
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
         if (R0Process == RTR0ProcHandleSelf())
             rc = get_user_pages(R3Ptr,                  /* Where from. */
                                 cPages,                 /* How many pages. */



More information about the vbox-dev mailing list