]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sparc64: vdso: Implement clock_gettime64()
authorThomas Weißschuh <thomas.weissschuh@linutronix.de>
Wed, 4 Mar 2026 07:49:10 +0000 (08:49 +0100)
committerThomas Gleixner <tglx@kernel.org>
Wed, 11 Mar 2026 09:18:33 +0000 (10:18 +0100)
To be y2038-safe, 32-bit userspace needs to explicitly call the 64-bit safe
time APIs.

Implement clock_gettime64() in the 32-bit vDSO.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Tested-by: Andreas Larsson <andreas@gaisler.com>
Reviewed-by: Andreas Larsson <andreas@gaisler.com>
Acked-by: Andreas Larsson <andreas@gaisler.com>
Link: https://patch.msgid.link/20260304-vdso-sparc64-generic-2-v6-13-d8eb3b0e1410@linutronix.de
arch/sparc/include/asm/vdso/gettimeofday.h
arch/sparc/vdso/vclock_gettime.c
arch/sparc/vdso/vdso32/vdso32.lds.S

index a35875fba45470ba961a7df3ae52bc17d2a4a4a0..b0c80c8a28bb71e16398ab38904ba826457ac71d 100644 (file)
@@ -101,6 +101,8 @@ static __always_inline u64 __arch_get_hw_counter(s32 clock_mode, const struct vd
        "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62",         \
        "cc", "memory"
 
+#ifdef CONFIG_SPARC64
+
 static __always_inline
 long clock_gettime_fallback(clockid_t clock, struct __kernel_timespec *ts)
 {
@@ -113,7 +115,20 @@ long clock_gettime_fallback(clockid_t clock, struct __kernel_timespec *ts)
        return o0;
 }
 
-#ifndef CONFIG_SPARC64
+#else /* !CONFIG_SPARC64 */
+
+static __always_inline
+long clock_gettime_fallback(clockid_t clock, struct __kernel_timespec *ts)
+{
+       register long num __asm__("g1") = __NR_clock_gettime64;
+       register long o0 __asm__("o0") = clock;
+       register long o1 __asm__("o1") = (long) ts;
+
+       __asm__ __volatile__(SYSCALL_STRING : "=r" (o0) : "r" (num),
+                            "0" (o0), "r" (o1) : SYSCALL_CLOBBERS);
+       return o0;
+}
+
 static __always_inline
 long clock_gettime32_fallback(clockid_t clock, struct old_timespec32 *ts)
 {
@@ -125,7 +140,8 @@ long clock_gettime32_fallback(clockid_t clock, struct old_timespec32 *ts)
                             "0" (o0), "r" (o1) : SYSCALL_CLOBBERS);
        return o0;
 }
-#endif
+
+#endif /* CONFIG_SPARC64 */
 
 static __always_inline
 long gettimeofday_fallback(struct __kernel_old_timeval *tv, struct timezone *tz)
index 093a7ff4dafce1cf0af5af4c303bef86e159858a..1d9859392e4cfd285349cf9155ca1fc25d3a7b41 100644 (file)
@@ -48,4 +48,12 @@ int __vdso_clock_gettime(clockid_t clock, struct old_timespec32 *ts)
 int clock_gettime(clockid_t, struct old_timespec32 *)
        __weak __alias(__vdso_clock_gettime);
 
+int __vdso_clock_gettime64(clockid_t clock, struct __kernel_timespec *ts)
+{
+       return __cvdso_clock_gettime(clock, ts);
+}
+
+int clock_gettime64(clockid_t, struct __kernel_timespec *)
+       __weak __alias(__vdso_clock_gettime64);
+
 #endif
index 53575ee154c492f9503efdd8f995ac2a035203c7..a14e4f77e6f2222b855df27cc7a0d0a4f98bd4ac 100644 (file)
@@ -17,6 +17,8 @@ VERSION {
        global:
                clock_gettime;
                __vdso_clock_gettime;
+               clock_gettime64;
+               __vdso_clock_gettime64;
                gettimeofday;
                __vdso_gettimeofday;
        local: *;