1 Index: include/iprt/time.h
2 ===================================================================
3 --- include/iprt/time.h (revision 83470)
4 +++ include/iprt/time.h (revision 83471)
6 /* PORTME: Add struct timeval guard macro here. */
7 #if defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
8 || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
10 + * Starting with Linux kernel version 5.6-rc3, the struct timeval is no longer
11 + * available to kernel code and must not be used in kernel code.
12 + * Only 64-bit time-interfaces are allowed into the kernel.
14 +# if defined(RT_OS_LINUX) && (!defined(__KERNEL__) || !defined(_LINUX_TIME64_H))
16 * Gets the time as POSIX timeval.
20 return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
22 +# endif /* RT_OS_LINUX ... */
23 #endif /* various ways of detecting struct timeval */
28 return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec);
30 +#endif /* various ways of detecting struct timespec */
33 -# ifdef _LINUX_TIME64_H
34 +#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H)
36 + * Starting with Linux kernel version 5.6-rc3, the _STRUCT_TIMESPEC is only defined
37 + * under !__KERNEL__ guard and _LINUX_TIME64_H does not define a corresponding
38 + * _STRUCT_TIMESPEC64. Only 64-bit time-interfaces are now allowed into the kernel.
40 DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
42 return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
45 -#endif /* various ways of detecting struct timespec */
46 +#endif /* RT_OS_LINUX && _LINUX_TIME64_H */
50 Index: src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c
51 ===================================================================
52 --- src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (revision 83470)
53 +++ src/VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c (revision 83471)
54 @@ -1461,9 +1461,19 @@
55 * MMIO / physical memory.
57 Assert(pMemLnxToMap->Core.enmType == RTR0MEMOBJTYPE_PHYS && !pMemLnxToMap->Core.u.Phys.fAllocated);
58 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
60 + * ioremap() defaults to no caching since the 2.6 kernels.
61 + * ioremap_nocache() has been removed finally in 5.6-rc1.
63 pMemLnx->Core.pv = pMemLnxToMap->Core.u.Phys.uCachePolicy == RTMEM_CACHE_POLICY_MMIO
64 + ? ioremap(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub)
65 + : ioremap_cache(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub);
66 +#else /* KERNEL_VERSION < 2.6.25 */
67 + pMemLnx->Core.pv = pMemLnxToMap->Core.u.Phys.uCachePolicy == RTMEM_CACHE_POLICY_MMIO
68 ? ioremap_nocache(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub)
69 : ioremap(pMemLnxToMap->Core.u.Phys.PhysBase + offSub, cbSub);
70 +#endif /* KERNEL_VERSION < 2.6.25 */
73 /** @todo fix protection. */
74 Index: src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
75 ===================================================================
76 --- src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c (revision 83470)
77 +++ src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c (revision 83471)
80 DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void)
82 -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16) /* This must match timer-r0drv-linux.c! */
83 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
85 + * Starting with kernel version 5.6-rc3 only 64-bit time interfaces
86 + * are allowed in the kernel.
89 + struct timespec64 Ts = { 0, 0 };
91 + ktime_get_ts64(&Ts);
92 + u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec;
95 +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16) /* This must match timer-r0drv-linux.c! */
97 * Use ktime_get_ts, this is also what clock_gettime(CLOCK_MONOTONIC,) is using.
100 - struct timespec Ts;
101 + struct timespec Ts = { 0, 0 };
103 u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec;
105 Index: src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c
106 ===================================================================
107 --- src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c (revision 83470)
108 +++ src/VBox/HostDrivers/VBoxPci/linux/VBoxPci-linux.c (revision 83471)
109 @@ -842,15 +842,27 @@
110 rcLnx = pci_request_region(pPciDev, iRegion, "vboxpci");
113 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
115 + * ioremap() defaults to no caching since the 2.6 kernels.
116 + * ioremap_nocache() has been removed finally in 5.6-rc1.
118 + RTR0PTR R0PtrMapping = ioremap(pci_resource_start(pPciDev, iRegion),
119 + pci_resource_len(pPciDev, iRegion));
120 +#else /* KERNEL_VERSION < 2.6.25 */
121 /* For now no caching, try to optimize later. */
122 RTR0PTR R0PtrMapping = ioremap_nocache(pci_resource_start(pPciDev, iRegion),
123 pci_resource_len(pPciDev, iRegion));
125 +#endif /* KERNEL_VERSION < 2.6.25 */
126 if (R0PtrMapping != NIL_RTR0PTR)
127 pIns->aRegionR0Mapping[iRegion] = R0PtrMapping;
130 +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
131 + vbpci_printk(KERN_DEBUG, pPciDev, "ioremap() failed\n");
133 vbpci_printk(KERN_DEBUG, pPciDev, "ioremap_nocache() failed\n");
135 pci_release_region(pPciDev, iRegion);
136 rc = VERR_MAP_FAILED;
138 Index: include/iprt/time.h
139 ===================================================================
140 --- include/iprt/time.h (revision 83472)
141 +++ include/iprt/time.h (revision 83473)
142 @@ -357,14 +357,18 @@
145 /* PORTME: Add struct timeval guard macro here. */
146 -#if defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
147 - || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
149 * Starting with Linux kernel version 5.6-rc3, the struct timeval is no longer
150 * available to kernel code and must not be used in kernel code.
151 * Only 64-bit time-interfaces are allowed into the kernel.
153 -# if defined(RT_OS_LINUX) && (!defined(__KERNEL__) || !defined(_LINUX_TIME64_H))
154 +#if defined(RT_OS_LINUX) && (defined(__KERNEL__) || defined(_LINUX_TIME64_H))
155 +#define RTTIME_NO_TIMEVAL
157 +#if !defined(RTTIME_NO_TIMEVAL) \
158 + && (defined(RTTIME_INCL_TIMEVAL) || defined(_STRUCT_TIMEVAL) || defined(_SYS__TIMEVAL_H_) \
159 + || defined(_SYS_TIME_H) || defined(_TIMEVAL) || defined(_LINUX_TIME_H) \
160 + || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_)))
162 * Gets the time as POSIX timeval.
166 return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec);
168 -# endif /* RT_OS_LINUX ... */
169 #endif /* various ways of detecting struct timeval */
172 Index: include/iprt/time.h
173 ===================================================================
174 --- include/iprt/time.h (revision 83483)
175 +++ include/iprt/time.h (revision 83484)
179 /* PORTME: Add struct timespec guard macro here. */
180 -#if defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
181 - || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_))
183 + * Starting with Linux kernel version 5.6-rc3, the _STRUCT_TIMESPEC is only defined
184 + * under !__KERNEL__ guard and _LINUX_TIME64_H does not define a corresponding
185 + * _STRUCT_TIMESPEC64. Only 64-bit time-interfaces are now allowed into the kernel.
186 + * We have to keep it for __KERNEL__ though to support older guest kernels (2.6.X)
187 + * without _LINUX_TIME64_H.
189 +#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H)
190 +#define RTTIME_NO_TIMESPEC
192 +#if !defined(RTTIME_NO_TIMESPEC) \
193 + && (defined(RTTIME_INCL_TIMESPEC) || defined(_STRUCT_TIMESPEC) || defined(_SYS__TIMESPEC_H_) \
194 + || defined(TIMEVAL_TO_TIMESPEC) || defined(_TIMESPEC) \
195 + || (defined(RT_OS_NETBSD) && defined(_SYS_TIME_H_)))
197 * Gets the time as POSIX timespec.
201 #endif /* various ways of detecting struct timespec */
203 -#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H)
205 - * Starting with Linux kernel version 5.6-rc3, the _STRUCT_TIMESPEC is only defined
206 - * under !__KERNEL__ guard and _LINUX_TIME64_H does not define a corresponding
207 - * _STRUCT_TIMESPEC64. Only 64-bit time-interfaces are now allowed into the kernel.
209 +#if defined(RTTIME_NO_TIMESPEC)
210 DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval)
212 return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec);
213 Index: src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c
214 ===================================================================
215 --- src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c (revision 83483)
216 +++ src/VBox/Runtime/r0drv/linux/time-r0drv-linux.c (revision 83484)
218 IPRT_LINUX_RESTORE_EFL_AC();
219 # ifdef _LINUX_TIME64_H
220 return RTTimeSpecSetTimespec64(pTime, &Ts);
223 return RTTimeSpecSetTimespec(pTime, &Ts);
228 do_gettimeofday(&Tv);