]>
Commit | Line | Data |
---|---|---|
1 | Index: include/iprt/time.h | |
2 | =================================================================== | |
3 | --- include/iprt/time.h (revision 83470) | |
4 | +++ include/iprt/time.h (revision 83471) | |
5 | @@ -359,6 +359,12 @@ | |
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_)) | |
9 | +/* | |
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. | |
13 | + */ | |
14 | +# if defined(RT_OS_LINUX) && (!defined(__KERNEL__) || !defined(_LINUX_TIME64_H)) | |
15 | /** | |
16 | * Gets the time as POSIX timeval. | |
17 | * | |
18 | @@ -392,6 +398,7 @@ | |
19 | { | |
20 | return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec); | |
21 | } | |
22 | +# endif /* RT_OS_LINUX ... */ | |
23 | #endif /* various ways of detecting struct timeval */ | |
24 | ||
25 | ||
26 | @@ -431,15 +438,19 @@ | |
27 | { | |
28 | return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimespec->tv_sec), pTimespec->tv_nsec); | |
29 | } | |
30 | +#endif /* various ways of detecting struct timespec */ | |
31 | ||
32 | - | |
33 | -# ifdef _LINUX_TIME64_H | |
34 | +#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H) | |
35 | +/* | |
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. | |
39 | + */ | |
40 | DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval) | |
41 | { | |
42 | return RTTimeSpecAddNano(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_nsec); | |
43 | } | |
44 | -# endif | |
45 | -#endif /* various ways of detecting struct timespec */ | |
46 | +#endif /* RT_OS_LINUX && _LINUX_TIME64_H */ | |
47 | ||
48 | ||
49 | ||
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. | |
56 | */ | |
57 | Assert(pMemLnxToMap->Core.enmType == RTR0MEMOBJTYPE_PHYS && !pMemLnxToMap->Core.u.Phys.fAllocated); | |
58 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) | |
59 | + /* | |
60 | + * ioremap() defaults to no caching since the 2.6 kernels. | |
61 | + * ioremap_nocache() has been removed finally in 5.6-rc1. | |
62 | + */ | |
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 */ | |
71 | if (pMemLnx->Core.pv) | |
72 | { | |
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) | |
78 | @@ -38,12 +38,24 @@ | |
79 | ||
80 | DECLINLINE(uint64_t) rtTimeGetSystemNanoTS(void) | |
81 | { | |
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) | |
84 | /* | |
85 | + * Starting with kernel version 5.6-rc3 only 64-bit time interfaces | |
86 | + * are allowed in the kernel. | |
87 | + */ | |
88 | + uint64_t u64; | |
89 | + struct timespec64 Ts = { 0, 0 }; | |
90 | + | |
91 | + ktime_get_ts64(&Ts); | |
92 | + u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec; | |
93 | + return u64; | |
94 | + | |
95 | +#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 16) /* This must match timer-r0drv-linux.c! */ | |
96 | + /* | |
97 | * Use ktime_get_ts, this is also what clock_gettime(CLOCK_MONOTONIC,) is using. | |
98 | */ | |
99 | uint64_t u64; | |
100 | - struct timespec Ts; | |
101 | + struct timespec Ts = { 0, 0 }; | |
102 | ktime_get_ts(&Ts); | |
103 | u64 = Ts.tv_sec * RT_NS_1SEC_64 + Ts.tv_nsec; | |
104 | return u64; | |
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"); | |
111 | if (!rcLnx) | |
112 | { | |
113 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) | |
114 | + /* | |
115 | + * ioremap() defaults to no caching since the 2.6 kernels. | |
116 | + * ioremap_nocache() has been removed finally in 5.6-rc1. | |
117 | + */ | |
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)); | |
124 | - | |
125 | +#endif /* KERNEL_VERSION < 2.6.25 */ | |
126 | if (R0PtrMapping != NIL_RTR0PTR) | |
127 | pIns->aRegionR0Mapping[iRegion] = R0PtrMapping; | |
128 | else | |
129 | { | |
130 | +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25) | |
131 | + vbpci_printk(KERN_DEBUG, pPciDev, "ioremap() failed\n"); | |
132 | +#else | |
133 | vbpci_printk(KERN_DEBUG, pPciDev, "ioremap_nocache() failed\n"); | |
134 | +#endif | |
135 | pci_release_region(pPciDev, iRegion); | |
136 | rc = VERR_MAP_FAILED; | |
137 | } | |
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 @@ | |
143 | ||
144 | ||
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_)) | |
148 | /* | |
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. | |
152 | */ | |
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 | |
156 | +#endif | |
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_))) | |
161 | /** | |
162 | * Gets the time as POSIX timeval. | |
163 | * | |
164 | @@ -398,7 +402,6 @@ | |
165 | { | |
166 | return RTTimeSpecAddMicro(RTTimeSpecSetSeconds(pTime, pTimeval->tv_sec), pTimeval->tv_usec); | |
167 | } | |
168 | -# endif /* RT_OS_LINUX ... */ | |
169 | #endif /* various ways of detecting struct timeval */ | |
170 | ||
171 | ||
172 | Index: include/iprt/time.h | |
173 | =================================================================== | |
174 | --- include/iprt/time.h (revision 83483) | |
175 | +++ include/iprt/time.h (revision 83484) | |
176 | @@ -406,8 +406,20 @@ | |
177 | ||
178 | ||
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_)) | |
182 | +/* | |
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. | |
188 | + */ | |
189 | +#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H) | |
190 | +#define RTTIME_NO_TIMESPEC | |
191 | +#endif | |
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_))) | |
196 | /** | |
197 | * Gets the time as POSIX timespec. | |
198 | * | |
199 | @@ -443,12 +455,7 @@ | |
200 | } | |
201 | #endif /* various ways of detecting struct timespec */ | |
202 | ||
203 | -#if defined(RT_OS_LINUX) && defined(_LINUX_TIME64_H) | |
204 | -/* | |
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. | |
208 | - */ | |
209 | +#if defined(RTTIME_NO_TIMESPEC) | |
210 | DECLINLINE(PRTTIMESPEC) RTTimeSpecSetTimespec64(PRTTIMESPEC pTime, const struct timespec64 *pTimeval) | |
211 | { | |
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) | |
217 | @@ -194,9 +194,9 @@ | |
218 | IPRT_LINUX_RESTORE_EFL_AC(); | |
219 | # ifdef _LINUX_TIME64_H | |
220 | return RTTimeSpecSetTimespec64(pTime, &Ts); | |
221 | -#else | |
222 | +# else | |
223 | return RTTimeSpecSetTimespec(pTime, &Ts); | |
224 | -#endif | |
225 | +# endif | |
226 | #else /* < 2.6.16 */ | |
227 | struct timeval Tv; | |
228 | do_gettimeofday(&Tv); |