diff options
author | Jean-Marc Lenoir | 2021-10-15 17:16:06 +0200 |
---|---|---|
committer | Jean-Marc Lenoir | 2021-10-15 17:16:06 +0200 |
commit | ddc60619063cde6c15a6e71ef573b4d55872dc5e (patch) | |
tree | 60b7ea7f1a721e6a6b48674367808b7ddf430cbb /vmmon.patch | |
parent | 9235677611f9a75df191a15e8994896152e895f8 (diff) | |
download | aur-ddc60619063cde6c15a6e71ef573b4d55872dc5e.tar.gz |
Sync with vmware-workstation 16.2.0
Diffstat (limited to 'vmmon.patch')
-rw-r--r-- | vmmon.patch | 145 |
1 files changed, 48 insertions, 97 deletions
diff --git a/vmmon.patch b/vmmon.patch index ccd999656f3e..bc662e0d24c8 100644 --- a/vmmon.patch +++ b/vmmon.patch @@ -1179,6 +1179,29 @@ #include "vmhost.h" #include "x86msr.h" #include "apic.h" +@@ -119,6 +121,13 @@ + # define close_rtc(filp, files) filp_close(filp, files) + #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 ++ + #define UPTIME_FREQ CONST64(1000000) + + /* +@@ -478,7 +487,7 @@ + while ((vcpuid = VCPUSet_FindFirst(&req)) != VCPUID_INVALID) { + struct task_struct *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); + } + } @@ -630,6 +632,15 @@ HostIF_FastClockUnlock(int callerID) // MutexUnlock(&fastClockMutex, callerID); } @@ -1482,7 +1505,7 @@ int res; int waitFD = args[0]; int timeoutms = args[2]; -@@ -2478,9 +2582,6 @@ HostIF_SemaphoreWait(VMDriver *vm, // +@@ -2478,22 +2582,19 @@ HostIF_SemaphoreWait(VMDriver *vm, // return MX_WAITERROR; } @@ -1492,6 +1515,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); + } + @@ -2502,9 +2603,11 @@ HostIF_SemaphoreWait(VMDriver *vm, // * 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). @@ -1515,6 +1553,15 @@ fput(file); /* +@@ -2566,7 +2675,7 @@ + FOR_EACH_VCPU_IN_SET(vcs, vcpuid) { + struct task_struct *t = vm->vmhost->vcpuSemaTask[vcpuid]; + 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(); @@ -2596,8 +2698,8 @@ HostIF_SemaphoreForceWakeup(VMDriver *vm int HostIF_SemaphoreSignal(uint64 *args) // IN: @@ -1812,99 +1859,3 @@ break; } -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 -@@ -102,6 +102,8 @@ - #include "vmmonInt.h" - #include "versioned_atomic.h" - -+#include "compat_sched.h" -+ - /* - * Determine if we can use high resolution timers. - */ -@@ -480,7 +482,7 @@ HostIF_WakeUpYielders(VMDriver *vm, // IN: - while ((vcpuid = VCPUSet_FindFirst(&req)) != VCPUID_INVALID) { - struct task_struct *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); - } - } -@@ -2587,14 +2589,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); - } - -@@ -2668,7 +2670,7 @@ HostIF_SemaphoreForceWakeup(VMDriver *vm, // IN: - FOR_EACH_VCPU_IN_SET(vcs, vcpuid) { - struct task_struct *t = vm->vmhost->vcpuSemaTask[vcpuid]; - 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(); |