summaryrefslogtreecommitdiff
blob: dfd4410e95e956590cff16b8da7d551d34257d11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
--- ./vmmon-only/linux/hostif.c	2019-03-21 23:45:15.452800836 +0100
+++ ./vmmon-only/linux/hostif.c.new	2019-03-21 23:55:42.963849662 +0100
@@ -1709,7 +1709,11 @@
 static uint64
 HostIFReadUptimeWork(unsigned long *j)  // OUT: current jiffies 
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
    struct timeval tv;
+#else
+   struct timespec64 ts;
+#endif
    uint64 monotime, uptime, upBase, monoBase;
    int64 diff;
    uint32 version;
@@ -1727,13 +1731,21 @@
       monoBase = uptimeState.monotimeBase;
    } while (!VersionedAtomic_EndTryRead(&uptimeState.version, version));
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
    do_gettimeofday(&tv);
+#else
+   ktime_get_real_ts64(&ts);
+#endif
    upBase = Atomic_Read64(&uptimeState.uptimeBase);
    
    monotime = (uint64)(jifs - jifBase) * (UPTIME_FREQ / HZ);
    monotime += monoBase;
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
    uptime = tv.tv_usec * (UPTIME_FREQ / 1000000) + tv.tv_sec * UPTIME_FREQ;
+#else
+   uptime = ts.tv_nsec / NSEC_PER_USEC	* (UPTIME_FREQ / 1000000) + ts.tv_sec * UPTIME_FREQ;
+#endif
    uptime += upBase;
    
    /* 
@@ -1842,6 +1854,7 @@
 void
 HostIF_InitUptime(void)
 {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
    struct timeval tv;
 
    uptimeState.jiffiesBase = jiffies;
@@ -1849,6 +1862,15 @@
    Atomic_Write64(&uptimeState.uptimeBase, 
                   -(tv.tv_usec * (UPTIME_FREQ / 1000000) + 
                     tv.tv_sec * UPTIME_FREQ));
+#else
+   struct timespec64 ts;
+
+   uptimeState.jiffiesBase = jiffies;
+   ktime_get_real_ts64(&ts);
+   Atomic_Write64(&uptimeState.uptimeBase, 
+                  -(ts.tv_nsec / NSEC_PER_USEC	* (UPTIME_FREQ / 1000000) + 
+                    ts.tv_sec * UPTIME_FREQ));
+#endif
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
    timer_setup(&uptimeState.timer, HostIFUptimeResyncMono, 0);
--- ./vmmon-only/linux/driver.c	2019-03-21 23:45:15.277800822 +0100
+++ ./vmmon-only/linux/driver.c.new	2019-03-21 23:50:55.619827304 +0100
@@ -760,14 +760,23 @@
 LinuxDriverWakeUp(Bool selective)  // IN:
 {
    if (selective && linuxState.pollList != NULL) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
       struct timeval tv;
+#else
+      struct timespec64 ts;
+#endif
       VmTimeType now;
       VMLinux *p;
       VMLinux *next;
 
       HostIF_PollListLock(1);
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
       do_gettimeofday(&tv);
       now = tv.tv_sec * 1000000ULL + tv.tv_usec;
+#else
+      ktime_get_real_ts64(&ts);
+      now = ts.tv_sec * 1000000ULL + ts.tv_nsec / NSEC_PER_USEC;
+#endif
 
       for (p = linuxState.pollList; p != NULL; p = next) {
          next = p->pollForw;
@@ -834,12 +843,21 @@
       }
    } else {
       if (linuxState.fastClockThread && vmLinux->pollTimeoutPtr != NULL) {
+#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 0, 0)
          struct timeval tv;
 
          do_gettimeofday(&tv);
          poll_wait(filp, &vmLinux->pollQueue, wait);
          vmLinux->pollTime = *vmLinux->pollTimeoutPtr +
                                        tv.tv_sec * 1000000ULL + tv.tv_usec;
+#else
+         struct timespec64 ts;
+
+         ktime_get_real_ts64(&ts);
+         poll_wait(filp, &vmLinux->pollQueue, wait);
+         vmLinux->pollTime = *vmLinux->pollTimeoutPtr +
+                                       ts.tv_sec * 1000000ULL + ts.tv_nsec / NSEC_PER_USEC;
+#endif
          if (vmLinux->pollBack == NULL) {
             HostIF_PollListLock(2);
             if (vmLinux->pollBack == NULL) {