From nobody Thu Oct 2 12:06:47 2025 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3543E2EC555; Wed, 17 Sep 2025 14:02:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758117740; cv=none; b=qJx48xWZ9fNx5ZMq8Nas4JS0KJEZzDtUAkzIuVSMtIFqhRV5MLsrgyWFXfpx+DxIpcQyT3OaoTanhEsSfHh0nPGDaZ3ZQSyXPppykjG9fGq9zvhHpZDmIr+KAA61aCUlQu82kRiDaXBBwKjyxUgHhnzeHd4MJ4tnop3bRXVo2DQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758117740; c=relaxed/simple; bh=zqG3ZhrWjvVQygDuISThwjO4RZY1Wh1EOCm6935wGyA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uVRY1K7TNIjC9HK+TsNTDh9d2s89YUZM1fG/Cglv3DhRz7V3h2ORslE6rf9zpm+AYNfr+K/bDiQcZ+Gwjt2faxnZO6d2QBxhPkk1BDSyTczQo6o9NSWYRVYv96MIASvEGe1kFcmmXG7PjfePilBFx7eZVN4ktykDPuoBgJhnMwI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=VPK3S01/; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=yyCLK3S2; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="VPK3S01/"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="yyCLK3S2" From: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1758117730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3fcUtqAqNq9zNiLfjOOqbPQxTHmRKJGS3uRsgVVJuxY=; b=VPK3S01/QaDX/NS/zo1/c4gDC9wIVwGh6De1Qlk4ykm+ASR/in5965WbpYo62ao6Nsy3cp RxVyvbl/Etu2IcgRfdDY4fi6u9TuC/qFQSVtMZG3JNKZsN90sbreV36D38RF8dkVpLlaZ0 PCdGvXZSANZZY8Zmrlsfl8rwaBXsqxS5T1WZV/iJOv0ul74/c6bBJVt125SOyiNPDKtU/n ZW4Ofh2L/XrJR8geK0d8zodRMPAEZHoW3FTROJe9P0qPvF2YrCGHaqA8dgMaQ+JbSNqsEy oyaDT1VT27QjBA1o9PBjhQJHjWijkXhw3tYnehFBavu9ViwY1qgvqaEFfA6R9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1758117730; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3fcUtqAqNq9zNiLfjOOqbPQxTHmRKJGS3uRsgVVJuxY=; b=yyCLK3S2mTypQaeGyNuOl4/z3RtLi9bgb2hvsyVXfiFYJMSxgcxgvrfpDPJ8YdUZMOcx0j LUnJaja51g6qZmDw== Date: Wed, 17 Sep 2025 16:00:31 +0200 Subject: [PATCH v3 29/36] sparc64: vdso: Move syscall fallbacks into header Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250917-vdso-sparc64-generic-2-v3-29-3679b1bc8ee8@linutronix.de> References: <20250917-vdso-sparc64-generic-2-v3-0-3679b1bc8ee8@linutronix.de> In-Reply-To: <20250917-vdso-sparc64-generic-2-v3-0-3679b1bc8ee8@linutronix.de> To: Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Arnd Bergmann , "David S. Miller" , Andreas Larsson , Nick Alcock , John Stultz , Stephen Boyd , John Paul Adrian Glaubitz , Shuah Khan , Catalin Marinas , Will Deacon , Theodore Ts'o , "Jason A. Donenfeld" , Russell King , Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , Christophe Leroy , Huacai Chen , WANG Xuerui , Thomas Bogendoerfer , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Nagarathnam Muthusamy , Shannon Nelson Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linux-s390@vger.kernel.org, =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Developer-Signature: v=1; a=ed25519-sha256; t=1758117712; l=5693; i=thomas.weissschuh@linutronix.de; s=20240209; h=from:subject:message-id; bh=zqG3ZhrWjvVQygDuISThwjO4RZY1Wh1EOCm6935wGyA=; b=qYy+GeQpBEot2Sl4R/HherZP07TDdJoXLOp73A4M4DUW77/qDoG8u0NEHu1aM1qHuiJMf0vNB CR+qmzhho1RBW2HRTOOgQ+S6eh8TkioRAPnlX3k/CHs5lD5WFv4+h9d X-Developer-Key: i=thomas.weissschuh@linutronix.de; a=ed25519; pk=pfvxvpFUDJV2h2nY0FidLUml22uGLSjByFbM6aqQQws= The generic vDSO libraries expected the syscall fallbacks in asm/vdso/gettimeofday.h. To prepare the adoption of the generic library, move the existing functions there. While at it, rename them so they match what the generic library expects. Signed-off-by: Thomas Wei=C3=9Fschuh --- arch/sparc/include/asm/vdso/gettimeofday.h | 50 ++++++++++++++++++++++++++= +++ arch/sparc/vdso/vclock_gettime.c | 51 ++------------------------= ---- 2 files changed, 52 insertions(+), 49 deletions(-) diff --git a/arch/sparc/include/asm/vdso/gettimeofday.h b/arch/sparc/includ= e/asm/vdso/gettimeofday.h index 31f6505d3ab5dde9e02eca6da9182e5fb91031c4..429dc080568f59145cc0bc69606= 0adeb60ac177a 100644 --- a/arch/sparc/include/asm/vdso/gettimeofday.h +++ b/arch/sparc/include/asm/vdso/gettimeofday.h @@ -6,6 +6,9 @@ #ifndef _ASM_SPARC_VDSO_GETTIMEOFDAY_H #define _ASM_SPARC_VDSO_GETTIMEOFDAY_H =20 +#include +#include + #include #include =20 @@ -75,4 +78,51 @@ static __always_inline u64 __arch_get_hw_counter(struct = vvar_data *vvar) return vread_tick(); } =20 +#ifdef CONFIG_SPARC64 +#define SYSCALL_STRING \ + "ta 0x6d;" \ + "bcs,a 1f;" \ + " sub %%g0, %%o0, %%o0;" \ + "1:" +#else +#define SYSCALL_STRING \ + "ta 0x10;" \ + "bcs,a 1f;" \ + " sub %%g0, %%o0, %%o0;" \ + "1:" +#endif + +#define SYSCALL_CLOBBERS \ + "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ + "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ + "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \ + "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \ + "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \ + "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", \ + "cc", "memory" + +static __always_inline +long clock_gettime_fallback(clockid_t clock, struct __kernel_old_timespec = *ts) +{ + register long num __asm__("g1") =3D __NR_clock_gettime; + register long o0 __asm__("o0") =3D clock; + register long o1 __asm__("o1") =3D (long) ts; + + __asm__ __volatile__(SYSCALL_STRING : "=3Dr" (o0) : "r" (num), + "0" (o0), "r" (o1) : SYSCALL_CLOBBERS); + return o0; +} + +static __always_inline +long gettimeofday_fallback(struct __kernel_old_timeval *tv, struct timezon= e *tz) +{ + register long num __asm__("g1") =3D __NR_gettimeofday; + register long o0 __asm__("o0") =3D (long) tv; + register long o1 __asm__("o1") =3D (long) tz; + + __asm__ __volatile__(SYSCALL_STRING : "=3Dr" (o0) : "r" (num), + "0" (o0), "r" (o1) : SYSCALL_CLOBBERS); + return o0; +} + #endif /* _ASM_SPARC_VDSO_GETTIMEOFDAY_H */ diff --git a/arch/sparc/vdso/vclock_gettime.c b/arch/sparc/vdso/vclock_gett= ime.c index 16ac80982a00b9f965453b89a0cc111312baa9b2..e768c0b84b3420deab2f7433589= 2d40a5b515ee7 100644 --- a/arch/sparc/vdso/vclock_gettime.c +++ b/arch/sparc/vdso/vclock_gettime.c @@ -13,38 +13,13 @@ */ =20 #include -#include #include #include -#include #include #include #include #include =20 -#ifdef CONFIG_SPARC64 -#define SYSCALL_STRING \ - "ta 0x6d;" \ - "bcs,a 1f;" \ - " sub %%g0, %%o0, %%o0;" \ - "1:" -#else -#define SYSCALL_STRING \ - "ta 0x10;" \ - "bcs,a 1f;" \ - " sub %%g0, %%o0, %%o0;" \ - "1:" -#endif - -#define SYSCALL_CLOBBERS \ - "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", \ - "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", \ - "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", \ - "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31", \ - "f32", "f34", "f36", "f38", "f40", "f42", "f44", "f46", \ - "f48", "f50", "f52", "f54", "f56", "f58", "f60", "f62", \ - "cc", "memory" - /* * Compute the vvar page's address in the process address space, and retur= n it * as a pointer to the vvar_data. @@ -64,28 +39,6 @@ notrace static __always_inline struct vvar_data *get_vva= r_data(void) return (struct vvar_data *) ret; } =20 -notrace static long vdso_fallback_gettime(long clock, struct __kernel_old_= timespec *ts) -{ - register long num __asm__("g1") =3D __NR_clock_gettime; - register long o0 __asm__("o0") =3D clock; - register long o1 __asm__("o1") =3D (long) ts; - - __asm__ __volatile__(SYSCALL_STRING : "=3Dr" (o0) : "r" (num), - "0" (o0), "r" (o1) : SYSCALL_CLOBBERS); - return o0; -} - -notrace static long vdso_fallback_gettimeofday(struct __kernel_old_timeval= *tv, struct timezone *tz) -{ - register long num __asm__("g1") =3D __NR_gettimeofday; - register long o0 __asm__("o0") =3D (long) tv; - register long o1 __asm__("o1") =3D (long) tz; - - __asm__ __volatile__(SYSCALL_STRING : "=3Dr" (o0) : "r" (num), - "0" (o0), "r" (o1) : SYSCALL_CLOBBERS); - return o0; -} - notrace static __always_inline u64 vgetsns(struct vvar_data *vvar) { u64 v; @@ -184,7 +137,7 @@ __vdso_clock_gettime(clockid_t clock, struct __kernel_o= ld_timespec *ts) /* * Unknown clock ID ? Fall back to the syscall. */ - return vdso_fallback_gettime(clock, ts); + return clock_gettime_fallback(clock, ts); } int clock_gettime(clockid_t, struct __kernel_old_timespec *) @@ -220,7 +173,7 @@ __vdso_gettimeofday(struct __kernel_old_timeval *tv, st= ruct timezone *tz) } return 0; } - return vdso_fallback_gettimeofday(tv, tz); + return gettimeofday_fallback(tv, tz); } int gettimeofday(struct __kernel_old_timeval *, struct timezone *) --=20 2.51.0