Last active
July 27, 2021 20:50
-
-
Save varette/37ca95a7925566017df2fccdad24f534 to your computer and use it in GitHub Desktop.
Add linux 5.6 support to Parallels Desktop 15 Guest Tools. Based on a discussion here: https://gist.github.com/mag911/1a5583a766467d6023584d738cee0d98
This file contains 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
For ubuntu 20.04 / linux 5.6 support, apply this patch to the root of the | |
prl_mod.tar.gz archive found in the ISO of the Parallels Desktop 15 Guest | |
Tools. This is a hack that contains a small memory leak. I have little | |
experience hacking on the linux kernel, use at your own risk. | |
--- | |
.../Guest/Linux/prl_fs/prlfs_compat.h | 17 ++++++++++++++++- | |
.../Linux/prl_freeze/prlfs_freeze_compat.h | 16 +++++++++++++++- | |
prl_tg/Toolgate/Guest/Linux/prl_tg/prltg.c | 16 +++++++++++++++- | |
prl_tg/Toolgate/Guest/Linux/prl_tg/prltg_call.c | 4 ++-- | |
4 files changed, 48 insertions(+), 5 deletions(-) | |
diff --git a/prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs_compat.h b/prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs_compat.h | |
index 5d20399..edca98a 100644 | |
--- a/prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs_compat.h | |
+++ b/prl_fs/SharedFolders/Guest/Linux/prl_fs/prlfs_compat.h | |
@@ -18,8 +18,23 @@ prlfs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, | |
if (p) | |
p->proc_fops = fops; | |
return p; | |
-#else | |
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) | |
return proc_create(name, mode, parent, fops); | |
+#else | |
+ // fun little memory leak | |
+ struct proc_ops *converted_proc_ops; | |
+ converted_proc_ops = (struct proc_ops *) kmalloc(sizeof(struct proc_ops), GFP_KERNEL); | |
+ *converted_proc_ops = ( struct proc_ops ){ | |
+ .proc_open = fops->open, | |
+ .proc_write = fops->write, | |
+ .proc_lseek = fops->llseek, | |
+ .proc_poll = fops->poll, | |
+ .proc_ioctl = fops->unlocked_ioctl, | |
+ .proc_mmap = fops->mmap, | |
+ .proc_release = fops->release, | |
+ .proc_get_unmapped_area = fops->get_unmapped_area, | |
+ }; | |
+ return proc_create(name, mode, parent, converted_proc_ops); | |
#endif | |
} | |
diff --git a/prl_fs_freeze/Snapshot/Guest/Linux/prl_freeze/prlfs_freeze_compat.h b/prl_fs_freeze/Snapshot/Guest/Linux/prl_freeze/prlfs_freeze_compat.h | |
index 2378ebf..f0eabb6 100644 | |
--- a/prl_fs_freeze/Snapshot/Guest/Linux/prl_freeze/prlfs_freeze_compat.h | |
+++ b/prl_fs_freeze/Snapshot/Guest/Linux/prl_freeze/prlfs_freeze_compat.h | |
@@ -17,8 +17,22 @@ prlfs_freeze_proc_create(char *name, umode_t mode, | |
if (p) | |
p->proc_fops = fops; | |
return p; | |
-#else | |
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) | |
return proc_create(name, mode, parent, fops); | |
+#else | |
+ // fun little memory leak | |
+ struct proc_ops *converted_proc_ops = kmalloc(sizeof(struct proc_ops), GFP_KERNEL); | |
+ *converted_proc_ops = ( struct proc_ops ){ | |
+ .proc_open = fops->open, | |
+ .proc_write = fops->write, | |
+ .proc_lseek = fops->llseek, | |
+ .proc_poll = fops->poll, | |
+ .proc_ioctl = fops->unlocked_ioctl, | |
+ .proc_mmap = fops->mmap, | |
+ .proc_release = fops->release, | |
+ .proc_get_unmapped_area = fops->get_unmapped_area, | |
+ }; | |
+ return proc_create(name, mode, parent, converted_proc_ops); | |
#endif | |
} | |
diff --git a/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg.c b/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg.c | |
index 6213542..42b33e6 100644 | |
--- a/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg.c | |
+++ b/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg.c | |
@@ -401,8 +401,22 @@ prltg_proc_create_data(char *name, umode_t mode, struct proc_dir_entry *parent, | |
p->data = data; | |
} | |
return p; | |
-#else | |
+#elif LINUX_VERSION_CODE < KERNEL_VERSION(5,6,0) | |
return proc_create_data(name, mode, parent, fops, data); | |
+#else | |
+ // fun little memory leak | |
+ struct proc_ops *converted_proc_ops = kmalloc(sizeof(struct proc_ops), GFP_KERNEL); | |
+ *converted_proc_ops = ( struct proc_ops ){ | |
+ .proc_open = fops->open, | |
+ .proc_write = fops->write, | |
+ .proc_lseek = fops->llseek, | |
+ .proc_poll = fops->poll, | |
+ .proc_ioctl = fops->unlocked_ioctl, | |
+ .proc_mmap = fops->mmap, | |
+ .proc_release = fops->release, | |
+ .proc_get_unmapped_area = fops->get_unmapped_area, | |
+ }; | |
+ return proc_create_data(name, mode, parent, converted_proc_ops, data); | |
#endif | |
} | |
diff --git a/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg_call.c b/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg_call.c | |
index 269c345..1c6305c 100644 | |
--- a/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg_call.c | |
+++ b/prl_tg/Toolgate/Guest/Linux/prl_tg/prltg_call.c | |
@@ -106,13 +106,13 @@ static TG_PAGED_BUFFER *tg_req_map_user_pages(struct TG_PENDING_REQUEST *req, | |
uple->writable = sbuf->Writable; | |
uple->count = npages; | |
- down_read(¤t->mm->mmap_sem); | |
+ mmap_read_lock(current->mm); | |
/* lock userspace pages */ | |
got = prl_get_user_pages( | |
sbuf->u.Va, npages, | |
sbuf->Writable, | |
uple->p, NULL); | |
- up_read(¤t->mm->mmap_sem); | |
+ mmap_read_unlock(current->mm); | |
if (got < npages) { | |
DPRINTK("[2] %d < %d \n", got, npages); | |
-- | |
2.31.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment