summarylogtreecommitdiffstats
path: root/vmmon.patch
diff options
context:
space:
mode:
authorJean-Marc Lenoir2021-10-15 14:50:40 +0200
committerJean-Marc Lenoir2021-10-15 14:50:40 +0200
commit4870c1496e39f96ca2ac561ca92e29902050cc30 (patch)
tree973190556ff0fcc6898cc9866e5315e1891eb0df /vmmon.patch
parent4984b963b055f73e9dea16976cdbd147ae51c15a (diff)
downloadaur-4870c1496e39f96ca2ac561ca92e29902050cc30.tar.gz
Sync with vmware-workstation 16.2.0
Diffstat (limited to 'vmmon.patch')
-rw-r--r--vmmon.patch145
1 files changed, 48 insertions, 97 deletions
diff --git a/vmmon.patch b/vmmon.patch
index 19ba25431813..6b496decf875 100644
--- a/vmmon.patch
+++ b/vmmon.patch
@@ -39,6 +39,29 @@
#include "vmware.h"
#include "x86apic.h"
+@@ -80,6 +83,13 @@
+ #error CONFIG_HIGH_RES_TIMERS required for acceptable performance
+ #endif
+
++/* task's state is read-once rather than volatile from 5.14-rc2. */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 15, 0) || defined(get_current_state)
++#define get_task_state(task) READ_ONCE((task)->__state)
++#else
++#define get_task_state(task) ((task)->state)
++#endif
++
+ /*
+ * Although this is not really related to kernel-compatibility, I put this
+ * helper macro here for now for a lack of better place --hpreg
+@@ -463,7 +473,7 @@
+ ASSERT(vcpuid < vm->numVCPUs);
+ t = vm->vmhost->vcpuSemaTask[vcpuid];
+ VCPUSet_Remove(&req, vcpuid);
+- if (t && (t->state & TASK_INTERRUPTIBLE)) {
++ if (t && (get_task_state(t) & TASK_INTERRUPTIBLE)) {
+ wake_up_process(t);
+ }
+ }
@@ -614,6 +617,15 @@
MutexUnlock(&fastClockMutex, callerID);
}
@@ -130,7 +153,7 @@
int res;
int waitFD = args[0];
int timeoutms = args[2];
-@@ -2566,9 +2610,6 @@
+@@ -2566,22 +2610,19 @@
return MX_WAITERROR;
}
@@ -140,6 +163,21 @@
{
struct poll_wqueues table;
unsigned int mask;
+
+ poll_initwait(&table);
+- current->state = TASK_INTERRUPTIBLE;
++ __set_current_state(TASK_INTERRUPTIBLE);
+ mask = file->f_op->poll(file, &table.pt);
+ if (!(mask & (POLLIN | POLLERR | POLLHUP))) {
+ vm->vmhost->vcpuSemaTask[vcpuid] = current;
+ schedule_timeout(timeoutms * HZ / 1000); // convert to Hz
+ vm->vmhost->vcpuSemaTask[vcpuid] = NULL;
+ }
+- current->state = TASK_RUNNING;
++ __set_current_state(TASK_RUNNING);
+ poll_freewait(&table);
+ }
+
@@ -2590,9 +2631,11 @@
* the code to happily deal with a pipe or an eventfd. We only care about
* reading no bytes (EAGAIN - non blocking fd) or sizeof(uint64).
@@ -163,6 +201,15 @@
fput(file);
/*
+@@ -2658,7 +2705,7 @@
+ */
+ struct task_struct *t =
+ (struct task_struct *)xchg(&vm->vmhost->vcpuSemaTask[vcpuid], NULL);
+- if (t && (t->state & TASK_INTERRUPTIBLE)) {
++ if (t && (get_task_state(t) & TASK_INTERRUPTIBLE)) {
+ wake_up_process(t);
+ }
+ } ROF_EACH_VCPU_IN_SET_WITH_MAX();
@@ -2688,8 +2730,8 @@
int
HostIF_SemaphoreSignal(uint64 *args) // IN:
@@ -233,99 +280,3 @@
/*
* Do not exit thread until we are told to do so.
*/
-From 9fda02bce13527ce94a95df1a98fb6188dea22b8 Mon Sep 17 00:00:00 2001
-From: Michal Kubecek <mkubecek@suse.cz>
-Date: Wed, 30 Jun 2021 11:05:16 +0200
-Subject: [PATCH] vmmon: fix task_struct::state access patterns
-
-Mainline commit 2f064a59a11f ("sched: Change task_struct::state") in
-5.14-rc1 finishes a series fixing racy access patterns to task state and
-renames task_struct::state to __state so that code old code acessing it
-directly fails to build.
-
-Two of these in HostIF_SemaphoreWait() can be rewritten into calls to
-set_current_state() unconditionally (second one may do with
-__set_current_state() but I don't feel confident enough about that).
-There are also two places where vmmon code reads task_struct::state;
-provide a compat accessor using READ_ONCE() and use it instead of
-a direct read. To avoid kernel version check, check presence of
-get_current_state() macro introduced in the same commit as state member
-rename.
----
- vmmon-only/include/compat_sched.h | 15 +++++++++++++++
- vmmon-only/linux/hostif.c | 10 ++++++----
- 2 files changed, 21 insertions(+), 4 deletions(-)
-
-diff --git a/vmmon-only/include/compat_sched.h b/vmmon-only/include/compat_sched.h
-index 3f3304b..72078e0 100644
---- a/vmmon-only/include/compat_sched.h
-+++ b/vmmon-only/include/compat_sched.h
-@@ -289,5 +289,20 @@ typedef struct pid * compat_pid;
- #define compat_kill_pid(pid, sig, flag) kill_pid(pid, sig, flag)
- #endif
-
-+/*
-+ * Since v5.14-rc1, task_struct::state hase been renamed to __state and is
-+ * is longer supposed to be accessed without READ_ONCE/WRITE_ONCE.
-+ */
-+#ifdef get_current_state
-+static inline int compat_get_task_state(const struct task_struct *t)
-+{
-+ return READ_ONCE(t->__state);
-+}
-+#else
-+static inline int compat_get_task_state(const struct task_struct *t)
-+{
-+ return READ_ONCE(t->state);
-+}
-+#endif
-
- #endif /* __COMPAT_SCHED_H__ */
-diff --git a/vmmon-only/linux/hostif.c b/vmmon-only/linux/hostif.c
-index 137062c..6910f69 100644
---- a/vmmon-only/linux/hostif.c
-+++ b/vmmon-only/linux/hostif.c
-@@ -79,6 +79,8 @@
- #include "pgtbl.h"
- #include "versioned_atomic.h"
-
-+#include "compat_sched.h"
-+
- #if !defined(CONFIG_HIGH_RES_TIMERS)
- #error CONFIG_HIGH_RES_TIMERS required for acceptable performance
- #endif
-@@ -466,7 +468,7 @@ HostIF_WakeUpYielders(VMDriver *vm, // IN:
- ASSERT(vcpuid < vm->numVCPUs);
- t = vm->vmhost->vcpuSemaTask[vcpuid];
- VCPUSet_Remove(&req, vcpuid);
-- if (t && (t->state & TASK_INTERRUPTIBLE)) {
-+ if (t && (compat_get_task_state(t) & TASK_INTERRUPTIBLE)) {
- wake_up_process(t);
- }
- }
-@@ -2613,14 +2615,14 @@ HostIF_SemaphoreWait(VMDriver *vm, // IN:
- unsigned int mask;
-
- poll_initwait(&table);
-- current->state = TASK_INTERRUPTIBLE;
-+ set_current_state(TASK_INTERRUPTIBLE);
- mask = file->f_op->poll(file, &table.pt);
- if (!(mask & (POLLIN | POLLERR | POLLHUP))) {
- vm->vmhost->vcpuSemaTask[vcpuid] = current;
- schedule_timeout(timeoutms * HZ / 1000); // convert to Hz
- vm->vmhost->vcpuSemaTask[vcpuid] = NULL;
- }
-- current->state = TASK_RUNNING;
-+ set_current_state(TASK_RUNNING);
- poll_freewait(&table);
- }
-
-@@ -2698,7 +2700,7 @@ HostIF_SemaphoreForceWakeup(VMDriver *vm, // IN:
- */
- struct task_struct *t =
- (struct task_struct *)xchg(&vm->vmhost->vcpuSemaTask[vcpuid], NULL);
-- if (t && (t->state & TASK_INTERRUPTIBLE)) {
-+ if (t && (compat_get_task_state(t) & TASK_INTERRUPTIBLE)) {
- wake_up_process(t);
- }
- } ROF_EACH_VCPU_IN_SET_WITH_MAX();