Commit 7c5fc16c authored by Thomas Weißschuh's avatar Thomas Weißschuh Committed by Thomas Gleixner
Browse files

sparc64: vdso: Switch to the generic vDSO library



The generic vDSO provides a lot common functionality shared between
different architectures. SPARC is the last architecture not using it,
preventing some necessary code cleanup.

Make use of the generic infrastructure.

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-10-d8eb3b0e1410@linutronix.de
parent e13e3059
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -104,7 +104,6 @@ config SPARC64
	select ARCH_USE_QUEUED_RWLOCKS
	select ARCH_USE_QUEUED_SPINLOCKS
	select GENERIC_TIME_VSYSCALL
	select ARCH_CLOCKSOURCE_DATA
	select ARCH_HAS_PTE_SPECIAL
	select PCI_DOMAINS if PCI
	select ARCH_HAS_GIGANTIC_PAGE
@@ -115,6 +114,8 @@ config SPARC64
	select ARCH_SUPPORTS_SCHED_SMT if SMP
	select ARCH_SUPPORTS_SCHED_MC  if SMP
	select ARCH_HAS_LAZY_MMU_MODE
	select HAVE_GENERIC_VDSO
	select GENERIC_GETTIMEOFDAY

config ARCH_PROC_KCORE_TEXT
	def_bool y
+0 −9
Original line number Diff line number Diff line
@@ -5,13 +5,4 @@
#ifndef _ASM_SPARC_CLOCKSOURCE_H
#define _ASM_SPARC_CLOCKSOURCE_H

/* VDSO clocksources */
#define VCLOCK_NONE   0  /* Nothing userspace can do. */
#define VCLOCK_TICK   1  /* Use %tick.  */
#define VCLOCK_STICK  2  /* Use %stick. */

struct arch_clocksource_data {
	int vclock_mode;
};

#endif /* _ASM_SPARC_CLOCKSOURCE_H */
+10 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_VDSO_CLOCKSOURCE_H
#define __ASM_VDSO_CLOCKSOURCE_H

/* VDSO clocksources */
#define VDSO_ARCH_CLOCKMODES	\
	VDSO_CLOCKMODE_TICK,	\
	VDSO_CLOCKMODE_STICK

#endif /* __ASM_VDSO_CLOCKSOURCE_H */
+49 −9
Original line number Diff line number Diff line
@@ -9,15 +9,14 @@
#include <uapi/linux/time.h>
#include <uapi/linux/unistd.h>

#include <vdso/align.h>
#include <vdso/clocksource.h>
#include <vdso/datapage.h>
#include <vdso/page.h>

#include <linux/types.h>
#include <asm/vvar.h>

#ifdef	CONFIG_SPARC64
static __always_inline u64 vdso_shift_ns(u64 val, u32 amt)
{
	return val >> amt;
}

static __always_inline u64 vread_tick(void)
{
	u64	ret;
@@ -48,6 +47,7 @@ static __always_inline u64 vdso_shift_ns(u64 val, u32 amt)
			     : "g1");
	return ret;
}
#define vdso_shift_ns vdso_shift_ns

static __always_inline u64 vread_tick(void)
{
@@ -70,9 +70,9 @@ static __always_inline u64 vread_tick_stick(void)
}
#endif

static __always_inline u64 __arch_get_hw_counter(struct vvar_data *vvar)
static __always_inline u64 __arch_get_hw_counter(s32 clock_mode, const struct vdso_time_data *vd)
{
	if (likely(vvar->vclock_mode == VCLOCK_STICK))
	if (likely(clock_mode == VDSO_CLOCKMODE_STICK))
		return vread_tick_stick();
	else
		return vread_tick();
@@ -102,7 +102,7 @@ static __always_inline u64 __arch_get_hw_counter(struct vvar_data *vvar)
	"cc", "memory"

static __always_inline
long clock_gettime_fallback(clockid_t clock, struct __kernel_old_timespec *ts)
long clock_gettime_fallback(clockid_t clock, struct __kernel_timespec *ts)
{
	register long num __asm__("g1") = __NR_clock_gettime;
	register long o0 __asm__("o0") = clock;
@@ -113,6 +113,20 @@ long clock_gettime_fallback(clockid_t clock, struct __kernel_old_timespec *ts)
	return o0;
}

#ifndef CONFIG_SPARC64
static __always_inline
long clock_gettime32_fallback(clockid_t clock, struct old_timespec32 *ts)
{
	register long num __asm__("g1") = __NR_clock_gettime;
	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;
}
#endif

static __always_inline
long gettimeofday_fallback(struct __kernel_old_timeval *tv, struct timezone *tz)
{
@@ -125,4 +139,30 @@ long gettimeofday_fallback(struct __kernel_old_timeval *tv, struct timezone *tz)
	return o0;
}

static __always_inline const struct vdso_time_data *__arch_get_vdso_u_time_data(void)
{
	unsigned long ret;

	/*
	 * SPARC does not support native PC-relative code relocations.
	 * Calculate the address manually, works for 32 and 64 bit code.
	 */
	__asm__ __volatile__(
		"1:\n"
		"call 3f\n"                     // Jump over the embedded data and set up %o7
		"nop\n"                         // Delay slot
		"2:\n"
		".word vdso_u_time_data - .\n"  // Embedded offset to external symbol
		"3:\n"
		"add %%o7, 2b - 1b, %%o7\n"     // Point %o7 to the embedded offset
		"ldsw [%%o7], %0\n"             // Load the offset
		"add %0, %%o7, %0\n"            // Calculate the absolute address
		: "=r" (ret)
		:
		: "o7");

	return (const struct vdso_time_data *)ret;
}
#define __arch_get_vdso_u_time_data __arch_get_vdso_u_time_data

#endif /* _ASM_SPARC_VDSO_GETTIMEOFDAY_H */
+10 −0
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 */

#ifndef _ASM_SPARC_VDSO_VSYSCALL_H
#define _ASM_SPARC_VDSO_VSYSCALL_H

#define __VDSO_PAGES 4

#include <asm-generic/vdso/vsyscall.h>

#endif /* _ASM_SPARC_VDSO_VSYSCALL_H */
Loading