Skip to content

Instantly share code, notes, and snippets.

@stuartgillibrand
Last active April 6, 2020 23:37
Show Gist options
  • Save stuartgillibrand/db4493c5f8e65e35da89d0b87b2e90af to your computer and use it in GitHub Desktop.
Save stuartgillibrand/db4493c5f8e65e35da89d0b87b2e90af to your computer and use it in GitHub Desktop.
VMware workstation (14) vmci (vmci-only) driver.c patch for kernel 5 (specifically 5.0.0-1035-azure which doesn't have VMCI compiled in by default)
nf@dev2:/usr/lib/vmware/modules/source/vmci-only/linux$ diff -u driver.c.bak driver.c
--- driver.c.bak 2020-04-04 11:06:09.785080943 +0000
+++ driver.c 2020-04-04 12:09:20.104265869 +0000
@@ -1437,7 +1437,11 @@
VMCIUserVAInvalidPointer(VA uva, // IN:
size_t size) // IN:
{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
return !access_ok(VERIFY_WRITE, (void *)uva, size);
+#else
+ return !access_ok(/*VERIFY_WRITE,*/ (void *)uva, size);
+#endif
}
@@ -1466,7 +1470,9 @@
int retval;
down_read(&current->mm->mmap_sem);
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
+ retval = get_user_pages(addr, 1, 0, &page, NULL);
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
retval = get_user_pages(addr, 1, 1, 0, &page, NULL);
#else
retval = get_user_pages(current, current->mm, addr,
@@ -1722,11 +1728,19 @@
vmci_dev.msix_entries[i].vector = i;
}
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
result = pci_enable_msix(pdev, vmci_dev.msix_entries, VMCI_MAX_INTRS);
+#else
+ result = pci_enable_msix_range(pdev, vmci_dev.msix_entries, VMCI_MAX_INTRS, VMCI_MAX_INTRS);
+#endif
if (!result) {
vmci_dev.exclusive_vectors = TRUE;
} else if (result > 0) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)
result = pci_enable_msix(pdev, vmci_dev.msix_entries, 1);
+#else
+ result = pci_enable_msix_range(pdev, vmci_dev.msix_entries, 1, 1);
+#endif
}
return result;
}
@@ -2490,12 +2504,17 @@
VMCI_HostCleanup();
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 5)
retval = 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);
+ Log(LGPFX"Module %s: unloaded\n", VMCI_MODULE_NAME);
+#endif
hostDeviceInit = FALSE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment