summarylogtreecommitdiffstats
path: root/015-linux-5.6.patch
blob: 95c0e957b6a491d80d13f918678425bf79b3f123 (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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
diff -Naurp a/src/vboxhost/vboxdrv/include/iprt/time.h b/src/vboxhost/vboxdrv/include/iprt/time.h
--- a/src/vboxhost/vboxdrv/include/iprt/time.h	2020-02-04 10:54:52.000000000 +0000
+++ b/src/vboxhost/vboxdrv/include/iprt/time.h	2020-04-05 16:18:14.000000000 +0000
@@ -357,8 +357,18 @@ DECLINLINE(void) RTTimeSpecGetSecondsAnd
 
 
 /* PORTME: Add struct timeval guard macro here. */
-#if defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
- || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
+/*
+ * Starting with Linux kernel version 5.6-rc3, the struct timeval is no longer
+ * available to kernel code and must not be used in kernel code.
+ * Only 64-bit time-interfaces are allowed into the kernel.
+ */
+#if defined(RT_OS_LINUX) && (defined(__KERNEL__) || defined(_LINUX_TIME64_H))
+#define RTTIME_NO_TIMEVAL
+#endif
+#if !defined(RTTIME_NO_TIMEVAL) \
+ && (defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) \
+ || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
+ || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_)))
 /**
  * Gets the time as POSIX timeval.
  *
@@ -396,8 +406,20 @@ DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTim
 
 
 /* PORTME: Add struct timespec guard macro here. */
-#if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
- || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
+/*
+ * Starting with Linux kernel version 5.6-rc3, the _STRUCT_TIMESPEC is only defined
+ * under !__KERNEL__ guard and _LINUX_TIME64_H does not define a corresponding
+ * _STRUCT_TIMESPEC64. Only 64-bit time-interfaces are now allowed into the kernel.
+ * We have to keep it for __KERNEL__ though to support older guest kernels (2.6.X)
+ * without _LINUX_TIME64_H.
+ */
+#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H)
+#define RTTIME_NO_TIMESPEC
+#endif
+#if !defined(RTTIME_NO_TIMESPEC) \
+ && (defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) \
+ || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
+ || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_)))
 /**
  * Gets the time as POSIX timespec.
  *
@@ -431,15 +453,14 @@ DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTim
 {
     return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
 }
+#endif /* various ways of detecting struct timespec */
 
-
-# ifdef _LINUX_TIME64_H
+#if defined(RTTIME_NO_TIMESPEC)
 DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
 {
     return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
 }
-# endif
-#endif /* various ways of detecting struct timespec */
+#endif /* RT_OS_LINUX && _LINUX_TIME64_H */
 
 
 
diff -Naurp a/src/vboxhost/vboxdrv/r0drv/linux/memobj-r0drv-linux.c b/src/vboxhost/vboxdrv/r0drv/linux/memobj-r0drv-linux.c
--- a/src/vboxhost/vboxdrv/r0drv/linux/memobj-r0drv-linux.c	2020-02-04 10:55:49.000000000 +0000
+++ b/src/vboxhost/vboxdrv/r0drv/linux/memobj-r0drv-linux.c	2020-04-05 16:18:14.000000000 +0000
@@ -1461,9 +1461,19 @@ DECLHIDDEN(int) rtR0MemObjNativeMapKerne
              * MMIO / physical memory.
              */
             Assert(pMemLnxToMap->Core.enmType == RTR0MEMOBJTYPE_PHYS && !pMemLnxToMap->Core.u.Phys.fAllocated);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
+            /*
+             * ioremap() defaults to no caching since the 2.6 kernels.
+             * ioremap_nocache() has been removed finally in 5.6-rc1.
+             */
+            pMemLnx->Core.pv = pMemLnxToMap->Core.u.Phys.uCachePolicy == RTMEM_CACHE_POLICY_MMIO
+                             ? ioremap(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub)
+                             : ioremap_cache(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub);
+#else /* KERNEL_VERSION < 2.6.25 */
             pMemLnx->Core.pv = pMemLnxToMap->Core.u.Phys.uCachePolicy == RTMEM_CACHE_POLICY_MMIO
                              ? ioremap_nocache(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub)
                              : ioremap(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub);
+#endif /* KERNEL_VERSION < 2.6.25 */
             if (pMemLnx->Core.pv)
             {
                 /** @todo fix protection. */
diff -Naurp a/src/vboxhost/vboxdrv/r0drv/linux/time-r0drv-linux.c b/src/vboxhost/vboxdrv/r0drv/linux/time-r0drv-linux.c
--- a/src/vboxhost/vboxdrv/r0drv/linux/time-r0drv-linux.c	2020-02-04 10:55:49.000000000 +0000
+++ b/src/vboxhost/vboxdrv/r0drv/linux/time-r0drv-linux.c	2020-04-05 16:18:14.000000000 +0000
@@ -38,12 +38,24 @@
 
 DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void)
 {
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16) /* This must match timer-r0drv-linux.c! */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
+    /*
+     * Starting with kernel version 5.6-rc3 only 64-bit time interfaces
+     * are allowed in the kernel.
+     */
+    uint64_t u64;
+    struct timespec64 Ts = { 0, 0 };
+
+    ktime_get_ts64(&Ts);
+    u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec;
+    return u64;
+
+#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16) /* This must match timer-r0drv-linux.c! */
     /*
      * Use ktime_get_ts, this is also what clock_gettime(CLOCK_MONOTONIC,) is using.
      */
     uint64_t u64;
-    struct timespec Ts;
+    struct timespec Ts = { 0, 0 };
     ktime_get_ts(&Ts);
     u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec;
     return u64;
@@ -182,9 +194,9 @@ RTDECL(PRTTIMESPEC) RTTimeNow(PRTTIMESPE
     IPRT_LINUX_RESTORE_EFL_AC();
 # ifdef _LINUX_TIME64_H
     return RTTimeSpecSetTimespec64(pTime, &Ts);
-#else
+# else
     return RTTimeSpecSetTimespec(pTime, &Ts);
-#endif
+# endif
 #else   /* < 2.6.16 */
     struct timeval Tv;
     do_gettimeofday(&Tv);
diff -Naurp a/src/vboxhost/vboxnetadp/include/iprt/time.h b/src/vboxhost/vboxnetadp/include/iprt/time.h
--- a/src/vboxhost/vboxnetadp/include/iprt/time.h	2020-02-04 10:54:52.000000000 +0000
+++ b/src/vboxhost/vboxnetadp/include/iprt/time.h	2020-04-05 16:18:14.000000000 +0000
@@ -357,8 +357,18 @@ DECLINLINE(void) RTTimeSpecGetSecondsAnd
 
 
 /* PORTME: Add struct timeval guard macro here. */
-#if defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
- || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
+/*
+ * Starting with Linux kernel version 5.6-rc3, the struct timeval is no longer
+ * available to kernel code and must not be used in kernel code.
+ * Only 64-bit time-interfaces are allowed into the kernel.
+ */
+#if defined(RT_OS_LINUX) && (defined(__KERNEL__) || defined(_LINUX_TIME64_H))
+#define RTTIME_NO_TIMEVAL
+#endif
+#if !defined(RTTIME_NO_TIMEVAL) \
+ && (defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) \
+ || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
+ || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_)))
 /**
  * Gets the time as POSIX timeval.
  *
@@ -396,8 +406,20 @@ DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTim
 
 
 /* PORTME: Add struct timespec guard macro here. */
-#if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
- || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
+/*
+ * Starting with Linux kernel version 5.6-rc3, the _STRUCT_TIMESPEC is only defined
+ * under !__KERNEL__ guard and _LINUX_TIME64_H does not define a corresponding
+ * _STRUCT_TIMESPEC64. Only 64-bit time-interfaces are now allowed into the kernel.
+ * We have to keep it for __KERNEL__ though to support older guest kernels (2.6.X)
+ * without _LINUX_TIME64_H.
+ */
+#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H)
+#define RTTIME_NO_TIMESPEC
+#endif
+#if !defined(RTTIME_NO_TIMESPEC) \
+ && (defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) \
+ || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
+ || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_)))
 /**
  * Gets the time as POSIX timespec.
  *
@@ -431,15 +453,14 @@ DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTim
 {
     return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
 }
+#endif /* various ways of detecting struct timespec */
 
-
-# ifdef _LINUX_TIME64_H
+#if defined(RTTIME_NO_TIMESPEC)
 DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
 {
     return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
 }
-# endif
-#endif /* various ways of detecting struct timespec */
+#endif /* RT_OS_LINUX && _LINUX_TIME64_H */
 
 
 
diff -Naurp a/src/vboxhost/vboxnetflt/include/iprt/time.h b/src/vboxhost/vboxnetflt/include/iprt/time.h
--- a/src/vboxhost/vboxnetflt/include/iprt/time.h	2020-02-04 10:54:52.000000000 +0000
+++ b/src/vboxhost/vboxnetflt/include/iprt/time.h	2020-04-05 16:18:14.000000000 +0000
@@ -357,8 +357,18 @@ DECLINLINE(void) RTTimeSpecGetSecondsAnd
 
 
 /* PORTME: Add struct timeval guard macro here. */
-#if defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
- || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
+/*
+ * Starting with Linux kernel version 5.6-rc3, the struct timeval is no longer
+ * available to kernel code and must not be used in kernel code.
+ * Only 64-bit time-interfaces are allowed into the kernel.
+ */
+#if defined(RT_OS_LINUX) && (defined(__KERNEL__) || defined(_LINUX_TIME64_H))
+#define RTTIME_NO_TIMEVAL
+#endif
+#if !defined(RTTIME_NO_TIMEVAL) \
+ && (defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) \
+ || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
+ || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_)))
 /**
  * Gets the time as POSIX timeval.
  *
@@ -396,8 +406,20 @@ DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTim
 
 
 /* PORTME: Add struct timespec guard macro here. */
-#if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
- || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
+/*
+ * Starting with Linux kernel version 5.6-rc3, the _STRUCT_TIMESPEC is only defined
+ * under !__KERNEL__ guard and _LINUX_TIME64_H does not define a corresponding
+ * _STRUCT_TIMESPEC64. Only 64-bit time-interfaces are now allowed into the kernel.
+ * We have to keep it for __KERNEL__ though to support older guest kernels (2.6.X)
+ * without _LINUX_TIME64_H.
+ */
+#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H)
+#define RTTIME_NO_TIMESPEC
+#endif
+#if !defined(RTTIME_NO_TIMESPEC) \
+ && (defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) \
+ || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
+ || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_)))
 /**
  * Gets the time as POSIX timespec.
  *
@@ -431,15 +453,14 @@ DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTim
 {
     return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
 }
+#endif /* various ways of detecting struct timespec */
 
-
-# ifdef _LINUX_TIME64_H
+#if defined(RTTIME_NO_TIMESPEC)
 DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
 {
     return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
 }
-# endif
-#endif /* various ways of detecting struct timespec */
+#endif /* RT_OS_LINUX && _LINUX_TIME64_H */