hc
2024-10-12 a5969cabbb4660eab42b6ef0412cbbd1200cf14d
kernel/arch/x86/include/asm/vdso/gettimeofday.h
....@@ -18,10 +18,10 @@
1818 #include <asm/unistd.h>
1919 #include <asm/msr.h>
2020 #include <asm/pvclock.h>
21
-#include <asm/mshyperv.h>
22
-#include <linux/compat_time.h>
21
+#include <clocksource/hyperv_timer.h>
2322
2423 #define __vdso_data (VVAR(_vdso_data))
24
+#define __timens_vdso_data (TIMENS(_vdso_data))
2525
2626 #define VDSO_HAS_TIME 1
2727
....@@ -52,9 +52,16 @@
5252 __attribute__((visibility("hidden")));
5353 #endif
5454
55
-#ifdef CONFIG_HYPERV_TSCPAGE
55
+#ifdef CONFIG_HYPERV_TIMER
5656 extern struct ms_hyperv_tsc_page hvclock_page
5757 __attribute__((visibility("hidden")));
58
+#endif
59
+
60
+#ifdef CONFIG_TIME_NS
61
+static __always_inline const struct vdso_data *__arch_get_timens_vdso_data(void)
62
+{
63
+ return __timens_vdso_data;
64
+}
5865 #endif
5966
6067 #ifndef BUILD_VDSO32
....@@ -97,8 +104,6 @@
97104
98105 #else
99106
100
-#define VDSO_HAS_32BIT_FALLBACK 1
101
-
102107 static __always_inline
103108 long clock_gettime_fallback(clockid_t _clkid, struct __kernel_timespec *_ts)
104109 {
....@@ -110,7 +115,7 @@
110115 "call __kernel_vsyscall \n"
111116 "mov %%edx, %%ebx \n"
112117 : "=a" (ret), "=m" (*_ts)
113
- : "0" (__NR_clock_gettime), [clock] "g" (_clkid), "c" (_ts)
118
+ : "0" (__NR_clock_gettime64), [clock] "g" (_clkid), "c" (_ts)
114119 : "edx");
115120
116121 return ret;
....@@ -162,7 +167,7 @@
162167 "call __kernel_vsyscall \n"
163168 "mov %%edx, %%ebx \n"
164169 : "=a" (ret), "=m" (*_ts)
165
- : "0" (__NR_clock_getres), [clock] "g" (_clkid), "c" (_ts)
170
+ : "0" (__NR_clock_getres_time64), [clock] "g" (_clkid), "c" (_ts)
166171 : "edx");
167172
168173 return ret;
....@@ -229,16 +234,17 @@
229234 }
230235 #endif
231236
232
-#ifdef CONFIG_HYPERV_TSCPAGE
237
+#ifdef CONFIG_HYPERV_TIMER
233238 static u64 vread_hvclock(void)
234239 {
235240 return hv_read_tsc_page(&hvclock_page);
236241 }
237242 #endif
238243
239
-static inline u64 __arch_get_hw_counter(s32 clock_mode)
244
+static inline u64 __arch_get_hw_counter(s32 clock_mode,
245
+ const struct vdso_data *vd)
240246 {
241
- if (clock_mode == VCLOCK_TSC)
247
+ if (likely(clock_mode == VDSO_CLOCKMODE_TSC))
242248 return (u64)rdtsc_ordered();
243249 /*
244250 * For any memory-mapped vclock type, we need to make sure that gcc
....@@ -247,13 +253,13 @@
247253 * question isn't enabled, which will segfault. Hence the barriers.
248254 */
249255 #ifdef CONFIG_PARAVIRT_CLOCK
250
- if (clock_mode == VCLOCK_PVCLOCK) {
256
+ if (clock_mode == VDSO_CLOCKMODE_PVCLOCK) {
251257 barrier();
252258 return vread_pvclock();
253259 }
254260 #endif
255
-#ifdef CONFIG_HYPERV_TSCPAGE
256
- if (clock_mode == VCLOCK_HVCLOCK) {
261
+#ifdef CONFIG_HYPERV_TIMER
262
+ if (clock_mode == VDSO_CLOCKMODE_HVCLOCK) {
257263 barrier();
258264 return vread_hvclock();
259265 }
....@@ -266,6 +272,24 @@
266272 return __vdso_data;
267273 }
268274
275
+static inline bool arch_vdso_clocksource_ok(const struct vdso_data *vd)
276
+{
277
+ return true;
278
+}
279
+#define vdso_clocksource_ok arch_vdso_clocksource_ok
280
+
281
+/*
282
+ * Clocksource read value validation to handle PV and HyperV clocksources
283
+ * which can be invalidated asynchronously and indicate invalidation by
284
+ * returning U64_MAX, which can be effectively tested by checking for a
285
+ * negative value after casting it to s64.
286
+ */
287
+static inline bool arch_vdso_cycles_ok(u64 cycles)
288
+{
289
+ return (s64)cycles >= 0;
290
+}
291
+#define vdso_cycles_ok arch_vdso_cycles_ok
292
+
269293 /*
270294 * x86 specific delta calculation.
271295 *