summarylogtreecommitdiffstats
path: root/vmmon.patch
diff options
context:
space:
mode:
authorJean-Marc Lenoir2018-01-07 15:23:48 +0100
committerJean-Marc Lenoir2018-01-07 15:23:48 +0100
commitf0abbd18cbbd0e9c4f53a7c5c9d1d6e3fcf2cf40 (patch)
tree507719836fb456902d709371ab995609f1e420bb /vmmon.patch
parent4dcb0e93d986e34a89282b64121ae7873a9622a3 (diff)
downloadaur-f0abbd18cbbd0e9c4f53a7c5c9d1d6e3fcf2cf40.tar.gz
Come back to VMware 14
Diffstat (limited to 'vmmon.patch')
-rw-r--r--vmmon.patch220
1 files changed, 113 insertions, 107 deletions
diff --git a/vmmon.patch b/vmmon.patch
index c8e61a5ed44c..1b812a0ab760 100644
--- a/vmmon.patch
+++ b/vmmon.patch
@@ -25,8 +25,8 @@ index bf805e0..9aac585 100644
-EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE)
+EXTRA_CFLAGS := $(CC_OPTS) $(INCLUDE) $(LINUXINCLUDE)
- EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/smpcall.c, -DVMW_HAVE_SMP_CALL_3ARG, )
- EXTRA_CFLAGS += $(call vm_check_build, $(SRCROOT)/autoconf/tsc_khz.c, -DVMW_HAVE_TSC_KHZ, )
+ obj-m += $(DRIVER).o
+
diff --git a/vmmon/include/compat_module.h b/vmmon/include/compat_module.h
index 2af7372..729aedc 100644
--- a/vmmon/include/compat_module.h
@@ -45,18 +45,64 @@ index 2af7372..729aedc 100644
+#endif
+
#endif /* __COMPAT_MODULE_H__ */
+diff --git a/vmmon-only/include/compat_timer.h b/vmmon-only/include/compat_timer.h
+new file mode 100644
+index 0000000..b68d9b2
+--- /dev/null
++++ b/vmmon-only/include/compat_timer.h
+@@ -0,0 +1,33 @@
++#ifndef __COMPAT_TIMER_H__
++#define __COMPAT_TIMER_H__
++
++#include <linux/timer.h>
++
++#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)) && !defined(timer_setup)
++
++typedef unsigned long compat_timer_arg_t;
++
++static inline void compat_timer_setup(struct timer_list *timer,
++ void (*func)(compat_timer_arg_t),
++ unsigned int flags)
++{
++ init_timer(timer);
++ timer->function = func;
++ timer->data = 0;
++ timer->flags = flags;
++}
++
++#else /* new timer interface since 4.15 */
++
++typedef struct timer_list *compat_timer_arg_t;
++
++static inline void compat_timer_setup(struct timer_list *timer,
++ void (*func)(compat_timer_arg_t),
++ unsigned int flags)
++{
++ timer_setup(timer, func, flags);
++}
++
++#endif /* new timer interface since 4.15 */
++
++#endif /* __COMPAT_TIMER_H__ */
diff --git a/vmmon/linux/driver.c b/vmmon/linux/driver.c
index 87cf45b..5390a93 100644
--- a/vmmon/linux/driver.c
+++ b/vmmon/linux/driver.c
-@@ -126,7 +126,16 @@ static struct vm_operations_struct vmuser_mops = {
- #endif
+@@ -21,6 +21,7 @@
+
+ #define EXPORT_SYMTAB
+
++#include "compat_timer.h"
+ #include <linux/file.h>
+ #include <linux/highmem.h>
+ #include <linux/mm.h>
+@@ -109,7 +109,15 @@ static struct vm_operations_struct vmuser_mops = {
+ .fault = LinuxDriverFault
};
-static struct file_operations vmuser_fops;
+static struct file_operations vmuser_fops = {
+ .owner = THIS_MODULE,
-+ .poll = LinuxDriverPoll,
+ .unlocked_ioctl = LinuxDriver_Ioctl,
+ .compat_ioctl = LinuxDriver_Ioctl,
+ .open = LinuxDriver_Open,
@@ -67,8 +113,27 @@ index 87cf45b..5390a93 100644
static struct timer_list tscTimer;
static Atomic_uint32 tsckHz;
static VmTimeStart tsckHzStartTime;
-@@ -319,21 +328,6 @@ init_module(void)
- linuxState.fastClockPriority = -20;
+@@ -216,7 +217,7 @@ LinuxDriverEstimateTSCkHz(void)
+ *----------------------------------------------------------------------
+ */
+ static void
+-LinuxDriverEstimateTSCkHzDeferred(unsigned long data)
++LinuxDriverEstimateTSCkHzDeferred(compat_timer_arg_t unused)
+ {
+ LinuxDriverEstimateTSCkHz();
+ }
+@@ -251,9 +252,7 @@ LinuxDriverInitTSCkHz(void)
+ }
+
+ LinuxDriverReadTSCAndUptime(&tsckHzStartTime);
+- tscTimer.function = LinuxDriverEstimateTSCkHzDeferred;
+ tscTimer.expires = jiffies + 4 * HZ;
+- tscTimer.data = 0;
+ add_timer(&tscTimer);
+ }
+
+@@ -295,20 +304,6 @@ init_module(void)
+ linuxState.fastClockRate = 0;
linuxState.swapSize = VMMON_UNKNOWN_SWAP_SIZE;
- /*
@@ -79,7 +144,6 @@ index 87cf45b..5390a93 100644
-
- memset(&vmuser_fops, 0, sizeof vmuser_fops);
- vmuser_fops.owner = THIS_MODULE;
-- vmuser_fops.poll = LinuxDriverPoll;
- vmuser_fops.unlocked_ioctl = LinuxDriver_Ioctl;
- vmuser_fops.compat_ioctl = LinuxDriver_Ioctl;
- vmuser_fops.open = LinuxDriver_Open;
@@ -89,7 +153,16 @@ index 87cf45b..5390a93 100644
#ifdef VMX86_DEVEL
devel_init_module();
linuxState.minor = 0;
-@@ -389,7 +383,9 @@ cleanup_module(void)
+@@ -335,7 +334,7 @@ init_module(void)
+ linuxState.deviceName, linuxState.major, linuxState.minor);
+
+ HostIF_InitUptime();
+- init_timer(&tscTimer);
++ compat_timer_setup(&tscTimer, LinuxDriverEstimateTSCkHzDeferred, 0);
+ LinuxDriverInitTSCkHz();
+ Vmx86_InitIDList();
+
+@@ -364,7 +373,9 @@ cleanup_module(void)
#ifdef VMX86_DEVEL
unregister_chrdev(linuxState.major, linuxState.deviceName);
#else
@@ -100,7 +173,7 @@ index 87cf45b..5390a93 100644
#endif
Log("Module %s: unloaded\n", linuxState.deviceName);
-@@ -1287,7 +1283,7 @@ LinuxDriverReadTSC(void *data, // OUT: TSC values
+@@ -977,7 +988,7 @@ LinuxDriverReadTSC(void *data, // OUT: TSC values
*-----------------------------------------------------------------------------
*/
@@ -113,7 +186,15 @@ diff --git a/vmmon/linux/hostif.c b/vmmon/linux/hostif.c
index fd32013..583d6da 100644
--- a/vmmon/linux/hostif.c
+++ b/vmmon/linux/hostif.c
-@@ -37,6 +37,9 @@
+@@ -29,6 +29,7 @@
+ #include "driver-config.h"
+
+ /* Must come before vmware.h --hpreg */
++#include "compat_timer.h"
+ #include <linux/binfmts.h>
+ #include <linux/delay.h>
+ #include <linux/file.h>
+@@ -36,6 +36,9 @@
#include <linux/vmalloc.h>
#include <linux/slab.h>
@@ -123,116 +204,41 @@ index fd32013..583d6da 100644
#include <linux/preempt.h>
#include <linux/poll.h>
-@@ -73,6 +76,7 @@
+@@ -51,6 +54,7 @@
#include <linux/capability.h>
#include <linux/kthread.h>
#include <linux/wait.h>
+#include <asm/apic.h>
+ #include <linux/hrtimer.h>
#include <linux/signal.h>
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
#include <linux/taskstats_kern.h> // For linux/sched/signal.h without version check
-@@ -99,6 +99,37 @@
- #include "vmmonInt.h"
- #include "versioned_atomic.h"
-
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 14, 0)
-+# define global_zone_page_state global_page_state
-+#endif
-+
-+static unsigned long get_nr_slab_unreclaimable(void)
-+{
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
-+ return global_node_page_state(NR_SLAB_UNRECLAIMABLE);
-+#else
-+ return global_page_state(NR_SLAB_UNRECLAIMABLE);
-+#endif
-+}
-+
-+static unsigned long get_nr_unevictable(void)
-+{
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
-+ return global_node_page_state(NR_UNEVICTABLE);
-+#else
-+ return global_page_state(NR_UNEVICTABLE);
-+#endif
-+}
-+
-+static unsigned long get_nr_anon_mapped(void)
-+{
-+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
-+ return global_node_page_state(NR_ANON_MAPPED);
-+ #else
-+ return global_page_state(NR_ANON_PAGES);
-+ #endif
-+}
-+
- /*
- * Determine if we can use high resolution timers.
- */
-@@ -142,6 +146,10 @@
+@@ -115,6 +149,10 @@
*/
#define LOCKED_PAGE_SLACK 10000
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
++#if LINUX_VERSION_CODE > KERNEL_VERSION(4, 8, 0)
+#define NR_ANON_PAGES NR_ANON_MAPPED
+#endif
+
static struct {
Atomic_uint64 uptimeBase;
VersionedAtomic version;
-@@ -1165,14 +1173,16 @@
- int retval;
-
- down_read(&current->mm->mmap_sem);
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)
-- retval = get_user_pages((unsigned long)uvAddr, numPages, 0, ppages, NULL);
--#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
-- retval = get_user_pages((unsigned long)uvAddr, numPages, 0, 0, ppages, NULL);
-+#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)
-+ retval = get_user_pages((unsigned long)uvAddr,
- #else
- retval = get_user_pages(current, current->mm, (unsigned long)uvAddr,
-- numPages, 0, 0, ppages, NULL);
- #endif
-+ numPages, 0,
-+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)
-+ 0,
-+#endif
-+ ppages, NULL);
- up_read(&current->mm->mmap_sem);
-
- return retval != numPages;
-@@ -1594,16 +1625,11 @@ HostIF_EstimateLockedPageLimit(const VMDriver* vm, // IN
- unsigned int reservedPages = MEMDEFAULTS_MIN_HOST_PAGES;
- unsigned int hugePages = (vm == NULL) ? 0 :
- BYTES_2_PAGES(vm->memInfo.hugePageBytes);
-- unsigned int lockedPages = global_page_state(NR_PAGETABLE) +
-- global_page_state(NR_SLAB_UNRECLAIMABLE) +
-- global_page_state(NR_UNEVICTABLE) +
-+ unsigned int lockedPages = global_zone_page_state(NR_PAGETABLE) +
-+ get_nr_slab_unreclaimable() +
-+ get_nr_unevictable() +
- hugePages + reservedPages;
-- unsigned int anonPages =
--#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 8, 0)
-- global_page_state(NR_ANON_MAPPED);
--#else
-- global_page_state(NR_ANON_PAGES);
--#endif
-+ unsigned int anonPages = get_nr_anon_mapped();
- unsigned int swapPages = BYTES_2_PAGES(linuxState.swapSize);
-
- if (anonPages > swapPages) {
-diff --git a/vmmon/linux/vmmonInt.h b/vmmon/linux/vmmonInt.h
-index 4dc04e9..993212d 100644
---- a/vmmon/linux/vmmonInt.h
-+++ b/vmmon/linux/vmmonInt.h
-@@ -28,7 +28,7 @@
- * Hide all kernel compatibility stuff in these macros and functions.
+@@ -1705,7 +1714,7 @@ HostIFReadUptimeWork(unsigned long *j) // OUT: current jiffies
*/
--#ifdef VMW_HAVE_SMP_CALL_3ARG
-+#if defined (VMW_HAVE_SMP_CALL_3ARG) || LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0)
- #define compat_smp_call_function(fn, info, wait) smp_call_function(fn, info, wait)
- #else
- #define compat_smp_call_function(fn, info, wait) smp_call_function(fn, info, 1, wait)
+ static void
+-HostIFUptimeResyncMono(unsigned long data) // IN: ignored
++HostIFUptimeResyncMono(compat_timer_arg_t unused) // IN: ignored
+ {
+ unsigned long jifs;
+ uintptr_t flags;
+@@ -1767,8 +1776,7 @@ HostIF_InitUptime(void)
+ -(tv.tv_usec * (UPTIME_FREQ / 1000000) +
+ tv.tv_sec * UPTIME_FREQ));
+
+- init_timer(&uptimeState.timer);
+- uptimeState.timer.function = HostIFUptimeResyncMono;
++ compat_timer_setup(&uptimeState.timer, HostIFUptimeResyncMono, 0);
+ mod_timer(&uptimeState.timer, jiffies + HZ);
+ }
+