Skip to content

Instantly share code, notes, and snippets.

@salaros
Last active June 19, 2017 22:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save salaros/07a3a18aee05bcf169d9c7bd9c98ff2c to your computer and use it in GitHub Desktop.
Save salaros/07a3a18aee05bcf169d9c7bd9c98ff2c to your computer and use it in GitHub Desktop.
static int
HostIFGetUserPages(void *uvAddr, // IN
struct page **ppages, // OUT
unsigned int numPages) // IN
{
int retval;
down_read(&current->mm->mmap_sem);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
unsigned int flags = 0;
flags |= 1;
retval = get_user_pages_remote(current, current->mm, (unsigned long)uvAddr,
numPages, flags, ppages, NULL);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
retval = get_user_pages((unsigned long)uvAddr, numPages, 0, 0, ppages, NULL);
#else
retval = get_user_pages(current, current->mm, (unsigned long)uvAddr,
numPages, 0, 0, ppages, NULL);
#endif
up_read(&current->mm->mmap_sem);
return retval != numPages;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
retval = get_user_pages((unsigned long)uvAddr, numPages, 0, 0, ppages, NULL);
#else
retval = get_user_pages(current, current->mm, (unsigned long)uvAddr,
numPages, 0, 0, ppages, NULL);
#endif
#if 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,
1, 1, 0, &page, NULL);
#endif
cd /usr/lib/vmware/modules/source
cp vmnet.tar vmnet.tar.bak
cp vmmon.tar vmmon.tar.bak
tar cf vmmon.tar vmmon-only/
tar cf vmnet.tar vmnet-only/
# The row below usually works, however on some computers we had
# to run 'vmware' as root in order to trigger module installation
vmware-modconfig --console --install-all
cd /usr/lib/vmware/modules/source
tar xfv vmmon.tar
tar xfv vmnet.tar
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
retval = get_user_pages(addr, 1, 1, 0, &page, NULL);
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
unsigned int flags = 0;
flags |= 1;
retval = get_user_pages_remote(current, current->mm, addr, 1, flags, &page, NULL);
#else
retval = get_user_pages(current, current->mm, addr,
1, 1, 0, &page, NULL);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment