summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Kitsinger (SwooshyCueb)2016-09-27 11:02:23 -0500
committerMarkus Kitsinger (SwooshyCueb)2016-09-27 11:02:23 -0500
commit2e8f7df8371764316bdfabb7fc56fc0b5464b2be (patch)
tree2595b0e2b78b83e49bcc79707a3cd40af8de3558
parent39dbbade236e336560e3db67cd6864bbf400da34 (diff)
downloadaur-2e8f7df8371764316bdfabb7fc56fc0b5464b2be.tar.gz
Updates for 4.8; Fix vmblock; futher minor changes
-rw-r--r--.SRCINFO18
-rw-r--r--Makefile2
-rw-r--r--NOTES51
-rw-r--r--PKGBUILD18
-rw-r--r--vmblock.patch62
-rw-r--r--vmci.patch162
-rw-r--r--vmmon.patch735
-rw-r--r--vmnet.patch547
-rw-r--r--vsock.patch108
9 files changed, 1589 insertions, 114 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 2cdadae7c7b4..9d8cbc8da650 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -1,9 +1,9 @@
# Generated by mksrcinfo v8
-# Sun Sep 18 22:00:57 UTC 2016
+# Tue Sep 27 16:01:35 UTC 2016
pkgbase = vmware-modules-dkms
pkgdesc = VMware Workstation kernel modules (DKMS)
pkgver = 308.0
- pkgrel = 9
+ pkgrel = 10
url = http://www.vmware.com/
install = vmware-modules-dkms.install
arch = i686
@@ -22,14 +22,16 @@ pkgbase = vmware-modules-dkms
source = vmmon.patch
source = vmnet.patch
source = vsock.patch
- sha256sums = ee3e5cfac51703ac392bce540e3375680c579eaac7aa31990e1e08ada589e89b
+ source = NOTES
+ sha256sums = 9041b85cea2e2c35b27629d47bee2e37b913635e5ace54a46fd9c45f90c4f1d4
sha256sums = 7baecdfd979d57aed7dac0db57e0165fc1730b15ed6bf42ed25571e68ec34b52
sha256sums = 707596776b0b232f7f5de4a0ddff12262df3bc934180afd956ea2ee45ac4db9e
- sha256sums = 48951fcb72e1f964e21dc3f7ea4729dd673936abdd28b54008dbca9b0967683f
- sha256sums = cea6c1e3d76063a95b6e71a46f90557a06e3a668457eb0eeede66e7f121cfa5f
- sha256sums = 8bb2e4dae95523024515b850a253baca4e6da914a85a5a3b237d4390c2617aa7
- sha256sums = 2eb2ad24722e0ddd97387c48266295204aea95de8970eec427e3931769d15e19
- sha256sums = a97e5096ef1b1595b2d1ed6b86b0fde80e34c6310f566156bcd4f5d660a74a58
+ sha256sums = b81a2c26a6af145a934118a0d19d22ff7a73464dfa849d24ba0dd785f119ae7e
+ sha256sums = 84ddf2d77039ca558466682a23280ecbb0ec4b6bf9a5b4561f161c78e32b57a1
+ sha256sums = 663dbccace714d719e3d27337fc5acabded61dbe5889af7c3bd28e0fbcef115e
+ sha256sums = 31c626d7686f9d8d50b3ab09ada45f6bdcaf97c47f62de3ff2494c99b19f90d0
+ sha256sums = 50bf86f3306fbdafa0a5d5947fb64c06e2a236be84e2ba3f7057f84cc49f7828
+ sha256sums = SKIP
pkgname = vmware-modules-dkms
diff --git a/Makefile b/Makefile
index 56ba2d9823f6..8273f0ad4bb0 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ KVERSION = $(shell uname -r)
all: $(foreach m, $(MODULES), $m.ko)
%.ko: % $(TARDIR)/%.tar
- $(MAKE) VM_UNAME=$(KVERSION) VM_KBUILD=yes -C $*
+ $(MAKE) KVERSION=$(KVERSION) VM_KBUILD=yes -C $*
mv $*.o $*.ko
$(MODULES): %: $(TARDIR)/%.tar
diff --git a/NOTES b/NOTES
new file mode 100644
index 000000000000..360fdd40ea3a
--- /dev/null
+++ b/NOTES
@@ -0,0 +1,51 @@
+NOTES
+===============================================================================
+I may not be able to update this aur package as quickly as some folks would
+like. I have disowned the package before, but nobody else stepped up to
+maintain it. Since I have to force the dkms modules into submission every so
+often anyway, I might as well continue to update this package whenever I am
+able, or until a new maintainer takes over. ~MK
+
+These patches are currently only compatible with the dkms module sources that
+come with VMware Workstation/Player 12.5, as far as I'm aware. ~MK
+
+A fair amount of the patches, I adapt from here:
+https://github.com/gentoo/vmware/tree/master/app-emulation/vmware-modules/files
+It's not always a one-to-one copy, as our patches seem to go back further than
+these, and, at the time of this writing, these patches are not updated for
+VMware Workstation/Player 12.5. There are also various other differences. ~MK
+
+I cannot test how the changes I make affect every version of the Linux kernel,
+so things might break if you're using an older version. Let me know if this
+happens and I'll see what I can do. ~MK
+
+Some of the changes made in commit 39dbbade236e336560e3db67cd6864bbf400da34 may
+need some review. In particular, the changes to the patching of
+vmci/linux/driver.c. This may also require a review of the change to
+vmci/shared/vmci_kernel_if.h. ~MK
+
+The version number we're using for the package (currently 308) comes from the
+VMMON_VERSION define in vmmon/include/iocontrols.h. This only seems to change
+with bumps to the major version number of VMware Workstation/Player, while the
+actual dkms module sources change more often. I would like to find something
+more reliable to base our version number on. In doing so, we might open up the
+possibility to make this package compatible with multiple versions of the dkms
+modules. ~MK
+
+I have my text editor set to trim trailing whitespace, and to ensure that files
+always end with a newline. Because of this, some superfluous patch chunks will
+likely make their way into the patches from time to time. Getting rid of these
+isn't the highest priority, but as I have time, I will try to neaten up the
+patch files. ~MK
+
+I considered adding the VMware Player 12.5 bundle to sources in PKGBUILD, so
+that we have a guaranteed fresh copy of the dkms module sources, but I have
+decided against it for the time-being. Feedback on this would be appreciated.
+~MK
+
+I would like to see about making an open-vm-tools package that is compatible
+with this one, as it would seem that there are many components in
+open-vm-tools, and only a small subset actually conflict. ~MK
+
+Currently, vsock doesn't work. It compiles fine, but it spits out symbol
+version disagreements when you try to load it. ~MK
diff --git a/PKGBUILD b/PKGBUILD
index 161e1b6db9a6..eabb58c62511 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -11,7 +11,7 @@
pkgname=vmware-modules-dkms
_pkgbase=vmware-modules
pkgver=308.0
-pkgrel=9
+pkgrel=10
pkgdesc="VMware Workstation kernel modules (DKMS)"
arch=('i686' 'x86_64')
url="http://www.vmware.com/"
@@ -32,15 +32,17 @@ source=('Makefile'
'vmci.patch'
'vmmon.patch'
'vmnet.patch'
- 'vsock.patch')
-sha256sums=('ee3e5cfac51703ac392bce540e3375680c579eaac7aa31990e1e08ada589e89b'
+ 'vsock.patch'
+ 'NOTES')
+sha256sums=('9041b85cea2e2c35b27629d47bee2e37b913635e5ace54a46fd9c45f90c4f1d4'
'7baecdfd979d57aed7dac0db57e0165fc1730b15ed6bf42ed25571e68ec34b52'
'707596776b0b232f7f5de4a0ddff12262df3bc934180afd956ea2ee45ac4db9e'
- '48951fcb72e1f964e21dc3f7ea4729dd673936abdd28b54008dbca9b0967683f'
- 'cea6c1e3d76063a95b6e71a46f90557a06e3a668457eb0eeede66e7f121cfa5f'
- '8bb2e4dae95523024515b850a253baca4e6da914a85a5a3b237d4390c2617aa7'
- '2eb2ad24722e0ddd97387c48266295204aea95de8970eec427e3931769d15e19'
- 'a97e5096ef1b1595b2d1ed6b86b0fde80e34c6310f566156bcd4f5d660a74a58')
+ 'b81a2c26a6af145a934118a0d19d22ff7a73464dfa849d24ba0dd785f119ae7e'
+ '84ddf2d77039ca558466682a23280ecbb0ec4b6bf9a5b4561f161c78e32b57a1'
+ '663dbccace714d719e3d27337fc5acabded61dbe5889af7c3bd28e0fbcef115e'
+ '31c626d7686f9d8d50b3ab09ada45f6bdcaf97c47f62de3ff2494c99b19f90d0'
+ '50bf86f3306fbdafa0a5d5947fb64c06e2a236be84e2ba3f7057f84cc49f7828'
+ 'SKIP')
build()
{
diff --git a/vmblock.patch b/vmblock.patch
index 314b0bfb0f0d..cad47e8d6a2f 100644
--- a/vmblock.patch
+++ b/vmblock.patch
@@ -1,3 +1,32 @@
+diff --git a/vmblock/Makefile b/vmblock/Makefile
+index bbfe225..8ec1a86 100644
+--- a/vmblock/Makefile
++++ b/vmblock/Makefile
+@@ -43,7 +43,11 @@ INCLUDE += -I$(SRCROOT)/shared
+ endif
+
+
++ifdef KVERSION
++VM_UNAME = $(KVERSION)
++else
+ VM_UNAME = $(shell uname -r)
++endif
+
+ # Header directory for the running kernel
+ ifdef LINUXINCLUDE
+diff --git a/vmblock/Makefile.kernel b/vmblock/Makefile.kernel
+index ab7a727..e3ec9d2 100644
+--- a/vmblock/Makefile.kernel
++++ b/vmblock/Makefile.kernel
+@@ -19,7 +19,7 @@
+
+ INCLUDE += -I$(SRCROOT)/include
+
+-EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE)
++EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) $(LINUXINCLUDE)
+
+ EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/cachecreate.c, -DVMW_KMEMCR_HAS_DTOR, )
+ EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/cachector.c, -DVMW_KMEMCR_CTOR_HAS_3_ARGS, )
diff --git a/vmblock/linux/control.c b/vmblock/linux/control.c
index 79716bd..5b6acb2 100644
--- a/vmblock/linux/control.c
@@ -233,7 +262,7 @@ index d7ac1f6..c5e6604 100644
.release = FileOpRelease,
};
diff --git a/vmblock/linux/inode.c b/vmblock/linux/inode.c
-index 098c94c..a179d72 100644
+index 098c94c..bd2bf01 100644
--- a/vmblock/linux/inode.c
+++ b/vmblock/linux/inode.c
@@ -35,13 +35,24 @@
@@ -255,10 +284,10 @@ index 098c94c..a179d72 100644
+static int InodeOpReadlink(struct dentry *dentry, char __user *buffer, int buflen);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 13)
static int InodeOpFollowlink(struct dentry *dentry, struct nameidata *nd);
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 99)
+static const char *InodeOpGetLink(struct dentry *dentry, struct inode *inode,
+ struct delayed_call *done);
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 99)
+static const char *InodeOpFollowlink(struct dentry *dentry, void **cookie);
+#else
+static void *InodeOpFollowlink(struct dentry *dentry, struct nameidata *nd);
@@ -270,10 +299,9 @@ index 098c94c..a179d72 100644
};
-static struct inode_operations LinkInodeOps = {
-- .readlink = InodeOpReadlink,
+struct inode_operations LinkInodeOps = {
-+ .readlink = InodeOpReadlink,
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
+ .readlink = InodeOpReadlink,
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 99)
+ .get_link = InodeOpGetLink,
+#else
.follow_link = InodeOpFollowlink,
@@ -306,20 +334,22 @@ index 098c94c..a179d72 100644
inode->i_op = &LinkInodeOps;
d_add(dentry, inode);
-@@ -176,8 +200,11 @@ InodeOpReadlink(struct dentry *dentry, // IN : dentry of symlink
+@@ -176,8 +200,13 @@ InodeOpReadlink(struct dentry *dentry, // IN : dentry of symlink
if (!iinfo) {
return -EINVAL;
}
-
+#if LINUX_VERSION_CODE <= KERNEL_VERSION(3, 14, 99)
return vfs_readlink(dentry, buffer, buflen, iinfo->name);
-+#else
++#elif LINUX_VERSION_CODE <= KERNEL_VERSION(4, 6, 99)
+ return readlink_copy(buffer, buflen, iinfo->name);
++#else
++ return generic_readlink(dentry, buffer, buflen);
+#endif
}
-@@ -198,30 +225,58 @@ InodeOpReadlink(struct dentry *dentry, // IN : dentry of symlink
+@@ -198,30 +227,58 @@ InodeOpReadlink(struct dentry *dentry, // IN : dentry of symlink
*----------------------------------------------------------------------------
*/
@@ -328,18 +358,18 @@ index 098c94c..a179d72 100644
+static
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 13)
+int
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 99)
+const char *
#else
-static int
+void *
#endif
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 99)
+InodeOpGetLink(struct dentry *dentry, struct inode *inode,
+ struct delayed_call *done)
+#else
InodeOpFollowlink(struct dentry *dentry, // IN : dentry of symlink
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 99)
+ void **cookie)
+#else
struct nameidata *nd) // OUT: stores result
@@ -350,7 +380,7 @@ index 098c94c..a179d72 100644
VMBlockInodeInfo *iinfo;
if (!dentry) {
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 99)
+ ret = -ECHILD;
+#else
Warning("InodeOpReadlink: invalid args from kernel\n");
@@ -359,7 +389,7 @@ index 098c94c..a179d72 100644
goto out;
}
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 99)
+ iinfo = INODE_TO_IINFO(inode);
+#else
iinfo = INODE_TO_IINFO(dentry->d_inode);
@@ -371,9 +401,9 @@ index 098c94c..a179d72 100644
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 12, 0)
ret = vfs_follow_link(nd, iinfo->name);
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 0)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 99)
+ return (char *)(iinfo->name);
-+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
++#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 99)
+ return *cookie = (char *)(iinfo->name);
+#else
+ nd_set_link(nd, iinfo->name);
diff --git a/vmci.patch b/vmci.patch
index 4dc66c59e70c..d1520050ccac 100644
--- a/vmci.patch
+++ b/vmci.patch
@@ -1,16 +1,62 @@
+diff --git a/vmci/Makefile b/vmci/Makefile
+index c630705..18357e5 100644
+--- a/vmci/Makefile
++++ b/vmci/Makefile
+@@ -43,7 +43,11 @@ INCLUDE += -I$(SRCROOT)/shared
+ endif
+
+
++ifdef KVERSION
++VM_UNAME = $(KVERSION)
++else
+ VM_UNAME = $(shell uname -r)
++endif
+
+ # Header directory for the running kernel
+ ifdef LINUXINCLUDE
+diff --git a/vmci/Makefile.kernel b/vmci/Makefile.kernel
+index 8e6e7d0..28eb503 100644
+--- a/vmci/Makefile.kernel
++++ b/vmci/Makefile.kernel
+@@ -21,7 +21,7 @@ CC_OPTS += -DVMCI
+
+ INCLUDE += -I$(SRCROOT)/shared -I$(SRCROOT)/common -I$(SRCROOT)/linux
+
+-EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE)
++EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) $(LINUXINCLUDE)
+
+ obj-m += $(DRIVER).o
+
diff --git a/vmci/linux/driver.c b/vmci/linux/driver.c
-index f676166..8e6f71f 100644
+index f676166..06b3d8a 100644
--- a/vmci/linux/driver.c
+++ b/vmci/linux/driver.c
@@ -26,6 +26,7 @@
-
+
#include <linux/file.h>
#include <linux/fs.h>
+#include <linux/vmalloc.h>
#include <linux/init.h>
#if defined(__x86_64__) && LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12)
# include <linux/ioctl32.h>
-@@ -1687,7 +1688,11 @@ vmci_guest_init(void)
+@@ -1467,12 +1468,13 @@ VMCIUserVALockPage(VA addr) // IN:
+ int retval;
+
+ down_read(&current->mm->mmap_sem);
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
+- retval = get_user_pages(addr, 1, 1, 0, &page, NULL);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 99)
++ retval = get_user_pages(addr,
+ #else
+ retval = get_user_pages(current, current->mm, addr,
+- 1, 1, 0, &page, NULL);
+ #endif
++ 1, 1, 0, &page, NULL);
++
+ up_read(&current->mm->mmap_sem);
+
+ if (retval != 1) {
+@@ -1687,7 +1689,11 @@ vmci_guest_init(void)
/* This should be last to make sure we are done initializing. */
retval = pci_register_driver(&vmci_driver);
if (retval < 0) {
@@ -22,8 +68,8 @@ index f676166..8e6f71f 100644
data_buffer = NULL;
return retval;
}
-@@ -2474,7 +2479,11 @@ vmci_exit(void)
-
+@@ -2474,7 +2480,11 @@ vmci_exit(void)
+
if (guestDeviceInit) {
pci_unregister_driver(&vmci_driver);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 15, 0)
@@ -33,26 +79,18 @@ index f676166..8e6f71f 100644
+#endif
guestDeviceInit = FALSE;
}
-
-@@ -2483,12 +2492,16 @@ vmci_exit(void)
-
+
+@@ -2483,7 +2493,7 @@ vmci_exit(void)
+
VMCI_HostCleanup();
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
- retval = misc_deregister(&linuxState.misc);
+
+- retval = misc_deregister(&linuxState.misc);
++ retval = compat_misc_deregister(&linuxState.misc);
if (retval) {
Warning(LGPFX "Module %s: error unregistering\n", VMCI_MODULE_NAME);
} else {
- Log(LGPFX"Module %s: unloaded\n", VMCI_MODULE_NAME);
- }
-+#else
-+ misc_deregister(&linuxState.misc);
-+#endif
-
- hostDeviceInit = FALSE;
- }
diff --git a/vmci/linux/vmciKernelIf.c b/vmci/linux/vmciKernelIf.c
-index 3fba8b6..f60d7b1 100644
+index 3fba8b6..d41769f 100644
--- a/vmci/linux/vmciKernelIf.c
+++ b/vmci/linux/vmciKernelIf.c
@@ -40,6 +40,7 @@
@@ -60,12 +98,12 @@ index 3fba8b6..f60d7b1 100644
#include <linux/vmalloc.h>
#include <linux/wait.h>
+#include <linux/skbuff.h>
-
+
#include "compat_highmem.h"
#include "compat_interrupt.h"
-@@ -1198,11 +1199,19 @@ __VMCIMemcpyToQueue(VMCIQueue *queue, // OUT:
+@@ -1198,16 +1199,29 @@ __VMCIMemcpyToQueue(VMCIQueue *queue, // OUT:
}
-
+
if (isIovec) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
struct iovec *iov = (struct iovec *)src;
@@ -73,19 +111,29 @@ index 3fba8b6..f60d7b1 100644
+ struct msghdr *msg = (struct msghdr *)src;
+#endif
int err;
-
+
/* The iovec will track bytesCopied internally. */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
err = memcpy_fromiovec((uint8 *)va + pageOffset, iov, toCopy);
+#else
-+ err = memcpy_from_msg((u8 *)va + pageOffset, msg, toCopy);
++ err = memcpy_from_msg((uint8 *)va + pageOffset, msg, toCopy);
+#endif
if (err != 0) {
if (kernelIf->host) {
kunmap(kernelIf->u.h.page[pageIndex]);
-@@ -1273,11 +1282,19 @@ __VMCIMemcpyFromQueue(void *dest, // OUT:
++#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
+ }
+ return VMCI_ERROR_INVALID_ARGS;
++#else
++ return VMCI_ERROR_INVALID_ARGS;
++ }
++#endif
+ }
+ } else {
+ memcpy((uint8 *)va + pageOffset, (uint8 *)src + bytesCopied, toCopy);
+@@ -1273,11 +1287,19 @@ __VMCIMemcpyFromQueue(void *dest, // OUT:
}
-
+
if (isIovec) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
struct iovec *iov = (struct iovec *)dest;
@@ -93,7 +141,7 @@ index 3fba8b6..f60d7b1 100644
+ struct msghdr *msg = (struct msghdr *)dest;
+#endif
int err;
-
+
/* The iovec will track bytesCopied internally. */
+#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 19, 0)
err = memcpy_toiovec(iov, (uint8 *)va + pageOffset, toCopy);
@@ -103,11 +151,11 @@ index 3fba8b6..f60d7b1 100644
if (err != 0) {
if (kernelIf->host) {
kunmap(kernelIf->u.h.page[pageIndex]);
-@@ -1834,7 +1851,11 @@ VMCIReleasePages(struct page **pages, // IN
+@@ -1834,7 +1856,11 @@ VMCIReleasePages(struct page **pages, // IN
if (dirty) {
set_page_dirty(pages[i]);
}
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 99)
+ put_page(pages[i]);
+#else
page_cache_release(pages[i]);
@@ -115,19 +163,63 @@ index 3fba8b6..f60d7b1 100644
pages[i] = NULL;
}
}
-@@ -2070,8 +2091,12 @@ VMCIHost_GetUserMemory(VA64 produceUVA, // IN
+@@ -2048,21 +2074,18 @@ VMCIHost_GetUserMemory(VA64 produceUVA, // IN
+ int err = VMCI_SUCCESS;
+
+ down_write(&current->mm->mmap_sem);
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 99)
+ retval = get_user_pages((VA)produceUVA,
+- produceQ->kernelIf->numPages,
+- 1, 0,
+- produceQ->kernelIf->u.h.headerPage,
+- NULL);
+ #else
+ retval = get_user_pages(current,
+ current->mm,
+ (VA)produceUVA,
++#endif
+ produceQ->kernelIf->numPages,
+ 1, 0,
+ produceQ->kernelIf->u.h.headerPage,
+ NULL);
+-#endif
++
+ if (retval < produceQ->kernelIf->numPages) {
+ Log("get_user_pages(produce) failed (retval=%d)\n", retval);
+ VMCIReleasePages(produceQ->kernelIf->u.h.headerPage, retval, FALSE);
+@@ -2070,9 +2093,13 @@ VMCIHost_GetUserMemory(VA64 produceUVA, // IN
goto out;
}
-
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
-+ retval = get_user_pages(
+
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 99)
++ retval = get_user_pages((VA)consumeUVA,
+#else
retval = get_user_pages(current,
current->mm,
-+#endif
(VA)consumeUVA,
++#endif
consumeQ->kernelIf->numPages,
1, 0,
+ consumeQ->kernelIf->u.h.headerPage,
+diff --git a/vmci/shared/compat_module.h b/vmci/shared/compat_module.h
+index 2af7372..729aedc 100644
+--- a/vmci/shared/compat_module.h
++++ b/vmci/shared/compat_module.h
+@@ -80,4 +80,13 @@ static const char __module_cat(tag, __LINE__)[] \
+ typedef int compat_mod_param_bool;
+ #endif
+
++/*
++ * Linux kernel >= 4.2.99 does not return anything from misc_deregister
++ */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 99)
++#define compat_misc_deregister(misc) misc_deregister(misc)
++#else
++#define compat_misc_deregister(misc) ({misc_deregister(misc);0;})
++#endif
++
+ #endif /* __COMPAT_MODULE_H__ */
diff --git a/vmci/shared/vm_device_version.h b/vmci/shared/vm_device_version.h
index e2cb477..3dd7097 100644
--- a/vmci/shared/vm_device_version.h
diff --git a/vmmon.patch b/vmmon.patch
index 1346e2e979b7..fb60455d2111 100644
--- a/vmmon.patch
+++ b/vmmon.patch
@@ -1,8 +1,124 @@
+diff --git a/vmmon/Makefile b/vmmon/Makefile
+index de8162e..6124a71 100644
+--- a/vmmon/Makefile
++++ b/vmmon/Makefile
+@@ -43,7 +43,11 @@ INCLUDE += -I$(SRCROOT)/shared
+ endif
+
+
++ifdef KVERSION
++VM_UNAME = $(KVERSION)
++else
+ VM_UNAME = $(shell uname -r)
++endif
+
+ # Header directory for the running kernel
+ ifdef LINUXINCLUDE
+diff --git a/vmmon/Makefile.kernel b/vmmon/Makefile.kernel
+index bf805e0..9aac585 100644
+--- a/vmmon/Makefile.kernel
++++ b/vmmon/Makefile.kernel
+@@ -22,7 +22,7 @@ CC_OPTS += -DVMMON -DVMCORE
+ INCLUDE := -I$(SRCROOT)/include -I$(SRCROOT)/common -I$(SRCROOT)/linux \
+ -I$(SRCROOT)/vmcore
+
+-EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE)
++EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) $(LINUXINCLUDE)
+
+ EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/smpcall.c, -DVMW_HAVE_SMP_CALL_3ARG, )
+ EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/tsc_khz.c, -DVMW_HAVE_TSC_KHZ, )
+diff --git a/vmmon/include/compat_module.h b/vmmon/include/compat_module.h
+index 2af7372..729aedc 100644
+--- a/vmmon/include/compat_module.h
++++ b/vmmon/include/compat_module.h
+@@ -80,4 +80,13 @@ static const char __module_cat(tag, __LINE__)[] \
+ typedef int compat_mod_param_bool;
+ #endif
+
++/*
++ * Linux kernel >= 4.2.99 does not return anything from misc_deregister
++ */
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 99)
++#define compat_misc_deregister(misc) misc_deregister(misc)
++#else
++#define compat_misc_deregister(misc) ({misc_deregister(misc);0;})
++#endif
++
+ #endif /* __COMPAT_MODULE_H__ */
diff --git a/vmmon/linux/driver.c b/vmmon/linux/driver.c
-index 87cf45b..6e90af4 100644
+index 87cf45b..5390a93 100644
--- a/vmmon/linux/driver.c
+++ b/vmmon/linux/driver.c
-@@ -1279,7 +1279,7 @@ LinuxDriverReadTSC(void *data, // OUT: TSC values
+@@ -124,7 +124,16 @@ static struct vm_operations_struct vmuser_mops = {
+ #endif
+ };
+
+-static struct file_operations vmuser_fops;
++static struct file_operations vmuser_fops = {
++ .owner = THIS_MODULE,
++ .poll = LinuxDriverPoll,
++ .unlocked_ioctl = LinuxDriver_Ioctl,
++ .compat_ioctl = LinuxDriver_Ioctl,
++ .open = LinuxDriver_Open,
++ .release = LinuxDriver_Close,
++ .mmap = LinuxDriverMmap
++};
++
+ static struct timer_list tscTimer;
+ static Atomic_uint32 tsckHz;
+ static VmTimeStart tsckHzStartTime;
+@@ -254,7 +263,7 @@ static void
+ LinuxDriverInitTSCkHz(void)
+ {
+ unsigned int khz;
+-
++
+ khz = compat_tsc_khz();
+ if (khz != 0) {
+ Atomic_Write(&tsckHz, khz);
+@@ -269,7 +278,7 @@ LinuxDriverInitTSCkHz(void)
+ add_timer(&tscTimer);
+ }
+
+-
++
+ /*
+ *----------------------------------------------------------------------
+ *
+@@ -317,21 +326,6 @@ init_module(void)
+ linuxState.fastClockPriority = -20;
+ linuxState.swapSize = VMMON_UNKNOWN_SWAP_SIZE;
+
+- /*
+- * Initialize the file_operations structure. Because this code is always
+- * compiled as a module, this is fine to do it here and not in a static
+- * initializer.
+- */
+-
+- memset(&vmuser_fops, 0, sizeof vmuser_fops);
+- vmuser_fops.owner = THIS_MODULE;
+- vmuser_fops.poll = LinuxDriverPoll;
+- vmuser_fops.unlocked_ioctl = LinuxDriver_Ioctl;
+- vmuser_fops.compat_ioctl = LinuxDriver_Ioctl;
+- vmuser_fops.open = LinuxDriver_Open;
+- vmuser_fops.release = LinuxDriver_Close;
+- vmuser_fops.mmap = LinuxDriverMmap;
+-
+ #ifdef VMX86_DEVEL
+ devel_init_module();
+ linuxState.minor = 0;
+@@ -387,7 +381,9 @@ cleanup_module(void)
+ #ifdef VMX86_DEVEL
+ unregister_chrdev(linuxState.major, linuxState.deviceName);
+ #else
+- misc_deregister(&linuxState.misc);
++ if (compat_misc_deregister(&linuxState.misc)) {
++ Warning("Module %s: error unregistering\n", linuxState.deviceName);
++ }
+ #endif
+
+ Log("Module %s: unloaded\n", linuxState.deviceName);
+@@ -1279,7 +1275,7 @@ LinuxDriverReadTSC(void *data, // OUT: TSC values
*-----------------------------------------------------------------------------
*/
@@ -11,8 +127,17 @@ index 87cf45b..6e90af4 100644
LinuxDriverSyncReadTSCs(uint64 *delta) // OUT: TSC max - TSC min
{
TSCDelta tscDelta;
+@@ -1971,7 +1967,7 @@ LinuxDriver_Ioctl(struct file *filp, // IN:
+ break;
+ }
+
+- default:
++ default:
+ Warning("Unknown ioctl %d\n", iocmd);
+ retval = -EINVAL;
+ }
diff --git a/vmmon/linux/hostif.c b/vmmon/linux/hostif.c
-index 7053a83..a4a4eb2 100644
+index 7053a83..219d244 100644
--- a/vmmon/linux/hostif.c
+++ b/vmmon/linux/hostif.c
@@ -74,6 +74,7 @@
@@ -23,6 +148,610 @@ index 7053a83..a4a4eb2 100644
#include "vmware.h"
#include "x86apic.h"
+@@ -139,6 +140,10 @@ static DECLARE_TASKLET(timerTasklet, HostIFWakeupClockThread, 0);
+ */
+ #define LOCKED_PAGE_SLACK 10000
+
++#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 7, 99)
++#define NR_ANON_PAGES NR_ANON_MAPPED
++#endif
++
+ static struct {
+ Atomic_uint64 uptimeBase;
+ VersionedAtomic version;
+@@ -435,7 +440,7 @@ HostIF_CancelWaitForThreads(VMDriver *vm, // IN:
+ * HostIF_WakeUpYielders --
+ *
+ * Wakeup vCPUs that are waiting for the current vCPU.
+- *
++ *
+ * Results:
+ * The requested vCPUs are nudged if they are sleeping due to
+ * Vmx86_YieldToSet.
+@@ -518,7 +523,7 @@ HostIF_InitGlobalLock(void)
+ * None
+ *
+ * Side effects:
+- * Should be a very low contention lock.
++ * Should be a very low contention lock.
+ * The current thread is rescheduled if the lock is busy.
+ *
+ *-----------------------------------------------------------------------------
+@@ -561,7 +566,7 @@ HostIF_GlobalUnlock(int callerID) // IN
+ * HostIF_GlobalLockIsHeld --
+ *
+ * Determine if the global lock is held by the current thread.
+- *
++ *
+ * Results:
+ * TRUE if yes
+ * FALSE if no
+@@ -591,7 +596,7 @@ HostIF_GlobalLockIsHeld(void)
+ * None
+ *
+ * Side effects:
+- * Should be a very low contention lock.
++ * Should be a very low contention lock.
+ * The current thread is rescheduled if the lock is busy.
+ *
+ *-----------------------------------------------------------------------------
+@@ -726,7 +731,7 @@ static int
+ HostIFHostMemInit(VMDriver *vm) // IN:
+ {
+ VMHost *vmh = vm->vmhost;
+-
++
+ vmh->lockedPages = PhysTrack_Alloc(vm);
+ if (!vmh->lockedPages) {
+ return -1;
+@@ -821,8 +826,8 @@ HostIF_AllocMachinePage(void)
+ *
+ * HostIF_FreeMachinePage --
+ *
+- * Free an anonymous machine page allocated by
+- * HostIF_AllocMachinePage(). This page is not tracked in any
++ * Free an anonymous machine page allocated by
++ * HostIF_AllocMachinePage(). This page is not tracked in any
+ * phystracker.
+ *
+ * Results:
+@@ -1115,7 +1120,7 @@ HostIF_LookupUserMPN(VMDriver *vm, // IN: VMDriver
+ * Results:
+ * prevents INTR #0x2d (IRQ 13) from being generated --
+ * assume that Int16 works for interrupt reporting
+- *
++ *
+ *
+ * Side effects:
+ * PIC
+@@ -1130,7 +1135,7 @@ HostIF_InitFP(VMDriver *vm) // IN:
+
+ uint8 val = inb(0xA1);
+
+- if (!(val & mask)) {
++ if (!(val & mask)) {
+ val = val | mask;
+ outb(val, 0xA1);
+ }
+@@ -1146,7 +1151,7 @@ HostIF_InitFP(VMDriver *vm) // IN:
+ * If ppages is NULL, pages are only marked as dirty.
+ *
+ * Results:
+- * Zero on success, non-zero on failure.
++ * Zero on success, non-zero on failure.
+ *
+ * Side effects:
+ * None
+@@ -1162,12 +1167,12 @@ HostIFGetUserPages(void *uvAddr, // IN
+ int retval;
+
+ down_read(&current->mm->mmap_sem);
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
+- retval = get_user_pages((unsigned long)uvAddr, numPages, 0, 0, ppages, NULL);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 99)
++ retval = get_user_pages((unsigned long)uvAddr,
+ #else
+ retval = get_user_pages(current, current->mm, (unsigned long)uvAddr,
+- numPages, 0, 0, ppages, NULL);
+ #endif
++ numPages, 0, 0, ppages, NULL);
+ up_read(&current->mm->mmap_sem);
+
+ return retval != numPages;
+@@ -1179,11 +1184,11 @@ HostIFGetUserPages(void *uvAddr, // IN
+ *
+ * HostIF_IsLockedByMPN --
+ *
+- * Checks if mpn was locked using allowMultipleMPNsPerVA.
++ * Checks if mpn was locked using allowMultipleMPNsPerVA.
+ *
+ * Results:
+ * TRUE if mpn is present in the physTracker.
+- *
++ *
+ *
+ * Side effects:
+ * None.
+@@ -1305,7 +1310,7 @@ HostIF_UnlockPage(VMDriver *vm, // IN:
+
+ vpn = VA_2_VPN((VA)addr);
+ e = MemTrack_LookupVPN(vm->memtracker, vpn);
+-
++
+ if (e == NULL) {
+ return PAGE_UNLOCK_NOT_TRACKED;
+ }
+@@ -1351,7 +1356,7 @@ HostIF_UnlockPageByMPN(VMDriver *vm, // IN: VMDriver
+ {
+ void *va = VA64ToPtr(uAddr);
+ MemTrackEntry *e;
+-
++
+ /*
+ * Verify for debugging that VA and MPN make sense.
+ * PgtblVa2MPN() can fail under high memory pressure.
+@@ -1369,7 +1374,7 @@ HostIF_UnlockPageByMPN(VMDriver *vm, // IN: VMDriver
+ }
+
+ /*
+- * Verify that this MPN was locked with
++ * Verify that this MPN was locked with
+ * HostIF_LockPage(allowMultipleMPNsPerVA = TRUE).
+ * That means that this MPN should not be in the MemTracker.
+ */
+@@ -1382,7 +1387,7 @@ HostIF_UnlockPageByMPN(VMDriver *vm, // IN: VMDriver
+ return PAGE_UNLOCK_MISMATCHED_TYPE;
+ }
+ }
+-#endif
++#endif
+
+ HOST_UNLOCK_PFN_BYMPN(vm, mpn);
+
+@@ -1390,7 +1395,7 @@ HostIF_UnlockPageByMPN(VMDriver *vm, // IN: VMDriver
+ }
+
+
+-static void
++static void
+ UnlockEntry(void *clientData, // IN:
+ MemTrackEntry *entryPtr) // IN:
+ {
+@@ -1453,11 +1458,11 @@ HostIF_FreeAllResources(VMDriver *vm) // IN
+ *
+ * HostIF_AllocKernelMem
+ *
+- * Allocate some kernel memory for the driver.
++ * Allocate some kernel memory for the driver.
+ *
+ * Results:
+- * The address allocated or NULL on error.
+- *
++ * The address allocated or NULL on error.
++ *
+ *
+ * Side effects:
+ * memory is malloced
+@@ -1469,8 +1474,8 @@ HostIF_AllocKernelMem(size_t size, // IN:
+ int wired) // IN:
+ {
+ void * ptr = kmalloc(size, GFP_KERNEL);
+-
+- if (ptr == NULL) {
++
++ if (ptr == NULL) {
+ Warning("%s failed (size=%p)\n", __func__, (void*)size);
+ }
+
+@@ -1498,7 +1503,7 @@ void *
+ HostIF_AllocPage(void)
+ {
+ VA kvAddr;
+-
++
+ kvAddr = __get_free_page(GFP_KERNEL);
+ if (kvAddr == 0) {
+ Warning("%s: __get_free_page() failed\n", __func__);
+@@ -1513,7 +1518,7 @@ HostIF_AllocPage(void)
+ *
+ * HostIF_FreeKernelMem
+ *
+- * Free kernel memory allocated for the driver.
++ * Free kernel memory allocated for the driver.
+ *
+ * Results:
+ * None.
+@@ -1552,7 +1557,7 @@ HostIF_FreePage(void *ptr) // IN:
+ * from the kernel without causing the host to die or to be really upset.
+ *
+ * Results:
+- * The maximum number of pages that can be locked.
++ * The maximum number of pages that can be locked.
+ *
+ * Side effects:
+ * none
+@@ -1580,9 +1585,9 @@ HostIF_EstimateLockedPageLimit(const VMDriver* vm, // IN
+ * Use the memory information linux exports as of late for a more
+ * precise estimate of locked memory. All kernel page-related structures
+ * (slab, pagetable) are as good as locked. Unevictable includes things
+- * that are explicitly marked as such (like mlock()). Huge pages are
+- * also as good as locked, since we don't use them. Lastly, without
+- * available swap, anonymous pages become locked in memory as well.
++ * that are explicitly marked as such (like mlock()). Huge pages are
++ * also as good as locked, since we don't use them. Lastly, without
++ * available swap, anonymous pages become locked in memory as well.
+ */
+
+ unsigned int forHost;
+@@ -1602,7 +1607,7 @@ HostIF_EstimateLockedPageLimit(const VMDriver* vm, // IN
+ unsigned int swapPages = BYTES_2_PAGES(linuxState.swapSize);
+
+ if (anonPages > swapPages) {
+- lockedPages += anonPages - swapPages;
++ lockedPages += anonPages - swapPages;
+ }
+ forHost = lockedPages + LOCKED_PAGE_SLACK;
+ if (forHost > totalPhysicalPages) {
+@@ -1647,7 +1652,7 @@ HostIF_Wait(unsigned int timeoutMs)
+ *----------------------------------------------------------------------
+ */
+
+-void
++void
+ HostIF_WaitForFreePages(unsigned int timeoutMs) // IN:
+ {
+ static unsigned count;
+@@ -1672,20 +1677,20 @@ HostIF_WaitForFreePages(unsigned int timeoutMs) // IN:
+ * timeofday to have small drift (due to NTP rate correction, etc).
+ * We handle this by rebasing the jiffies based monotonic clock
+ * every second (see HostIFUptimeResyncMono).
+- *
++ *
+ * Results:
+ * The uptime, in units of UPTIME_FREQ. Also returns the jiffies
+ * value that was used in the monotonic time calculation.
+ *
+ * Side effects:
+- * May reset the uptime base in the case gettimeofday warp was
++ * May reset the uptime base in the case gettimeofday warp was
+ * detected.
+ *
+ *----------------------------------------------------------------------
+ */
+
+ static uint64
+-HostIFReadUptimeWork(unsigned long *j) // OUT: current jiffies
++HostIFReadUptimeWork(unsigned long *j) // OUT: current jiffies
+ {
+ struct timeval tv;
+ uint64 monotime, uptime, upBase, monoBase;
+@@ -1707,14 +1712,14 @@ HostIFReadUptimeWork(unsigned long *j) // OUT: current jiffies
+
+ do_gettimeofday(&tv);
+ upBase = Atomic_Read64(&uptimeState.uptimeBase);
+-
++
+ monotime = (uint64)(jifs - jifBase) * (UPTIME_FREQ / HZ);
+ monotime += monoBase;
+
+ uptime = tv.tv_usec * (UPTIME_FREQ / 1000000) + tv.tv_sec * UPTIME_FREQ;
+ uptime += upBase;
+-
+- /*
++
++ /*
+ * Use the jiffies based monotonic time to sanity check gettimeofday.
+ * If they differ by more than one second, assume the time of day has
+ * been warped, and use the jiffies time to undo (most of) the warp.
+@@ -1726,7 +1731,7 @@ HostIFReadUptimeWork(unsigned long *j) // OUT: current jiffies
+ uint64 newUpBase = monotime - (uptime - upBase);
+
+ attempts++;
+- if (!Atomic_CMPXCHG64(&uptimeState.uptimeBase, &upBase, &newUpBase) &&
++ if (!Atomic_CMPXCHG64(&uptimeState.uptimeBase, &upBase, &newUpBase) &&
+ attempts < 5) {
+ /* Another thread updated uptimeBase. Recalculate uptime. */
+ goto retry;
+@@ -1767,7 +1772,7 @@ HostIFUptimeResyncMono(unsigned long data) // IN: ignored
+ unsigned long jifs;
+ uintptr_t flags;
+
+- /*
++ /*
+ * Read the uptime and the corresponding jiffies value. This will
+ * also correct the uptime (which is based on time of day) if needed
+ * before we rebase monotonic time (which is based on jiffies).
+@@ -1775,7 +1780,7 @@ HostIFUptimeResyncMono(unsigned long data) // IN: ignored
+
+ uint64 uptime = HostIFReadUptimeWork(&jifs);
+
+- /*
++ /*
+ * Every second, recalculate monoBase and jiffiesBase to squash small
+ * drift between gettimeofday and jiffies. Also, this prevents
+ * (jiffies - jiffiesBase) wrap on 32-bits.
+@@ -1820,8 +1825,8 @@ HostIF_InitUptime(void)
+
+ uptimeState.jiffiesBase = jiffies;
+ do_gettimeofday(&tv);
+- Atomic_Write64(&uptimeState.uptimeBase,
+- -(tv.tv_usec * (UPTIME_FREQ / 1000000) +
++ Atomic_Write64(&uptimeState.uptimeBase,
++ -(tv.tv_usec * (UPTIME_FREQ / 1000000) +
+ tv.tv_sec * UPTIME_FREQ));
+
+ init_timer(&uptimeState.timer);
+@@ -1949,7 +1954,7 @@ HostIF_CopyFromUser(void *dst, // OUT
+ *-----------------------------------------------------------------------------
+ */
+
+-int
++int
+ HostIF_CopyToUser(void *dst, // OUT
+ const void *src, // IN
+ unsigned int len) // IN
+@@ -1962,15 +1967,15 @@ HostIF_CopyToUser(void *dst, // OUT
+ *-----------------------------------------------------------------------------
+ *
+ * HostIF_MapCrossPage --
+- *
+- * Obtain kernel pointer to crosspage.
+ *
+- * We must return a VA that is obtained through a kernel mapping, so that
++ * Obtain kernel pointer to crosspage.
++ *
++ * We must return a VA that is obtained through a kernel mapping, so that
+ * the mapping never goes away (see bug 29753).
+ *
+- * However, the LA corresponding to that VA must not overlap with the
+- * monitor (see bug 32922). The userland code ensures that by only
+- * allocating cross pages from low memory. For those pages, the kernel
++ * However, the LA corresponding to that VA must not overlap with the
++ * monitor (see bug 32922). The userland code ensures that by only
++ * allocating cross pages from low memory. For those pages, the kernel
+ * uses a permanent mapping, instead of a temporary one with a high LA.
+ *
+ * Results:
+@@ -2158,7 +2163,7 @@ HostIF_VMLock(VMDriver *vm, // IN
+ * None
+ *
+ * Side effects:
+- * Can wake up the thread blocked on this lock.
++ * Can wake up the thread blocked on this lock.
+ *
+ *-----------------------------------------------------------------------------
+ */
+@@ -2181,7 +2186,7 @@ HostIF_VMUnlock(VMDriver *vm, // IN
+ * HostIF_VMLockIsHeld --
+ *
+ * Determine if the per-VM lock is held by the current thread.
+- *
++ *
+ * Results:
+ * TRUE if yes
+ * FALSE if no
+@@ -2237,14 +2242,14 @@ HostIF_VMLockIsHeld(VMDriver *vm) // IN
+ *
+ *----------------------------------------------------------------------
+ */
+-
++
+ static Bool
+ isVAReadable(VA r) // IN:
+ {
+ mm_segment_t old_fs;
+ uint32 dummy;
+ int ret;
+-
++
+ old_fs = get_fs();
+ set_fs(get_ds());
+ r = APICR_TO_ADDR(r, APICR_VERSION);
+@@ -2319,7 +2324,7 @@ ProbeAPIC(VMDriver *vm, // IN/OUT: driver state
+ Bool setVMPtr) // IN: set a pointer to the APIC's virtual address
+ {
+ MA ma = APIC_GetMA();
+-
++
+ if (ma == (MA)-1) {
+ return FALSE;
+ }
+@@ -2420,7 +2425,7 @@ HostIF_APICInit(VMDriver *vm, // IN:
+ * Perform the semaphore wait (P) operation, possibly blocking.
+ *
+ * Result:
+- * 1 (which equals MX_WAITNORMAL) if success,
++ * 1 (which equals MX_WAITNORMAL) if success,
+ * negated error code otherwise.
+ *
+ * Side-effects:
+@@ -2429,7 +2434,7 @@ HostIF_APICInit(VMDriver *vm, // IN:
+ *-----------------------------------------------------------------------------
+ */
+
+-int
++int
+ HostIF_SemaphoreWait(VMDriver *vm, // IN:
+ Vcpuid vcpuid, // IN:
+ uint64 *args) // IN:
+@@ -2452,7 +2457,7 @@ HostIF_SemaphoreWait(VMDriver *vm, // IN:
+ {
+ struct poll_wqueues table;
+ unsigned int mask;
+-
++
+ poll_initwait(&table);
+ current->state = TASK_INTERRUPTIBLE;
+ mask = file->f_op->poll(file, &table.pt);
+@@ -2527,7 +2532,7 @@ HostIF_SemaphoreWait(VMDriver *vm, // IN:
+ *-----------------------------------------------------------------------------
+ */
+
+-void
++void
+ HostIF_SemaphoreForceWakeup(VMDriver *vm, // IN:
+ const VCPUSet *vcs) // IN:
+ {
+@@ -2817,8 +2822,8 @@ HostIF_CallOnEachCPU(void (*func)(void*), // IN: function to call
+ *
+ * HostIF_ReadPage --
+ *
+- * puts the content of a machine page into a kernel or user mode
+- * buffer.
++ * puts the content of a machine page into a kernel or user mode
++ * buffer.
+ *
+ * Results:
+ * 0 on success
+@@ -2849,7 +2854,7 @@ HostIF_ReadPage(MPN mpn, // MPN of the page
+ if (ptr == NULL) {
+ return -ENOMEM;
+ }
+-
++
+ if (kernelBuffer) {
+ memcpy(buf, ptr, PAGE_SIZE);
+ } else {
+@@ -2866,7 +2871,7 @@ HostIF_ReadPage(MPN mpn, // MPN of the page
+ *
+ * HostIF_WritePage --
+ *
+- * Put the content of a kernel or user mode buffer into a machine
++ * Put the content of a kernel or user mode buffer into a machine
+ * page.
+ *
+ * Results:
+@@ -2996,7 +3001,7 @@ HostIF_GetNextAnonPage(VMDriver *vm, MPN inMPN)
+ * Side effects:
+ * None.
+ *
+- *----------------------------------------------------------------------
++ *----------------------------------------------------------------------
+ */
+
+ uint32
+@@ -3014,18 +3019,18 @@ HostIF_GetCurrentPCPU(void)
+ *
+ * Wake up the fast clock thread. Can't do this from the timer
+ * callback, because it holds locks that the scheduling code
+- * might take.
++ * might take.
+ *
+ * Results:
+ * None.
+- *
++ *
+ * Side effects:
+ * None.
+ *
+ *----------------------------------------------------------------------
+ */
+
+-static void
++static void
+ HostIFWakeupClockThread(unsigned long data) //IN:
+ {
+ wake_up_process(linuxState.fastClockThread);
+@@ -3036,7 +3041,7 @@ HostIFWakeupClockThread(unsigned long data) //IN:
+ *----------------------------------------------------------------------
+ *
+ * HostIFTimerCallback --
+- *
++ *
+ * Schedule a tasklet to wake up the fast clock thread.
+ *
+ * Results:
+@@ -3047,8 +3052,8 @@ HostIFWakeupClockThread(unsigned long data) //IN:
+ *
+ *----------------------------------------------------------------------
+ */
+-
+-static enum hrtimer_restart
++
++static enum hrtimer_restart
+ HostIFTimerCallback(struct hrtimer *timer) //IN:
+ {
+ tasklet_schedule(&timerTasklet);
+@@ -3061,7 +3066,7 @@ HostIFTimerCallback(struct hrtimer *timer) //IN:
+ *----------------------------------------------------------------------
+ *
+ * HostIFScheduleHRTimeout --
+- *
++ *
+ * Schedule an hrtimer to wake up the fast clock thread.
+ *
+ * Results:
+@@ -3073,7 +3078,7 @@ HostIFTimerCallback(struct hrtimer *timer) //IN:
+ *----------------------------------------------------------------------
+ */
+
+-static void
++static void
+ HostIFScheduleHRTimeout(ktime_t *expires) //IN:
+ {
+ struct hrtimer t;
+@@ -3091,7 +3096,7 @@ HostIFScheduleHRTimeout(ktime_t *expires) //IN:
+ if (hrtimer_active(&t)) {
+ schedule();
+ }
+-
++
+ hrtimer_cancel(&t);
+ __set_current_state(TASK_RUNNING);
+ }
+@@ -3114,7 +3119,7 @@ HostIFScheduleHRTimeout(ktime_t *expires) //IN:
+ * Side effects:
+ * none.
+ *
+- *----------------------------------------------------------------------
++ *----------------------------------------------------------------------
+ */
+
+ static long
+@@ -3147,7 +3152,7 @@ HostIFDoIoctl(struct file *filp,
+ */
+
+ int
+-HostIFStartTimer(Bool rateChanged, //IN: Did rate change?
++HostIFStartTimer(Bool rateChanged, //IN: Did rate change?
+ unsigned int rate, //IN: current clock rate
+ struct file *filp) //IN: /dev/rtc descriptor
+ {
+@@ -3157,14 +3162,14 @@ HostIFStartTimer(Bool rateChanged, //IN: Did rate change?
+ int timerPeriod;
+
+ if (rateChanged) {
+- timerPeriod = NSEC_PER_SEC / rate;
++ timerPeriod = NSEC_PER_SEC / rate;
+ expires = ktime_set(0, timerPeriod);
+ /*
+ * Allow the kernel to expire the timer at its convenience.
+ * ppoll() uses 0.1% of the timeout value. I think we can
+ * tolerate 1%.
+ */
+-
++
+ slack = timerPeriod / 100;
+ }
+ set_current_state(TASK_INTERRUPTIBLE);
+@@ -3510,7 +3515,7 @@ HostIF_MapUserMem(VA addr, // IN: User memory virtual address
+
+ printk(KERN_DEBUG "%s: p = 0x%p, offset = 0x%p, numPagesNeeded = %"FMTSZ"u,"
+ " handleSize = %"FMTSZ"u, mappedAddr = 0x%p\n",
+- __func__, p, (void *)offset, numPagesNeeded, handleSize, mappedAddr);
++ __func__, p, (void *)offset, numPagesNeeded, handleSize, mappedAddr);
+
+ newHandle->numPages = numPagesNeeded;
+ newHandle->addr = mappedAddr;
+@@ -3546,7 +3551,7 @@ HostIF_UnmapUserMem(VMMappedUserMem *handle) // IN: Handle to mapped memory
+ }
+
+ printk(KERN_DEBUG "%s: numPages = %"FMTSZ"u, addr = 0x%p\n",
+- __func__, handle->numPages, handle->addr);
++ __func__, handle->numPages, handle->addr);
+
+ if (handle->numPages > 1) {
+ vunmap(handle->addr);
diff --git a/vmmon/linux/vmmonInt.h b/vmmon/linux/vmmonInt.h
index 4dc04e9..993212d 100644
--- a/vmmon/linux/vmmonInt.h
diff --git a/vmnet.patch b/vmnet.patch
index 910cbc07c8f8..018f7c5e0277 100644
--- a/vmnet.patch
+++ b/vmnet.patch
@@ -1,3 +1,541 @@
+diff --git a/vmnet/Makefile b/vmnet/Makefile
+index 459846e..cd29652 100644
+--- a/vmnet/Makefile
++++ b/vmnet/Makefile
+@@ -43,7 +43,11 @@ INCLUDE += -I$(SRCROOT)/shared
+ endif
+
+
++ifdef KVERSION
++VM_UNAME = $(KVERSION)
++else
+ VM_UNAME = $(shell uname -r)
++endif
+
+ # Header directory for the running kernel
+ ifdef LINUXINCLUDE
+diff --git a/vmnet/Makefile.kernel b/vmnet/Makefile.kernel
+index 2d8e6f6..a14166b 100644
+--- a/vmnet/Makefile.kernel
++++ b/vmnet/Makefile.kernel
+@@ -19,7 +19,7 @@
+
+ INCLUDE := -I$(SRCROOT)
+
+-EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE)
++EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) $(LINUXINCLUDE)
+ EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/netdev_has_net.c,-DVMW_NETDEV_HAS_NET, )
+ EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/netdev_has_dev_net.c,-DVMW_NETDEV_HAS_DEV_NET, )
+ EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/nfhook_uses_skb.c,-DVMW_NFHOOK_USES_SKB, )
+diff --git a/vmnet/driver.c b/vmnet/driver.c
+index 7e7ad99..5f508f6 100644
+--- a/vmnet/driver.c
++++ b/vmnet/driver.c
+@@ -137,7 +137,16 @@ static ssize_t VNetFileOpWrite(struct file *filp, const char *buf, size_t count
+ static long VNetFileOpUnlockedIoctl(struct file * filp,
+ unsigned int iocmd, unsigned long ioarg);
+
+-static struct file_operations vnetFileOps;
++static struct file_operations vnetFileOps = {
++ .owner = THIS_MODULE,
++ .read = VNetFileOpRead,
++ .write = VNetFileOpWrite,
++ .poll = VNetFileOpPoll,
++ .unlocked_ioctl = VNetFileOpUnlockedIoctl,
++ .compat_ioctl = VNetFileOpUnlockedIoctl,
++ .open = VNetFileOpOpen,
++ .release = VNetFileOpClose
++};
+
+ /*
+ * Utility functions
+@@ -317,22 +326,6 @@ init_module(void)
+ goto err_proto;
+ }
+
+- /*
+- * Initialize the file_operations structure. Because this code is always
+- * compiled as a module, this is fine to do it here and not in a static
+- * initializer.
+- */
+-
+- memset(&vnetFileOps, 0, sizeof vnetFileOps);
+- vnetFileOps.owner = THIS_MODULE;
+- vnetFileOps.read = VNetFileOpRead;
+- vnetFileOps.write = VNetFileOpWrite;
+- vnetFileOps.poll = VNetFileOpPoll;
+- vnetFileOps.unlocked_ioctl = VNetFileOpUnlockedIoctl;
+- vnetFileOps.compat_ioctl = VNetFileOpUnlockedIoctl;
+- vnetFileOps.open = VNetFileOpOpen;
+- vnetFileOps.release = VNetFileOpClose;
+-
+ retval = register_chrdev(VNET_MAJOR_NUMBER, "vmnet", &vnetFileOps);
+ if (retval) {
+ LOG(0, (KERN_NOTICE "/dev/vmnet: could not register major device %d\n",
+@@ -1145,12 +1138,12 @@ VNetMulticastFilter(const uint8 *destAddr, // IN: multicast MAC
+ }
+ /*
+ * Do not need to further compute and check ladrf if no match
+- * in exact multicast filter, since only one of them is
++ * in exact multicast filter, since only one of them is
+ * used at a time.
+ */
+ return FALSE;
+ }
+-
++
+
+ crc = 0xffffffff; /* init CRC for each address */
+ for (byte = 0; byte < ETH_ALEN; byte++) { /* for each address byte */
+diff --git a/vmnet/userif.c b/vmnet/userif.c
+index 2b976d7..8c3f685 100644
+--- a/vmnet/userif.c
++++ b/vmnet/userif.c
+@@ -113,12 +113,12 @@ UserifLockPage(VA addr) // IN
+ int retval;
+
+ down_read(&current->mm->mmap_sem);
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
+- retval = get_user_pages(addr, 1, 1, 0, &page, NULL);
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 5, 99)
++ retval = get_user_pages(addr,
+ #else
+ retval = get_user_pages(current, current->mm, addr,
+- 1, 1, 0, &page, NULL);
+ #endif
++ 1, 1, 0, &page, NULL);
+ up_read(&current->mm->mmap_sem);
+
+ if (retval != 1) {
+@@ -182,13 +182,13 @@ VNetUserIfMapUint32Ptr(VA uAddr, // IN: pointer to user memory
+ *
+ * Sets up notification by filling in pollPtr, actPtr, and recvClusterCount
+ * fields.
+- *
+- * Results:
++ *
++ * Results:
+ * 0 on success
+ * < 0 on failure: the actual value determines the type of failure
+ *
+ * Side effects:
+- * Fields pollPtr, actPtr, recvClusterCount, pollPage, actPage, and
++ * Fields pollPtr, actPtr, recvClusterCount, pollPage, actPage, and
+ * recvClusterPage are filled in VNetUserIf structure.
+ *
+ *-----------------------------------------------------------------------------
+@@ -278,8 +278,8 @@ VNetUserIfSetupNotify(VNetUserIF *userIf, // IN
+ * VNetUserIfUnsetupNotify --
+ *
+ * Destroys permanent mapping for notify structure provided by user.
+- *
+- * Results:
++ *
++ * Results:
+ * None.
+ *
+ * Side effects:
+@@ -333,7 +333,7 @@ VNetUserIfUnsetupNotify(VNetUserIF *userIf) // IN
+ *
+ * Free the user interface port.
+ *
+- * Results:
++ * Results:
+ * None.
+ *
+ * Side effects:
+@@ -355,7 +355,7 @@ VNetUserIfFree(VNetJack *this) // IN
+ }
+ dev_kfree_skb(skb);
+ }
+-
++
+ if (userIf->pollPtr) {
+ VNetUserIfUnsetupNotify(userIf);
+ }
+@@ -379,7 +379,7 @@ VNetUserIfFree(VNetJack *this) // IN
+ *
+ * This jack is receiving a packet. Take appropriate action.
+ *
+- * Results:
++ * Results:
+ * None.
+ *
+ * Side effects:
+@@ -395,12 +395,12 @@ VNetUserIfReceive(VNetJack *this, // IN
+ VNetUserIF *userIf = (VNetUserIF*)this->private;
+ uint8 *dest = SKB_2_DESTMAC(skb);
+ unsigned long flags;
+-
++
+ if (!UP_AND_RUNNING(userIf->port.flags)) {
+ userIf->stats.droppedDown++;
+ goto drop_packet;
+ }
+-
++
+ if (!VNetPacketMatch(dest,
+ userIf->port.paddr,
+ (const uint8 *)userIf->port.exactFilter,
+@@ -410,12 +410,12 @@ VNetUserIfReceive(VNetJack *this, // IN
+ userIf->stats.droppedMismatch++;
+ goto drop_packet;
+ }
+-
++
+ if (skb_queue_len(&userIf->packetQueue) >= vnet_max_qlen) {
+ userIf->stats.droppedOverflow++;
+ goto drop_packet;
+ }
+-
++
+ if (skb->len > ETHER_MAX_QUEUED_PACKET) {
+ userIf->stats.droppedLargePacket++;
+ goto drop_packet;
+@@ -439,7 +439,7 @@ VNetUserIfReceive(VNetJack *this, // IN
+
+ wake_up(&userIf->waitQueue);
+ return;
+-
++
+ drop_packet:
+ dev_kfree_skb(skb);
+ }
+@@ -452,7 +452,7 @@ VNetUserIfReceive(VNetJack *this, // IN
+ *
+ * Callback for read operation on this userif entry in vnets proc fs.
+ *
+- * Results:
++ * Results:
+ * Length of read operation.
+ *
+ * Side effects:
+@@ -471,21 +471,21 @@ VNetUserIfProcRead(char *page, // IN/OUT: buffer to write into
+ // read
+ void *data) // IN: client data - not used
+ {
+- VNetUserIF *userIf = (VNetUserIF*)data;
++ VNetUserIF *userIf = (VNetUserIF*)data;
+ int len = 0;
+-
++
+ if (!userIf) {
+ return len;
+ }
+-
++
+ len += VNetPrintPort(&userIf->port, page+len);
+-
++
+ len += sprintf(page+len, "read %u written %u queued %u ",
+ userIf->stats.read,
+ userIf->stats.written,
+ userIf->stats.queued);
+-
+- len += sprintf(page+len,
++
++ len += sprintf(page+len,
+ "dropped.down %u dropped.mismatch %u "
+ "dropped.overflow %u dropped.largePacket %u",
+ userIf->stats.droppedDown,
+@@ -494,7 +494,7 @@ VNetUserIfProcRead(char *page, // IN/OUT: buffer to write into
+ userIf->stats.droppedLargePacket);
+
+ len += sprintf(page+len, "\n");
+-
++
+ *start = 0;
+ *eof = 1;
+ return len;
+@@ -508,7 +508,7 @@ VNetUserIfProcRead(char *page, // IN/OUT: buffer to write into
+ *
+ * Copy part of datagram to userspace.
+ *
+- * Results:
++ * Results:
+ * zero on success,
+ * -EFAULT if buffer is an invalid area
+ *
+@@ -545,12 +545,12 @@ VNetCopyDatagram(const struct sk_buff *skb, // IN: skb to copy
+ *
+ * Copy part of datagram to userspace doing checksum at same time.
+ *
+- * Do not mark this function INLINE, it is recursive! With all gcc's
++ * Do not mark this function INLINE, it is recursive! With all gcc's
+ * released up to now (<= gcc-3.3.1) inlining this function just
+ * consumes 120 more bytes of code and goes completely mad on
+ * register allocation, storing almost everything in the memory.
+ *
+- * Results:
++ * Results:
+ * folded checksum (non-negative value) on success,
+ * -EINVAL if offset is too big,
+ * -EFAULT if buffer is an invalid area
+@@ -572,7 +572,7 @@ VNetCsumCopyDatagram(const struct sk_buff *skb, // IN: skb to copy
+ char *curr = buf;
+ const skb_frag_t *frag;
+
+- /*
++ /*
+ * Something bad happened. We skip only up to skb->nh.raw, and skb->nh.raw
+ * must be in the header, otherwise we are in the big troubles.
+ */
+@@ -629,7 +629,7 @@ VNetCsumCopyDatagram(const struct sk_buff *skb, // IN: skb to copy
+ * Copy complete datagram to the user space. Fill correct checksum
+ * into the copied datagram if nobody did it yet.
+ *
+- * Results:
++ * Results:
+ * On success byte count, on failure -EFAULT.
+ *
+ * Side effects:
+@@ -658,7 +658,7 @@ VNetCopyDatagramToUser(const struct sk_buff *skb, // IN
+ size_t skl;
+ int csum;
+ u_int16_t csum16;
+-
++
+ skl = compat_skb_csum_start(skb);
+ if (VNetCopyDatagram(skb, buf, skl)) {
+ return -EFAULT;
+@@ -689,7 +689,7 @@ VNetCopyDatagramToUser(const struct sk_buff *skb, // IN
+ * The virtual network's read file operation. Reads the next pending
+ * packet for this network connection.
+ *
+- * Results:
++ * Results:
+ * On success the len of the packet received,
+ * else if no packet waiting and nonblocking 0,
+ * else -errno.
+@@ -700,7 +700,7 @@ VNetCopyDatagramToUser(const struct sk_buff *skb, // IN
+ *----------------------------------------------------------------------
+ */
+
+-static int
++static int
+ VNetUserIfRead(VNetPort *port, // IN
+ struct file *filp, // IN
+ char *buf, // OUT
+@@ -768,7 +768,7 @@ VNetUserIfRead(VNetPort *port, // IN
+ * The virtual network's write file operation. Send the raw packet
+ * to the network.
+ *
+- * Results:
++ * Results:
+ * On success the count of bytes written else errno.
+ *
+ * Side effects:
+@@ -777,7 +777,7 @@ VNetUserIfRead(VNetPort *port, // IN
+ *----------------------------------------------------------------------
+ */
+
+-static int
++static int
+ VNetUserIfWrite(VNetPort *port, // IN
+ struct file *filp, // IN
+ const char *buf, // IN
+@@ -789,8 +789,8 @@ VNetUserIfWrite(VNetPort *port, // IN
+ /*
+ * Check size
+ */
+-
+- if (count < sizeof (struct ethhdr) ||
++
++ if (count < sizeof (struct ethhdr) ||
+ count > ETHER_MAX_QUEUED_PACKET) {
+ return -EINVAL;
+ }
+@@ -807,25 +807,25 @@ VNetUserIfWrite(VNetPort *port, // IN
+ /*
+ * Allocate an sk_buff.
+ */
+-
++
+ skb = dev_alloc_skb(count + 7);
+ if (skb == NULL) {
+ // XXX obey O_NONBLOCK?
+ return -ENOBUFS;
+ }
+-
++
+ skb_reserve(skb, 2);
+-
++
+ /*
+ * Copy the data and send it.
+ */
+-
++
+ userIf->stats.written++;
+ if (copy_from_user(skb_put(skb, count), buf, count)) {
+ dev_kfree_skb(skb);
+ return -EFAULT;
+ }
+-
++
+ VNetSend(&userIf->port.jack, skb);
+
+ return count;
+@@ -839,7 +839,7 @@ VNetUserIfWrite(VNetPort *port, // IN
+ *
+ * XXX
+ *
+- * Results:
++ * Results:
+ * 0 on success
+ * -errno on failure
+ *
+@@ -862,8 +862,8 @@ VNetUserIfIoctl(VNetPort *port, // IN
+ return -EINVAL;
+ case SIOCSETNOTIFY2:
+ #ifdef VMX86_SERVER
+- /*
+- * This ioctl always return failure on ESX since we cannot map pages into
++ /*
++ * This ioctl always return failure on ESX since we cannot map pages into
+ * the console os that are from the VMKernel address space which was the
+ * only case we used this.
+ */
+@@ -906,20 +906,20 @@ VNetUserIfIoctl(VNetPort *port, // IN
+ break;
+
+ case SIOCSIFFLAGS:
+- /*
+- * Drain queue when interface is no longer active. We drain the queue to
++ /*
++ * Drain queue when interface is no longer active. We drain the queue to
+ * avoid having old packets delivered to the guest when reneabled.
+ */
+-
++
+ if (!UP_AND_RUNNING(userIf->port.flags)) {
+ struct sk_buff *skb;
+ unsigned long flags;
+ struct sk_buff_head *q = &userIf->packetQueue;
+-
++
+ while ((skb = skb_dequeue(q)) != NULL) {
+ dev_kfree_skb(skb);
+ }
+-
++
+ spin_lock_irqsave(&q->lock, flags);
+ if (userIf->pollPtr) {
+ if (skb_queue_empty(q)) {
+@@ -936,11 +936,11 @@ VNetUserIfIoctl(VNetPort *port, // IN
+ case SIOCINJECTLINKSTATE:
+ {
+ uint8 linkUpFromUser;
+- if (copy_from_user(&linkUpFromUser, (void *)ioarg,
++ if (copy_from_user(&linkUpFromUser, (void *)ioarg,
+ sizeof linkUpFromUser)) {
+ return -EFAULT;
+ }
+-
++
+ if (linkUpFromUser != 0 && linkUpFromUser != 1) {
+ return -EINVAL;
+ }
+@@ -952,7 +952,7 @@ VNetUserIfIoctl(VNetPort *port, // IN
+ return -ENOIOCTLCMD;
+ break;
+ }
+-
++
+ return 0;
+ }
+
+@@ -964,7 +964,7 @@ VNetUserIfIoctl(VNetPort *port, // IN
+ *
+ * The virtual network's file poll operation.
+ *
+- * Results:
++ * Results:
+ * Return POLLIN if success, else sleep and return 0.
+ * FIXME: Should not we always return POLLOUT?
+ *
+@@ -980,7 +980,7 @@ VNetUserIfPoll(VNetPort *port, // IN
+ poll_table *wait) // IN
+ {
+ VNetUserIF *userIf = (VNetUserIF*)port->jack.private;
+-
++
+ poll_wait(filp, &userIf->waitQueue, wait);
+ if (!skb_queue_empty(&userIf->packetQueue)) {
+ return POLLIN;
+@@ -995,8 +995,8 @@ VNetUserIfPoll(VNetPort *port, // IN
+ * VNetUserIfSetUplinkState --
+ *
+ * Sends link state change event.
+- *
+- * Results:
++ *
++ * Results:
+ * 0 on success, errno on failure.
+ *
+ * Side effects:
+@@ -1038,7 +1038,7 @@ VNetUserIfSetUplinkState(VNetPort *port, uint8 linkUp)
+ event.header.eventId = 0;
+ event.header.classSet = VNET_EVENT_CLASS_UPLINK;
+ event.header.type = VNET_EVENT_TYPE_LINK_STATE;
+- /*
++ /*
+ * XXX kind of a hack, vmx will coalesce linkup/down if they come from the
+ * same adapter.
+ */
+@@ -1063,8 +1063,8 @@ VNetUserIfSetUplinkState(VNetPort *port, uint8 linkUp)
+ *
+ * Create a user level port to the wonderful world of virtual
+ * networking.
+- *
+- * Results:
++ *
++ * Results:
+ * Errno. Also returns an allocated port to connect to,
+ * NULL on error.
+ *
+@@ -1080,7 +1080,7 @@ VNetUserIf_Create(VNetPort **ret) // OUT
+ VNetUserIF *userIf;
+ static unsigned id = 0;
+ int retval;
+-
++
+ userIf = kmalloc(sizeof *userIf, GFP_USER);
+ if (!userIf) {
+ return -ENOMEM;
+@@ -1089,7 +1089,7 @@ VNetUserIf_Create(VNetPort **ret) // OUT
+ /*
+ * Initialize fields.
+ */
+-
++
+ userIf->port.id = id++;
+
+ userIf->port.jack.peer = NULL;
+@@ -1134,7 +1134,7 @@ VNetUserIf_Create(VNetPort **ret) // OUT
+ /*
+ * Rest of fields.
+ */
+-
++
+ userIf->port.flags = IFF_RUNNING;
+
+ memset(userIf->port.paddr, 0, sizeof userIf->port.paddr);
+@@ -1147,12 +1147,12 @@ VNetUserIf_Create(VNetPort **ret) // OUT
+ userIf->port.fileOpWrite = VNetUserIfWrite;
+ userIf->port.fileOpIoctl = VNetUserIfIoctl;
+ userIf->port.fileOpPoll = VNetUserIfPoll;
+-
++
+ skb_queue_head_init(&(userIf->packetQueue));
+ init_waitqueue_head(&userIf->waitQueue);
+
+ memset(&userIf->stats, 0, sizeof userIf->stats);
+-
++
+ *ret = &userIf->port;
+ return 0;
+ }
diff --git a/vmnet/vm_device_version.h b/vmnet/vm_device_version.h
index e2cb477..3dd7097 100644
--- a/vmnet/vm_device_version.h
@@ -13,12 +551,15 @@ index e2cb477..3dd7097 100644
#define PCI_DEVICE_ID_VMWARE_SVGA 0x0710
#define PCI_DEVICE_ID_VMWARE_VGA 0x0711
diff --git a/vmnet/vmnetInt.h b/vmnet/vmnetInt.h
-index 0ee52ec..96060a3 100644
+index 0ee52ec..4e3b923 100644
--- a/vmnet/vmnetInt.h
+++ b/vmnet/vmnetInt.h
-@@ -79,7 +79,7 @@
+@@ -77,9 +77,9 @@
+
+
extern struct proto vmnet_proto;
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
+-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 99)
# define compat_sk_alloc(_bri, _pri) sk_alloc(&init_net, \
- PF_NETLINK, _pri, &vmnet_proto, 1)
+ PF_NETLINK, _pri, &vmnet_proto, 0)
diff --git a/vsock.patch b/vsock.patch
index cf806c731c7b..9617ff200bdd 100644
--- a/vsock.patch
+++ b/vsock.patch
@@ -1,40 +1,68 @@
+diff --git a/vsock/Makefile b/vsock/Makefile
+index 5d92e9b..7d315e8 100644
+--- a/vsock/Makefile
++++ b/vsock/Makefile
+@@ -42,8 +42,11 @@ AUTOCONF_DIR := $(SRCROOT)/shared/autoconf
+ INCLUDE += -I$(SRCROOT)/shared
+ endif
+
+-
++ifdef KVERSION
++VM_UNAME = $(KVERSION)
++else
+ VM_UNAME = $(shell uname -r)
++endif
+
+ # Header directory for the running kernel
+ ifdef LINUXINCLUDE
+diff --git a/vsock/Makefile.kernel b/vsock/Makefile.kernel
+index 5218df2..374cc1f 100644
+--- a/vsock/Makefile.kernel
++++ b/vsock/Makefile.kernel
+@@ -25,7 +25,7 @@ INCLUDE += -I$(SRCROOT)/include
+ INCLUDE += -I$(SRCROOT)/linux
+ INCLUDE += -I$(SRCROOT)/common
+
+-EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE)
++EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) $(LINUXINCLUDE)
+ EXTRA_CFLAGS += $(call vm_check_build, $(AUTOCONF_DIR)/netcreate_num_params.c, -DVMW_NETCREATE_KERNARG, )
+
+
diff --git a/vsock/linux/af_vsock.c b/vsock/linux/af_vsock.c
-index bde1497..40b7927 100644
+index bde1497..9f8f843 100644
--- a/vsock/linux/af_vsock.c
+++ b/vsock/linux/af_vsock.c
-@@ -232,13 +232,27 @@ static int VSockVmciStreamSetsockopt(struct socket *sock, int level, int optname
+@@ -232,13 +232,29 @@ static int VSockVmciStreamSetsockopt(struct socket *sock, int level, int optname
static int VSockVmciStreamGetsockopt(struct socket *sock, int level, int optname,
char __user *optval, int __user * optlen);
--static int VSockVmciDgramSendmsg(struct kiocb *kiocb,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 99)
+ static int VSockVmciDgramSendmsg(struct kiocb *kiocb,
++#else
+static int VSockVmciDgramSendmsg(
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
-+ struct kiocb *kiocb,
+#endif
struct socket *sock, struct msghdr *msg, size_t len);
--static int VSockVmciDgramRecvmsg(struct kiocb *kiocb, struct socket *sock,
-+static int VSockVmciDgramRecvmsg(
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
-+ struct kiocb *kiocb,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 99)
+ static int VSockVmciDgramRecvmsg(struct kiocb *kiocb, struct socket *sock,
++#else
++static int VSockVmciDgramRecvmsg(struct socket *sock,
+#endif
-+ struct socket *sock,
struct msghdr *msg, size_t len, int flags);
--static int VSockVmciStreamSendmsg(struct kiocb *kiocb,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 99)
+ static int VSockVmciStreamSendmsg(struct kiocb *kiocb,
++#else
+static int VSockVmciStreamSendmsg(
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
-+ struct kiocb *kiocb,
+#endif
struct socket *sock, struct msghdr *msg, size_t len);
--static int VSockVmciStreamRecvmsg(struct kiocb *kiocb, struct socket *sock,
-+static int VSockVmciStreamRecvmsg(
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
-+ struct kiocb *kiocb,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 99)
+ static int VSockVmciStreamRecvmsg(struct kiocb *kiocb, struct socket *sock,
++#else
++static int VSockVmciStreamRecvmsg(struct socket *sock,
+#endif
-+ struct socket *sock,
struct msghdr *msg, size_t len, int flags);
static int VSockVmciCreate(
-@@ -2822,11 +2836,18 @@ __VSockVmciCreate(struct net *net, // IN: Network namespace
+@@ -2822,11 +2838,18 @@ __VSockVmciCreate(struct net *net, // IN: Network namespace
* From 2.6.9 to until 2.6.12 sk_alloc() used a cache in
* the protocol structure, but you still had to specify the size and cache
* yourself.
@@ -49,25 +77,25 @@ index bde1497..40b7927 100644
+ * we have switched to passing 0.
*/
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12)
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 2, 0)
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 1, 99)
+ sk = sk_alloc(net, vsockVmciFamilyOps.family, priority, &vsockVmciProto, 0);
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 12)
sk = sk_alloc(vsockVmciFamilyOps.family, priority,
vsockVmciProto.slab_obj_size, vsockVmciProto.slab);
#elif LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24)
-@@ -4210,7 +4231,10 @@ VSockVmciShutdown(struct socket *sock, // IN
+@@ -4210,7 +4233,11 @@ VSockVmciShutdown(struct socket *sock, // IN
*/
static int
--VSockVmciDgramSendmsg(struct kiocb *kiocb, // UNUSED
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 99)
+ VSockVmciDgramSendmsg(struct kiocb *kiocb, // UNUSED
++#else
+VSockVmciDgramSendmsg(
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
-+ struct kiocb *kiocb, // UNUSED
+#endif
struct socket *sock, // IN: socket to send on
struct msghdr *msg, // IN: message to send
size_t len) // IN: length of message
-@@ -4302,7 +4326,11 @@ VSockVmciDgramSendmsg(struct kiocb *kiocb, // UNUSED
+@@ -4302,7 +4329,11 @@ VSockVmciDgramSendmsg(struct kiocb *kiocb, // UNUSED
goto out;
}
@@ -79,19 +107,19 @@ index bde1497..40b7927 100644
dg->dst = VMCI_MAKE_HANDLE(remoteAddr->svm_cid, remoteAddr->svm_port);
dg->src = VMCI_MAKE_HANDLE(vsk->localAddr.svm_cid, vsk->localAddr.svm_port);
-@@ -4540,7 +4568,10 @@ VSockVmciStreamGetsockopt(struct socket *sock, // IN
+@@ -4540,7 +4571,11 @@ VSockVmciStreamGetsockopt(struct socket *sock, // IN
*/
static int
--VSockVmciStreamSendmsg(struct kiocb *kiocb, // UNUSED
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 99)
+ VSockVmciStreamSendmsg(struct kiocb *kiocb, // UNUSED
++#else
+VSockVmciStreamSendmsg(
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
-+ struct kiocb *kiocb, // UNUSED
+#endif
struct socket *sock, // IN: socket to send on
struct msghdr *msg, // IN: message to send
size_t len) // IN: length of message
-@@ -4662,7 +4693,11 @@ VSockVmciStreamSendmsg(struct kiocb *kiocb, // UNUSED
+@@ -4662,7 +4697,11 @@ VSockVmciStreamSendmsg(struct kiocb *kiocb, // UNUSED
* able to send.
*/
@@ -103,19 +131,19 @@ index bde1497..40b7927 100644
len - totalWritten, 0);
if (written < 0) {
err = -ENOMEM;
-@@ -4709,7 +4744,10 @@ out:
+@@ -4709,7 +4748,11 @@ out:
*/
static int
--VSockVmciDgramRecvmsg(struct kiocb *kiocb, // UNUSED
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 99)
+ VSockVmciDgramRecvmsg(struct kiocb *kiocb, // UNUSED
++#else
+VSockVmciDgramRecvmsg(
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
-+ struct kiocb *kiocb, // UNUSED
+#endif
struct socket *sock, // IN: socket to receive from
struct msghdr *msg, // IN/OUT: message to receive into
size_t len, // IN: length of receive buffer
-@@ -4759,7 +4797,11 @@ VSockVmciDgramRecvmsg(struct kiocb *kiocb, // UNUSED
+@@ -4759,7 +4802,11 @@ VSockVmciDgramRecvmsg(struct kiocb *kiocb, // UNUSED
}
/* Place the datagram payload in the user's iovec. */
@@ -127,19 +155,19 @@ index bde1497..40b7927 100644
if (err) {
goto out;
}
-@@ -4800,7 +4842,10 @@ out:
+@@ -4800,7 +4847,11 @@ out:
*/
static int
--VSockVmciStreamRecvmsg(struct kiocb *kiocb, // UNUSED
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 99)
+ VSockVmciStreamRecvmsg(struct kiocb *kiocb, // UNUSED
++#else
+VSockVmciStreamRecvmsg(
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 1, 0)
-+ struct kiocb *kiocb, // UNUSED
+#endif
struct socket *sock, // IN: socket to receive from
struct msghdr *msg, // IN/OUT: message to receive into
size_t len, // IN: length of receive buffer
-@@ -4905,9 +4950,17 @@ VSockVmciStreamRecvmsg(struct kiocb *kiocb, // UNUSED
+@@ -4905,9 +4956,17 @@ VSockVmciStreamRecvmsg(struct kiocb *kiocb, // UNUSED
}
if (flags & MSG_PEEK) {