Add missing patch to vmware-modules

This commit is contained in:
Sergey Morozov 2018-10-02 12:39:18 +03:00
parent b816279f45
commit 6bae9f0d7f
1 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,77 @@
From 3f2a6c720f68860e3482c81eb49737ad9a05606d Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Sun, 17 Jun 2018 15:54:09 +0200
Subject: [PATCH 4/4] vmmon: compatibility with eventpoll switch to poll_mask()
Since commit 11c5ad0ec441 ("eventpoll: switch to ->poll_mask") in
v4.18-rc1, eventpoll switched from ->poll() to ->poll_mask(). Rather than
calling the callback directly (which would result in null pointer
dereference), use vfs_poll() wrapper. As this wrapper is only available
since 4.18-rc1 cycle as well, provide a copy to use when building against
older kernels.
---
vmmon-only/include/compat_poll.h | 30 ++++++++++++++++++++++++++++++
vmmon-only/linux/hostif.c | 3 ++-
2 files changed, 32 insertions(+), 1 deletion(-)
create mode 100644 vmmon-only/include/compat_poll.h
diff --git a/vmmon-only/include/compat_poll.h b/vmmon-only/include/compat_poll.h
new file mode 100644
index 0000000..562cdb6
--- /dev/null
+++ b/vmmon-only/include/compat_poll.h
@@ -0,0 +1,30 @@
+#ifndef __COMPAT_POLL_H__
+#define __COMPAT_POLL_H__
+
+#include <linux/poll.h>
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 18, 0))
+
+#ifndef __poll_t
+typedef unsigned int __poll_t;
+#endif
+
+static inline __poll_t compat_vfs_poll(struct file *file,
+ struct poll_table_struct *pt)
+{
+ if (unlikely(!file->f_op->poll))
+ return DEFAULT_POLLMASK;
+ return file->f_op->poll(file, pt);
+}
+
+#else
+
+static inline __poll_t compat_vfs_poll(struct file *file,
+ struct poll_table_struct *pt)
+{
+ return vfs_poll(file, pt);
+}
+
+#endif
+
+#endif /* __COMPAT_POLL_H__ */
diff --git a/vmmon-only/linux/hostif.c b/vmmon-only/linux/hostif.c
index b793539..61d00df 100644
--- a/vmmon-only/linux/hostif.c
+++ b/vmmon-only/linux/hostif.c
@@ -74,6 +74,7 @@
#include "pgtbl.h"
#include "versioned_atomic.h"
+#include "compat_poll.h"
#if !defined(CONFIG_HIGH_RES_TIMERS)
#error CONFIG_HIGH_RES_TIMERS required for acceptable performance
@@ -2373,7 +2374,7 @@ HostIF_SemaphoreWait(VMDriver *vm, // IN:
poll_initwait(&table);
current->state = TASK_INTERRUPTIBLE;
- mask = file->f_op->poll(file, &table.pt);
+ mask = compat_vfs_poll(file, &table.pt);
if (!(mask & (POLLIN | POLLERR | POLLHUP))) {
vm->vmhost->vcpuSemaTask[vcpuid] = current;
schedule_timeout(timeoutms * HZ / 1000); // convert to Hz
--
2.18.0