From patchwork Tue Dec 17 21:47:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 1211748 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108164-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="EImJzFGs"; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="RCovwVcM"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47csFS3Pjhz9sRC for ; Wed, 18 Dec 2019 08:47:55 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=juIgm3RZ1mL14DiaaG0VT2Xnd8puETcMc3pIiUa26pjt+Tch0Kf3i xBfmSiiTh43m7bfxAVdlDDRkacxw2tkcUbPC+ykWKiIKzLU1hXTxev+LHZA+BTU0 /oHWfNgXROiyI6vX5URanKerQvmvDOrHYDdjHDk8k3hwZVdbHn5D+U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=s9+6BQuaDd60knysckFoueYlUow=; b=EImJzFGs980+ySmHO61dRESdmPg0 Lq4CBit6mpnW4AiJzKPAYixt3p5dI+gABENwLCvw+D0pnI05Tf21InZROlKbpQ/K vzD7MGm6OrVhfssM46TDMLw9HvPJk9h8E4UfhH01/cwOVi7IVNpE8SaM81EedAr7 2aRaG7jbmVKsUpg= Received: (qmail 109476 invoked by alias); 17 Dec 2019 21:47:40 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 109410 invoked by uid 89); 17 Dec 2019 21:47:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=1822, inline_vsyscall, sysdepvdsoh, INLINE_VSYSCALL X-HELO: mail-pl1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=kIHlcsXGLCcPQnKGQWbOLUsjqn84Fl8/BNjdtDz1aCY=; b=RCovwVcMEAdhEO/9+gBaZVDgWLqCbHNJQfZsa14AIY8JA2igAJmiiZRm5NCNSP2QvL OUQWtrZTRDq+tUZZhYRlxn2b4/9RuAlHnWdBrD+6B1iJ18MCKNUnc+xr+2UarFxXChs6 lMTeHvfyJZNqfK1mdC5UeF4qNFKcZPhtXOYu90FoPWAnJHOZWNAiQToNoKDfUITSMUpi xlGHGF2NdK31jpAbmURzVkeanHelYU0BXdNpcnj/gCrUFtuNiijDw6+wCdHc2beGs+0Z TnUwk2aBUoHXvmdzHbPbAJTOjNXlqBTBAot6JzaeJOhRLWtvXkRYOYrToObuRa9BXSG1 NRPw== From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 01/16] linux: Fix vDSO macros build with time64 interfaces Date: Tue, 17 Dec 2019 18:47:13 -0300 Message-Id: <20191217214728.2886-1-adhemerval.zanella@linaro.org> Changes from previous version: - Reinstate syscall fallback on INLINE_VSYSCALL, it simplifies when the macro is used multiple times (as for clock_gettime and clock_getres). Reviewed-by: Siddhesh Poyarekar --- As indicated on libc-help [1] the ec138c67cb commit broke 32-bit builds when configured with --enable-kernel=5.1 or higher. The scenario 10 from [2] might also occur in this configuration and INLINE_VSYSCALL will try to use the vDSO symbol and HAVE_CLOCK_GETTIME64_VSYSCALL does not set HAVE_VSYSCALL prior its usage. Also, there is no easy way to just enable the code to use one vDSO sysmbo since the macro INLINE_VSYSCALL is redefined if HAVE_VSYSCALL is set. Instead of adding more pre-processor handling and making the code even more convoluted, this patch removes the requirement of defining HAVE_VSYSCALL before including sysdep-vdso.h to enable vDSO usage. The INLINE_VSYSCALL is now expected to be issued inside a HAVE_*_VSYSCALL check, since it will try to use the internal vDSO pointers. Both clock_getres and clock_gettime vDSO code for time64_t were removed since there is no vDSO setup code for the symbol (an architecture can not set HAVE_CLOCK_GETTIME64_VSYSCALL). Checked on i686-linux-gnu (default and with --enable-kernel=5.1), x86_64-linux-gnu, aarch64-linux-gnu, and powerpc64le-linux-gnu. I also checked against a build to mips64-linux-gnu and sparc64-linux-gnu. [1] https://sourceware.org/ml/libc-help/2019-12/msg00014.html --- .../unix/sysv/linux/aarch64/gettimeofday.c | 4 -- sysdeps/unix/sysv/linux/clock_getres.c | 36 +++++++++++------- sysdeps/unix/sysv/linux/clock_gettime.c | 38 +++++++++++-------- sysdeps/unix/sysv/linux/getcpu.c | 9 +---- .../unix/sysv/linux/powerpc/gettimeofday.c | 4 -- sysdeps/unix/sysv/linux/powerpc/time.c | 4 -- sysdeps/unix/sysv/linux/sched_getcpu.c | 15 +++----- sysdeps/unix/sysv/linux/sysdep-vdso.h | 34 +---------------- sysdeps/unix/sysv/linux/x86/gettimeofday.c | 4 -- sysdeps/unix/sysv/linux/x86/time.c | 8 ++-- 10 files changed, 58 insertions(+), 98 deletions(-) diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c index 7e772e05ce..143c5c1507 100644 --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c @@ -22,10 +22,6 @@ #include #include - -#ifdef HAVE_GETTIMEOFDAY_VSYSCALL -# define HAVE_VSYSCALL -#endif #include /* Used as a fallback in the ifunc resolver if VDSO is not available diff --git a/sysdeps/unix/sysv/linux/clock_getres.c b/sysdeps/unix/sysv/linux/clock_getres.c index 9497f78787..52671fa641 100644 --- a/sysdeps/unix/sysv/linux/clock_getres.c +++ b/sysdeps/unix/sysv/linux/clock_getres.c @@ -20,9 +20,6 @@ #include #include -#ifdef HAVE_CLOCK_GETRES_VSYSCALL -# define HAVE_VSYSCALL -#endif #include #include #include @@ -32,23 +29,34 @@ int __clock_getres64 (clockid_t clock_id, struct __timespec64 *res) { #ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_clock_getres_time64 - return INLINE_VSYSCALL (clock_getres, 2, clock_id, res); + /* 64 bit ABIs or Newer 32-bit ABIs that only support 64-bit time_t. */ +# ifdef __NR_clock_getres_time64 + return INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res); # else - return INLINE_SYSCALL (clock_getres_time64, 2, clock_id, res); +# ifdef HAVE_CLOCK_GETRES_VSYSCALL + return INLINE_VSYSCALL (clock_getres, 2, clock_id, res); +# else + return INLINE_SYSCALL_CALL (clock_getres, clock_id, res); +# endif # endif #else + int r; + /* Old 32-bit ABI with possible 64-bit time_t support. */ # ifdef __NR_clock_getres_time64 - int ret = INLINE_SYSCALL (clock_getres_time64, 2, clock_id, res); - if (ret == 0 || errno != ENOSYS) - return ret; + r = INLINE_SYSCALL_CALL (clock_getres_time64, clock_id, res); + if (r == 0 || errno != ENOSYS) + return r; # endif + /* Fallback code that uses 32-bit support. */ struct timespec ts32; - int retval = INLINE_VSYSCALL (clock_getres, 2, clock_id, &ts32); - if (! retval && res) +# ifdef HAVE_CLOCK_GETRES_VSYSCALL + r = INLINE_VSYSCALL (clock_getres, 2, clock_id, &ts32); +# else + r = INLINE_SYSCALL_CALL (clock_getres, clock_id, &ts32); +# endif + if (r == 0) *res = valid_timespec_to_timespec64 (ts32); - - return retval; + return r; #endif } @@ -60,7 +68,7 @@ __clock_getres (clockid_t clock_id, struct timespec *res) int retval; retval = __clock_getres64 (clock_id, &ts64); - if (! retval && res) + if (retval == 0 && res != NULL) *res = valid_timespec64_to_timespec (ts64); return retval; diff --git a/sysdeps/unix/sysv/linux/clock_gettime.c b/sysdeps/unix/sysv/linux/clock_gettime.c index 875c4fe905..e895812704 100644 --- a/sysdeps/unix/sysv/linux/clock_gettime.c +++ b/sysdeps/unix/sysv/linux/clock_gettime.c @@ -21,10 +21,6 @@ #include #include #include "kernel-posix-cpu-timers.h" - -#ifdef HAVE_CLOCK_GETTIME_VSYSCALL -# define HAVE_VSYSCALL -#endif #include #include @@ -34,22 +30,34 @@ int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) { #ifdef __ASSUME_TIME64_SYSCALLS -# ifndef __NR_clock_gettime64 -# define __NR_clock_gettime64 __NR_clock_gettime -# define __vdso_clock_gettime64 __vdso_clock_gettime + /* 64 bit ABIs or Newer 32-bit ABIs that only support 64-bit time_t. */ +# ifdef __NR_clock_gettime64 + return INLINE_SYSCALL_CALL (clock_gettime64, clock_id, tp); +# else +# ifdef HAVE_CLOCK_GETTIME_VSYSCALL + return INLINE_VSYSCALL (clock_gettime, 2, clock_id, tp); +# else + return INLINE_SYSCALL_CALL (clock_gettime, clock_id, tp); +# endif # endif - return INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); #else -# if defined HAVE_CLOCK_GETTIME64_VSYSCALL - int ret64 = INLINE_VSYSCALL (clock_gettime64, 2, clock_id, tp); - if (ret64 == 0 || errno != ENOSYS) - return ret64; + int r; + /* Old 32-bit ABI with possible 64-bit time_t support. */ +# ifdef __NR_clock_gettime64 + r = INLINE_SYSCALL_CALL (clock_gettime64, clock_id, tp); + if (r == 0 || errno != ENOSYS) + return r; # endif + /* Fallback code that uses 32-bit support. */ struct timespec tp32; - int ret = INLINE_VSYSCALL (clock_gettime, 2, clock_id, &tp32); - if (ret == 0) +# ifdef HAVE_CLOCK_GETTIME_VSYSCALL + r = INLINE_VSYSCALL (clock_gettime, 2, clock_id, &tp32); +# else + r = INLINE_SYSCALL_CALL (clock_gettime, clock_id, &tp32); +# endif + if (r == 0) *tp = valid_timespec_to_timespec64 (tp32); - return ret; + return r; #endif } diff --git a/sysdeps/unix/sysv/linux/getcpu.c b/sysdeps/unix/sysv/linux/getcpu.c index fdd27203af..efb4bb7627 100644 --- a/sysdeps/unix/sysv/linux/getcpu.c +++ b/sysdeps/unix/sysv/linux/getcpu.c @@ -18,20 +18,15 @@ #include #include #include - -#ifdef HAVE_GETCPU_VSYSCALL -# define HAVE_VSYSCALL -#endif #include int __getcpu (unsigned int *cpu, unsigned int *node) { -#ifdef __NR_getcpu +#ifdef HAVE_GETCPU_VSYSCALL return INLINE_VSYSCALL (getcpu, 3, cpu, node, NULL); #else - __set_errno (ENOSYS); - return -1; + return INLINE_SYSCALL_CALL (getcpu, cpu, node, NULL); #endif } weak_alias (__getcpu, getcpu) diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c index 18d8f7cb7a..c40793fe64 100644 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -17,10 +17,6 @@ #include #include - -#ifdef HAVE_GETTIMEOFDAY_VSYSCALL -# define HAVE_VSYSCALL -#endif #include static int diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c index 80a4c73416..f2b4c76be8 100644 --- a/sysdeps/unix/sysv/linux/powerpc/time.c +++ b/sysdeps/unix/sysv/linux/powerpc/time.c @@ -18,10 +18,6 @@ #include #include - -#ifdef HAVE_TIME_VSYSCALL -# define HAVE_VSYSCALL -#endif #include static time_t diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c index 65dd9fdda7..68ba7f3734 100644 --- a/sysdeps/unix/sysv/linux/sched_getcpu.c +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c @@ -18,22 +18,17 @@ #include #include #include - -#ifdef HAVE_GETCPU_VSYSCALL -# define HAVE_VSYSCALL -#endif #include int sched_getcpu (void) { -#ifdef __NR_getcpu unsigned int cpu; - int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL); - - return r == -1 ? r : cpu; + int r = -1; +#ifdef HAVE_GETCPU_VSYSCALL + r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL); #else - __set_errno (ENOSYS); - return -1; + r = INLINE_SYSCALL_CALL (getcpu, &cpu, NULL, NULL); #endif + return r == -1 ? r : cpu; } diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h index cf614fbf8b..76a211e39b 100644 --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h @@ -20,17 +20,14 @@ # define SYSDEP_VDSO_LINUX_H #include +#include #ifndef INTERNAL_VSYSCALL_CALL # define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ funcptr (args) #endif -#ifdef HAVE_VSYSCALL - -# include - -# define INLINE_VSYSCALL(name, nr, args...) \ +#define INLINE_VSYSCALL(name, nr, args...) \ ({ \ __label__ out; \ __label__ iserr; \ @@ -59,31 +56,4 @@ sc_ret; \ }) -# define INTERNAL_VSYSCALL(name, err, nr, args...) \ - ({ \ - __label__ out; \ - long v_ret; \ - \ - __typeof (__vdso_##name) vdsop = __vdso_##name; \ - PTR_DEMANGLE (vdsop); \ - if (vdsop != NULL) \ - { \ - v_ret = INTERNAL_VSYSCALL_CALL (vdsop, err, nr, ##args); \ - if (!INTERNAL_SYSCALL_ERROR_P (v_ret, err) \ - || INTERNAL_SYSCALL_ERRNO (v_ret, err) != ENOSYS) \ - goto out; \ - } \ - v_ret = INTERNAL_SYSCALL (name, err, nr, ##args); \ - out: \ - v_ret; \ - }) -#else - -# define INLINE_VSYSCALL(name, nr, args...) \ - INLINE_SYSCALL (name, nr, ##args) -# define INTERNAL_VSYSCALL(name, err, nr, args...) \ - INTERNAL_SYSCALL (name, err, nr, ##args) - -#endif /* USE_VSYSCALL && defined HAVE_VSYSCALL */ - #endif /* SYSDEP_VDSO_LINUX_H */ diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c index 190127d31e..8015c40210 100644 --- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/x86/gettimeofday.c @@ -18,10 +18,6 @@ #include #include - -#ifdef HAVE_GETTIMEOFDAY_VSYSCALL -# define HAVE_VSYSCALL -#endif #include static int diff --git a/sysdeps/unix/sysv/linux/x86/time.c b/sysdeps/unix/sysv/linux/x86/time.c index 4a03c46d21..85a9fc8a08 100644 --- a/sysdeps/unix/sysv/linux/x86/time.c +++ b/sysdeps/unix/sysv/linux/x86/time.c @@ -18,16 +18,16 @@ #include #include - -#ifdef HAVE_TIME_VSYSCALL -# define HAVE_VSYSCALL -#endif #include static time_t time_vsyscall (time_t *t) { +#ifdef HAVE_TIME_VSYSCALL return INLINE_VSYSCALL (time, 1, t); +#else + return INLINE_SYSCALL_CALL (time, t); +#endif } #ifdef SHARED From patchwork Tue Dec 17 21:47:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 1211747 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108163-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="TMSBlSOS"; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="AvrgwmtJ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47csFF5cVNz9sRC for ; Wed, 18 Dec 2019 08:47:45 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=v/5i22j4xmaezEPIppFPNHIKetZrW2O y/VjUo99EkVu+u0XDh9SFmFoX6sdDnxt7CWWpSSv9sGhOSJ/2/W56NPgyZD9L0V5 cWoWy2aPxhid4s4E7zjVRXxRy+c1gLbe68Gv7FeCL9KBwuwe60wS97gZtWJve2Q6 WOxCEPVX9KYc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=63AzUM/oCo7JwKqxdiZN3WwbQqk=; b=TMSBl SOSXgEnHmdC9abVO17KBblZ0yeHKXu5dB5qutEGyEInyORDvbE7iYlcfNgH4R4En TQ2rualetS5/RHzB45nSws3A46ZdAGDO2MAzoCvFsN6EyuN156QqnY6AvQzlbC2t tddxf3c9tJM2Fy0Heo3wI/MyUQaQoWzYTCqArs= Received: (qmail 109376 invoked by alias); 17 Dec 2019 21:47:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 109365 invoked by uid 89); 17 Dec 2019 21:47:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:__vdso_ X-HELO: mail-pg1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=iRjQ0sA/OnfmKy+PFVG+M8ot9pfoVgRJ7S+g+jG2lUk=; b=AvrgwmtJcDDQJtORmHFRgrx5pAOqM9IOAnnnGYhIZw0fFJ7LA6T65y4ofAnbf9Hcb+ IwqtaRSPVCEMJgZNBCZnZ5QK4q2t+Mb+lUv6q8Pzx/AcAXLSg5aj7+9c/GBytVTKlFom Don3q/r03PIz1AX/vXr/GsA6QkIntXvXI8i2fuMmz3uP7v/Qu45NQQJDiAZe4OeqlYCA tlSP87PnvxfY+UPrTzz8dJyxJvlK9AFjWKmQ9mhJn7J1feir+Hw+LWAF28fTKPW28aEW cNarznHaNK4KVi3c++C2XijY4WXCBHoN4CLs/3rr3BmKrODyGUacbM2969AIi0SXinuw v/qw== From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 02/16] x86: Make x32 use x86 time implementation Date: Tue, 17 Dec 2019 18:47:14 -0300 Message-Id: <20191217214728.2886-2-adhemerval.zanella@linaro.org> In-Reply-To: <20191217214728.2886-1-adhemerval.zanella@linaro.org> References: <20191217214728.2886-1-adhemerval.zanella@linaro.org> Changes from previous version: - Remove unused x32 gettimeofday.c. Reviewed-by: Siddhesh Poyarekar --- This is the only use of auto-generation syscall which uses a vDSO plus IFUNC and the current x86 generic implementation already covers the expected semantic. Checked on x86_64-linux-gnu-x32. --- sysdeps/unix/sysv/linux/x86_64/x32/gettimeofday.c | 1 - sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list | 1 - 2 files changed, 2 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/x86_64/x32/gettimeofday.c diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/gettimeofday.c b/sysdeps/unix/sysv/linux/x86_64/x32/gettimeofday.c deleted file mode 100644 index cd342f33ad..0000000000 --- a/sysdeps/unix/sysv/linux/x86_64/x32/gettimeofday.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list b/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list index 786c884232..58ea31d1fd 100644 --- a/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list +++ b/sysdeps/unix/sysv/linux/x86_64/x32/syscalls.list @@ -2,4 +2,3 @@ personality EXTRA personality Ei:i __personality personality posix_fadvise64 - fadvise64 Vi:iiii posix_fadvise posix_fadvise64 -time - time:__vdso_time@LINUX_2.6 Ei:P time From patchwork Tue Dec 17 21:47:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 1211749 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108165-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="ImYLTpHS"; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Z+wLbZJJ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47csFf5fmlz9sRC for ; Wed, 18 Dec 2019 08:48:06 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=Qs0bOCeRMb6n8cGeCpHpAE3yxFZNTZN hCr7hNdI+T1A7jnk8+qfKRmXRpT7SJTMgiyNZbkHT4Vx1svoQUREhOaeLZKG4/lM x0rNLMDOhdHA7LYlDc1ht2MDuqln065/APeuzHvuM7wGu3I1F1jiLa778bh+pJ6o BW1vK5isOWuw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=TTozQ/otqIR+N9gLRGWzZEx6gxc=; b=ImYLT pHSCK8KxTJOQFUKwN9epB8+Ghn3oe2jf4VB/wClElyB9093h05Wuf8PED0YoeTPX f5Hzc1kIbLZfvdlmw/qfMDASRDy8hVJiC+y0JzIN73QTHK/XDmb0M2wp+VzHUqO9 rL1vjBvX2ozHsT1dp8XvyTaGbzymwjsqqFwCUM= Received: (qmail 109673 invoked by alias); 17 Dec 2019 21:47:41 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 109625 invoked by uid 89); 17 Dec 2019 21:47:40 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-HELO:sk:mail-pj X-HELO: mail-pj1-f65.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=jhofP24iy+EIsWqORv9KnFvA524I9prsM9/VYL+ZFL0=; b=Z+wLbZJJC322wqgvd5kzOPKu3051tcBRDYJR5A/+MoqpbbdvciRNrY1h7i7TksLvHc x1mOP/xASX7PNiE35aeb9zQLe22EmGgNiLdyjsesB8A2wBdBCIWfOJweOqDHyJYlsHeY BnduzXMQd3BLzT6I+lifsVDD2ypxP+so1q8esKgUeKFf/PdQUKRbP5qkIt2s0TFoyYFO SQlqthfqZfNxqbDEeguwWv/YFpvijBZ+o1y4+JNj5tC8EdXzcRH6N5cWfwAILw5mcKfQ /GQbVK9+cM2WDitF7hVUhiIozZA74MA3i9wKEfAfZ2jx+CYq5EhbhPXbmNxsH1JDd5p3 AH7g== From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 03/16] Remove vDSO support from make-syscall.sh Date: Tue, 17 Dec 2019 18:47:15 -0300 Message-Id: <20191217214728.2886-3-adhemerval.zanella@linaro.org> In-Reply-To: <20191217214728.2886-1-adhemerval.zanella@linaro.org> References: <20191217214728.2886-1-adhemerval.zanella@linaro.org> The auto-generated vDSO call shows some issues: - It requires sync the auto-generated C file with current glibc implementation; - It still uses symbol redirections hacks where libc-symbols.h provide macros that uses compiler builtins (libc_ifunc_redirected for instance); - It does not handle all required compiler handling (inhibit_stack_protector on iFUNC resolver). - No architecure uses it. Checked with a build against all major ABIs. Reviewed-by: Siddhesh Poyarekar --- sysdeps/unix/make-syscalls.sh | 45 +---------------------------------- 1 file changed, 1 insertion(+), 44 deletions(-) diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh index fe24bbc78f..c07626677f 100644 --- a/sysdeps/unix/make-syscalls.sh +++ b/sysdeps/unix/make-syscalls.sh @@ -149,14 +149,6 @@ emit_weak_aliases() echo "$calls" | while read file srcfile caller syscall args strong weak; do - vdso_syscall= - case x"$syscall" in - *:*@*) - vdso_syscall="${syscall#*:}" - syscall="${syscall%:*}" - ;; - esac - case x"$syscall" in x-) callnum=_ ;; *) @@ -233,10 +225,9 @@ while read file srcfile caller syscall args strong weak; do if test $shared_only = t; then # The versioned symbols are only in the shared library. echo "shared-only-routines += $file" - test -n "$vdso_syscall" || echo "\$(objpfx)${file}.os: \\" + echo "\$(objpfx)${file}.os: \\" else object_suffixes='$(object-suffixes)' - test -z "$vdso_syscall" || object_suffixes='$(object-suffixes-noshared)' echo "\ \$(foreach p,\$(sysd-rules-targets),\ \$(foreach o,${object_suffixes},\$(objpfx)\$(patsubst %,\$p,$file)\$o)): \\" @@ -268,40 +259,6 @@ while read file srcfile caller syscall args strong weak; do echo ' ) | $(compile-syscall) '"\ \$(foreach p,\$(patsubst %$file,%,\$(basename \$(@F))),\$(\$(p)CPPFLAGS))" - if test -n "$vdso_syscall"; then - # In the shared library, we're going to emit an IFUNC using a vDSO function. - # $vdso_syscall looks like "name@KERNEL_X.Y" where "name" is the symbol - # name in the vDSO and KERNEL_X.Y is its symbol version. - vdso_symbol="${vdso_syscall%@*}" - vdso_symver="${vdso_syscall#*@}" - vdso_symver=`echo "$vdso_symver" | sed 's/\./_/g'` - cat <'; \\ - echo '#undef ${strong}'; \\ - echo '#define vdso_ifunc_init()'; \\ - echo '__ifunc (__redirect_${strong}, ${strong},'; \\ - echo ' get_vdso_symbol ("${vdso_symbol}"), void,'; \\ - echo ' vdso_ifunc_init)'; \\ -EOF - # This is doing "hidden_def (${strong})", but the compiler - # doesn't know that we've defined ${strong} in the same file, so - # we can't do it the normal way. - cat < X-Patchwork-Id: 1211750 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108166-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="mae0VYLj"; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="uHqllbLC"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47csFw0L3Jz9sRC for ; Wed, 18 Dec 2019 08:48:19 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=uL7jxA8aY1mnm9PMi6NZFCt61jhtoGk 2NbryZw3dGyLc2xE0x7GyKAX+leh8FjwhzNzKlFb6vdApScU0QLavRHr+JeYIHt3 siSYG88CDYhIf0mkj/6k/MWRLyg/znwgWMcVywrK/eIicyGGgf9ANHdBuQExE8KM vObS3pEd4ffY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=LeLk8kpMuF+xQzEVZHP+JwR11LE=; b=mae0V YLjm0H0QSLdSrEkvG9bRslaKeNXGq9zsNlT6Wl2wF0FkEqPqi68uUxOHzCU4TtK+ IJNAJeYGKNQPSIaRKQvcIIBS1UTXsFqkjHN2Rd7nilMWDDUNGRcjuogNUVrbSbAG Vd4VVFtbMCYPLAoU+tpj5GmufPCwqRmfY8vLNI= Received: (qmail 109852 invoked by alias); 17 Dec 2019 21:47:42 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 109806 invoked by uid 89); 17 Dec 2019 21:47:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=5.3 X-HELO: mail-pg1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=NUQAsUcV48k34hRw3/1PawKagDwE4erEMipNDJq7Lcw=; b=uHqllbLCY8n1oYh/P78jwaZm58dmsft8qI3tQbM+S9zZjL1LqX4Bt1hHcmCxoARVqJ w0pDIw/+1VfFm1XCCSG7poQFZAXWx9SgMk47e5dIZP9saPJRvDq9ryzJ8WBFZjJneebI rXclrCilBzMrTEudFqu2G8FWJvRUfUVKdJDx7XjSET+ilckNpHfQos42tbAGUiOEKoN5 y4HLVKM8X7EraVxrtN9A5iuNjVoKXBcvYXfeA2nE3o7SQHxYDDSQvXzjmzaiQDfdd5Eo IwuI9QvwP2dDObv+3q3UfD/5QeUerZwYbYZeL/P2OaJYgiJ2dqG7TlOeocWqKEAB7HiU twfQ== From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 04/16] linux: Update x86 vDSO symbols Date: Tue, 17 Dec 2019 18:47:16 -0300 Message-Id: <20191217214728.2886-4-adhemerval.zanella@linaro.org> In-Reply-To: <20191217214728.2886-1-adhemerval.zanella@linaro.org> References: <20191217214728.2886-1-adhemerval.zanella@linaro.org> Add the missing time and clock_getres vDSO symbol names on x86. For time, the iFUNC already uses expected name so it affects only the static build. The clock_getres is a new implementation added on Linux 5.3 (f66501dc53e72). Checked on x86-linux-gnu and i686-linux-gnu. Reviewed-by: Siddhesh Poyarekar --- sysdeps/unix/sysv/linux/i386/sysdep.h | 2 ++ sysdeps/unix/sysv/linux/x86/time.c | 4 ---- sysdeps/unix/sysv/linux/x86_64/sysdep.h | 2 ++ 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h index 7066ddc214..b2e750d490 100644 --- a/sysdeps/unix/sysv/linux/i386/sysdep.h +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h @@ -315,6 +315,8 @@ struct libc_do_syscall_args /* List of system calls which are supported as vsyscalls. */ # define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" # define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" +# define HAVE_TIME_VSYSCALL "__vdso_time" +# define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres" /* Define a macro which expands inline into the wrapper code for a system call. This use is for internal calls that do not need to handle errors diff --git a/sysdeps/unix/sysv/linux/x86/time.c b/sysdeps/unix/sysv/linux/x86/time.c index 85a9fc8a08..67188a2ceb 100644 --- a/sysdeps/unix/sysv/linux/x86/time.c +++ b/sysdeps/unix/sysv/linux/x86/time.c @@ -23,11 +23,7 @@ static time_t time_vsyscall (time_t *t) { -#ifdef HAVE_TIME_VSYSCALL return INLINE_VSYSCALL (time, 1, t); -#else - return INLINE_SYSCALL_CALL (time, t); -#endif } #ifdef SHARED diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h index 475b7d991a..965fd4b851 100644 --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h @@ -376,7 +376,9 @@ /* List of system calls which are supported as vsyscalls. */ # define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" # define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" +# define HAVE_TIME_VSYSCALL "__vdso_time" # define HAVE_GETCPU_VSYSCALL "__vdso_getcpu" +# define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres" # define SINGLE_THREAD_BY_GLOBAL 1 From patchwork Tue Dec 17 21:47:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 1211751 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108167-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="hV9h2jMm"; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eKyw1jB/"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47csG55zvXz9sRC for ; Wed, 18 Dec 2019 08:48:29 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=ajLX7VoDbK4J4seFCynPhU39SdPG/kr 1hJEWtbrLOIDXY7xMSA0+bMxqcyN7Pioq8gJKeAK9CwpJ4dhKzUzbhZkUFosO771 rb+aMfGvQcFBzh+CTROBdiTnQKp7FQpqWbotBQjJZb5g6rwPh7j4RlRbSvH5tEI5 nYIFxNQhATk4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=DBA7BTL/WRXCVT5A0up9ZG8ptcc=; b=hV9h2 jMmTKjfulXUOch3Om1oL5NXUlT/kK3T8wcuYKdpalOgNBsF8Yfr3wpupXL9N3ijG G+0wLFGWGKLslwdrTxoPehHVJD+935lZUi6p3SCrA+icGf4nwy4DLPVVAmY6LvHK +w0vh2E19wRESYh7NjPx82ppeouJ1mYffmnBXI= Received: (qmail 110050 invoked by alias); 17 Dec 2019 21:47:43 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 109976 invoked by uid 89); 17 Dec 2019 21:47:43 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-pl1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=R6YfmEhYhDYV1EwEVtsdvXCEyOTQdgGb7QiEqPpbF04=; b=eKyw1jB/NJuGoESpvjX2576X+rdQxpO8Q7tMZ+zwFOvY/CIgwqQZDng/7dOo+pMczB iHukt54T7hb6F11OHn/txO0A6+OtuE9BUzns0bUbdLGkygv91Rh6brwl3MvsH7b1HUTo P/5EcZsJkEsRqXACE0C/boA4huqzoygWSWk0+E3cfORvufK+OPs/ZqLUbpX+4flkKUzZ 0rW596/S/xubMghaKVjyprCxETOzc0ev1k1LjuepnzSFvANRnvYTqubvM9bn4mZ3A2cm ZJEzSJ6acTgK9GHTy/ZoJS1b6sxRVW6ixuzm8UHRSorhM0QcI3yCHSKGNdU5mRFywozG NEBg== From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 05/16] linux: Update mips vDSO symbols Date: Tue, 17 Dec 2019 18:47:17 -0300 Message-Id: <20191217214728.2886-5-adhemerval.zanella@linaro.org> In-Reply-To: <20191217214728.2886-1-adhemerval.zanella@linaro.org> References: <20191217214728.2886-1-adhemerval.zanella@linaro.org> The clock_getres is a new implementation added on Linux 5.4 (abed3d826f2f). Checked with a build against mips-linux-gnu and mips64-linux-gnu. Reviewed-by: Siddhesh Poyarekar --- sysdeps/unix/sysv/linux/mips/sysdep.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h index 82a3cf9f3d..c2bec03806 100644 --- a/sysdeps/unix/sysv/linux/mips/sysdep.h +++ b/sysdeps/unix/sysv/linux/mips/sysdep.h @@ -22,6 +22,7 @@ /* List of system calls which are supported as vsyscalls. */ #define HAVE_CLOCK_GETTIME_VSYSCALL "__vdso_clock_gettime" #define HAVE_GETTIMEOFDAY_VSYSCALL "__vdso_gettimeofday" +#define HAVE_CLOCK_GETRES_VSYSCALL "__vdso_clock_getres" #ifndef __ASSEMBLER__ From patchwork Tue Dec 17 21:47:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 1211752 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-108168-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="S/R4QH9Z"; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="CGGZos12"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47csGH4PcVz9sRC for ; Wed, 18 Dec 2019 08:48:39 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=ffvgtqRJmpSw/yL/NRV311B2fss9TbH eFweCoz9URQLZlPpaDapqXQQi52a7W6wkSIdqSQzHaPuEYgxwiMF+s1/sOcei2PO KIYoX+xlidzhI2qN77uRy1ko5jbXSVbCVWp1+yXajIFP5/J2BcIOwtlU5cAqrfR6 4/MVD4B/8BtA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=doqqrwj4k32e2QcT9kKA/au5FUs=; b=S/R4Q H9Z5L1tQwSR6cuF04zerytS6OZtmnU3Hogk/Il+v0XHa02hwNUOAgkR9r3tBJkF0 ovUJVAmE+rkEraPvTXhdWXpkch7GdGqqEPafvqeQAWjoRHnvbUPrYCt1YcWtOw8W AjfwcizMK87IYfz2L4gtZ2X0UJ8CivTjarSnM0= Received: (qmail 110447 invoked by alias); 17 Dec 2019 21:47:47 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 110382 invoked by uid 89); 17 Dec 2019 21:47:46 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=consolidate, Consolidate X-HELO: mail-pj1-f67.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=IIuAdZVF2aJgLYlG8U70B93H4H5XyR7ZjkbmnZah82w=; b=CGGZos12QW4k1XaRxPreMlHLdMrKL3LJQUTBdtnGKK34/dX0b/IhpzHcF9MGQDQZS/ Oim2Kg6LVBA51YMemOjys1AbPok7NpviuuMBvoZza4dnsWJRqsKFVmdYlTEFk2MRCL+L 2E9p0f8HSR7Z4GPu2mlcKNW60yawn7SlRulrr36JAe51rd3ywt4+xapPTdd2Mytu3i8R trVwnTbkTvjxqzNF4bfFBV9XCutyXF+KeOGkaX5pFtaLsY0yxPGxYVgoHUDfvJ7oV/cr oeEvHhklAFpC4wrrDejmE7vx4l+iBZdmtdVrUBYb+IgvwOwByvXvkEct9Tj39nLVAtm+ GHpw== From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 06/16] linux: Consolidate Linux gettimeofday Date: Tue, 17 Dec 2019 18:47:18 -0300 Message-Id: <20191217214728.2886-6-adhemerval.zanella@linaro.org> In-Reply-To: <20191217214728.2886-1-adhemerval.zanella@linaro.org> References: <20191217214728.2886-1-adhemerval.zanella@linaro.org> The IFUNC bypass to vDSO is used when USE_IFUNC_GETTIMEOFDAY is set. Currently aarch64, powerpc*, and x86 defines it. Otherwise the generic implementation is used, which calls clock_gettime. Checked on aarch64-linux-gnu, powerpc64le-linux-gnu, powerpc64-linux-gnu, powerpc-linux-gnu-power4, x86_64-linux-gnu, and i686-linux-gnu. Reviewed-by: Siddhesh Poyarekar --- .../unix/sysv/linux/aarch64/gettimeofday.c | 38 +------------ sysdeps/unix/sysv/linux/gettimeofday.c | 57 +++++++++++++++++++ .../unix/sysv/linux/powerpc/gettimeofday.c | 35 +----------- sysdeps/unix/sysv/linux/x86/gettimeofday.c | 33 +---------- 4 files changed, 63 insertions(+), 100 deletions(-) create mode 100644 sysdeps/unix/sysv/linux/gettimeofday.c diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c index 143c5c1507..f28260c8e9 100644 --- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c @@ -16,39 +16,5 @@ License along with the GNU C Library; if not, see . */ -/* Get the current time of day and timezone information, - putting it into *tv and *tz. If tz is null, *tz is not filled. - Returns 0 on success, -1 on errors. */ - -#include -#include -#include - -/* Used as a fallback in the ifunc resolver if VDSO is not available - and for libc.so internal __gettimeofday calls. */ -static int -__gettimeofday_vsyscall (struct timeval *restrict tv, void *restrict tz) -{ - if (__glibc_unlikely (tz != 0)) - memset (tz, 0, sizeof *tz); - - return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); -} - -#ifdef SHARED -# include -# include - -# define INIT_ARCH() -libc_ifunc (__gettimeofday, - (get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL) - ?: __gettimeofday_vsyscall)) - -#else -int -__gettimeofday (struct timeval *restrict tv, void *restrict tz) -{ - return __gettimeofday_vsyscall (tv, tz); -} -#endif -weak_alias (__gettimeofday, gettimeofday) +#define USE_IFUNC_GETTIMEOFDAY +#include diff --git a/sysdeps/unix/sysv/linux/gettimeofday.c b/sysdeps/unix/sysv/linux/gettimeofday.c new file mode 100644 index 0000000000..600da6b468 --- /dev/null +++ b/sysdeps/unix/sysv/linux/gettimeofday.c @@ -0,0 +1,57 @@ +/* gettimeofday - set time. Linux version. + Copyright (C) 2019 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +/* Some architecture might optimize the gettimeofday by setting the plt direct + to vDSO symbol by using a IFUNC. */ +#ifdef USE_IFUNC_GETTIMEOFDAY +# include +# include +# include + +# ifdef SHARED +# include + +static int +__gettimeofday_syscall (struct timeval *restrict tv, void *restrict tz) +{ + if (__glibc_unlikely (tz != 0)) + memset (tz, 0, sizeof *tz); + return INLINE_SYSCALL_CALL (gettimeofday, tv, tz); +} + +# undef INIT_ARCH +# define INIT_ARCH() \ + void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL) +libc_ifunc (__gettimeofday, + vdso_gettimeofday ? VDSO_IFUNC_RET (vdso_gettimeofday) + : (void *) __gettimeofday_syscall) + +# else +int +__gettimeofday (struct timeval *restrict tv, void *restrict tz) +{ + if (__glibc_unlikely (tz != 0)) + memset (tz, 0, sizeof *tz); + + return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); +} +# endif +weak_alias (__gettimeofday, gettimeofday) +#else /* USE_IFUNC_GETTIMEOFDAY */ +# include