Last active
April 6, 2020 23:36
-
-
Save stuartgillibrand/fdadafdf868528636f8d3e805455bbe2 to your computer and use it in GitHub Desktop.
VMware workstation (14) vmci (vmci-only) vmciKernelIf.c patch for kernel 5 (specifically 5.0.0-1035-azure which doesn't have VMCI compiled in by default)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- vmciKernelIf.c.bak 2020-04-04 11:26:35.338057419 +0000 | |
| +++ vmciKernelIf.c 2020-04-04 12:10:54.851830116 +0000 | |
| @@ -40,6 +40,8 @@ | |
| #include <linux/socket.h> /* For memcpy_{to,from}iovec(). */ | |
| #include <linux/vmalloc.h> | |
| #include <linux/wait.h> | |
| +#include <linux/sched/signal.h> | |
| +#include <linux/skbuff.h> | |
| #include "compat_highmem.h" | |
| #include "compat_interrupt.h" | |
| @@ -1198,11 +1200,19 @@ | |
| } | |
| if (isIovec) { | |
| +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) | |
| struct iovec *iov = (struct iovec *)src; | |
| +#else | |
| + struct msghdr *msg = src; | |
| +#endif | |
| int err; | |
| /* The iovec will track bytesCopied internally. */ | |
| +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) | |
| err = memcpy_fromiovec((uint8 *)va + pageOffset, iov, toCopy); | |
| +#else | |
| + err = memcpy_from_msg((uint8 *)va + pageOffset, msg, toCopy); | |
| +#endif | |
| if (err != 0) { | |
| if (kernelIf->host) { | |
| kunmap(kernelIf->u.h.page[pageIndex]); | |
| @@ -1273,11 +1283,19 @@ | |
| } | |
| if (isIovec) { | |
| +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) | |
| struct iovec *iov = (struct iovec *)dest; | |
| +#else | |
| + struct msghdr *msg = dest; | |
| +#endif | |
| int err; | |
| /* The iovec will track bytesCopied internally. */ | |
| +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0) | |
| err = memcpy_toiovec(iov, (uint8 *)va + pageOffset, toCopy); | |
| +#else | |
| + err = memcpy_to_msg(msg, (uint8 *)va + pageOffset, toCopy); | |
| +#endif | |
| if (err != 0) { | |
| if (kernelIf->host) { | |
| kunmap(kernelIf->u.h.page[pageIndex]); | |
| @@ -1834,7 +1852,11 @@ | |
| if (dirty) { | |
| set_page_dirty(pages[i]); | |
| } | |
| +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) | |
| page_cache_release(pages[i]); | |
| +#else | |
| + put_page(pages[i]); | |
| +#endif | |
| pages[i] = NULL; | |
| } | |
| } | |
| @@ -2048,7 +2070,13 @@ | |
| int err = VMCI_SUCCESS; | |
| down_write(¤t->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((VA)produceUVA, | |
| + 1, | |
| + 0, | |
| + produceQ->kernelIf->u.h.headerPage, | |
| + NULL); | |
| +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0) | |
| retval = get_user_pages((VA)produceUVA, | |
| produceQ->kernelIf->numPages, | |
| 1, 0, | |
| @@ -2070,6 +2098,16 @@ | |
| goto out; | |
| } | |
| +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0) | |
| + retval = get_user_pages_remote(current, | |
| + current->mm, | |
| + (VA)consumeUVA, | |
| + consumeQ->kernelIf->numPages, | |
| + 0, | |
| + consumeQ->kernelIf->u.h.headerPage, | |
| + NULL, | |
| + NULL); | |
| +#else | |
| retval = get_user_pages(current, | |
| current->mm, | |
| (VA)consumeUVA, | |
| @@ -2077,6 +2115,7 @@ | |
| 1, 0, | |
| consumeQ->kernelIf->u.h.headerPage, | |
| NULL); | |
| +#endif | |
| if (retval < consumeQ->kernelIf->numPages) { | |
| Log("get_user_pages(consume) failed (retval=%d)\n", retval); | |
| VMCIReleasePages(consumeQ->kernelIf->u.h.headerPage, retval, FALSE); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment