Commit 1628f6a7 authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Thomas Gleixner
Browse files

sparc64: vdso: Implement clock_gettime64()



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: default avatarThomas Weißschuh <thomas.weissschuh@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@kernel.org>
Tested-by: default avatarAndreas Larsson <andreas@gaisler.com>
Reviewed-by: default avatarAndreas Larsson <andreas@gaisler.com>
Acked-by: default avatarAndreas Larsson <andreas@gaisler.com>
Link: https://patch.msgid.link/20260304-vdso-sparc64-generic-2-v6-13-d8eb3b0e1410@linutronix.de
parent 168d23e5
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -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)
+8 −0
Original line number Diff line number Diff line
@@ -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
+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ VERSION {
	global:
		clock_gettime;
		__vdso_clock_gettime;
		clock_gettime64;
		__vdso_clock_gettime64;
		gettimeofday;
		__vdso_gettimeofday;
	local: *;