public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 10/12] sparc64: Use linux generic time implementation
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
                   ` (7 preceding siblings ...)
  2019-06-14 15:29 ` [PATCH 11/12] linux: Consolidate time implementation Adhemerval Zanella
@ 2019-06-14 15:29 ` Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 06/12] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

There is no need to sparc64 provide an arch-specific implementation to
route to POSIX one (which uses gettimeofday).  Linux one already handles
the case for architecture that does not have __NR_time.

No semantic changes, checked against a build for sparc64-linux-gnu.

	* sysdeps/unix/sysv/linux/sparc/sparc64/time.c: Remove file.
---
 sysdeps/unix/sysv/linux/sparc/sparc64/time.c | 1 -
 1 file changed, 1 deletion(-)
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/sparc64/time.c

diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/time.c b/sysdeps/unix/sysv/linux/sparc/sparc64/time.c
deleted file mode 100644
index 509b580c55..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/sparc64/time.c
+++ /dev/null
@@ -1 +0,0 @@
-#include <sysdeps/posix/time.c>
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 02/12] riscv: Enable VDSO for static linking
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
                   ` (2 preceding siblings ...)
  2019-06-14 15:29 ` [PATCH 09/12] mips: Consolidate INTERNAL_VSYSCALL_CALL Adhemerval Zanella
@ 2019-06-14 15:29 ` Adhemerval Zanella
  2019-08-02 12:34   ` Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 05/12] linux: Enable vDSO for static linking as default (BZ#19767) Adhemerval Zanella
                   ` (7 subsequent siblings)
  11 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

Checked on riscv64-linux-gnu-rv64imafdc-lp64d qemu system with
some static tests.

	[BZ #19767]
	* sysdeps/unix/sysv/linux/riscv/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/riscv/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/riscv/sysdep.h (ALWAYS_USE_VSYSCALL):
	Define.
---
 sysdeps/unix/sysv/linux/riscv/init-first.c | 8 +++-----
 sysdeps/unix/sysv/linux/riscv/libc-vdso.h  | 6 +-----
 sysdeps/unix/sysv/linux/riscv/sysdep.h     | 3 +++
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/riscv/init-first.c b/sysdeps/unix/sysv/linux/riscv/init-first.c
index 8134c79695..98a8ce33ad 100644
--- a/sysdeps/unix/sysv/linux/riscv/init-first.c
+++ b/sysdeps/unix/sysv/linux/riscv/init-first.c
@@ -17,9 +17,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef SHARED
-# include <dl-vdso.h>
-# include <libc-vdso.h>
+#include <dl-vdso.h>
+#include <libc-vdso.h>
 
 long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
     attribute_hidden;
@@ -52,7 +51,6 @@ _libc_vdso_platform_setup (void)
   VDSO_SYMBOL (clock_getres) = p;
 }
 
-# define VDSO_SETUP _libc_vdso_platform_setup
-#endif
+#define VDSO_SETUP _libc_vdso_platform_setup
 
 #include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h b/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
index b0c46f3cb7..2373292ab9 100644
--- a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
@@ -20,9 +20,7 @@
 #ifndef _LIBC_VDSO_H
 #define _LIBC_VDSO_H
 
-#ifdef SHARED
-
-# include <sysdep-vdso.h>
+#include <sysdep-vdso.h>
 
 extern long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
     attribute_hidden;
@@ -33,6 +31,4 @@ extern long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
 extern long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
     attribute_hidden;
 
-#endif
-
 #endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 5470ea3d2a..caf013a9a1 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -19,6 +19,9 @@
 #ifndef _LINUX_RISCV_SYSDEP_H
 #define _LINUX_RISCV_SYSDEP_H 1
 
+/* Always enable vsyscalls on riscv */
+#define ALWAYS_USE_VSYSCALL 1
+
 #include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <tls.h>
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 08/12] powerpc: Refactor vsyscall internal macros
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
                   ` (4 preceding siblings ...)
  2019-06-14 15:29 ` [PATCH 05/12] linux: Enable vDSO for static linking as default (BZ#19767) Adhemerval Zanella
@ 2019-06-14 15:29 ` Adhemerval Zanella
  2019-06-17 21:49   ` Tulio Magno Quites Machado Filho
  2019-06-14 15:29 ` [PATCH 03/12] s390: Enable VDSO for static linking Adhemerval Zanella
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

As described in libc-vdso.h, the powerpc64 vDSO does not provide the
function descriptor required by ELFv1 ABI.  It requires the architecture
to emulate function calls through INTERNAL_VSYSCALL_CALL without odp
entries.

Another issue is for direct optimized iFUNC calls, where the ifunc goes
directly to vDSO instead of a libc wrapper, the libc must create an
function table itself (since the program will use the default function
call ABI).

This patch follows the previous Linux vDSO refactor to make the internal
vDSO pointer as the only proxy to access the vDSO.  The get_vdso_symbol
and get_vdso_mangle_symbol calls are changed for powerpc64 elfv1 to
generate the required ODP entries.  This allows removes all the internal
macros and simplify the code, where compile is free to generate itself
a function call when the vDSO is called.

Checked on powerpc-linux-gnu, powerpcp64-linux-gnu, and
powerpc64le-linux-gnu.

	* sysdeps/unix/sysv/linux/powerpc/dl-vdso.h: New file.
	* sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
	(get_timebase_freq_fallback): New symbol.
	(__get_timebase_freq): Call vDSO as a function pointer instead of
	arch-specific macros.
	* .../unix/sysv/linux/powerpc/gettimeofday.c (gettimeofday): Use
	get_vdso_symbol.
	* sysdeps/unix/sysv/linux/powerpc/time.c (time): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h (VDSO_IFUNC_RET): Move
	definition to dl-vdso.h.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
	(INTERNAL_VSYSCALL_CALL_TYPE, INTERNAL_VSYSCALL_CALL): Remove.
	* .../sysv/linux/powerpc/powerpc64/sysdep.h
	(INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK, INTERNAL_VSYSCALL_CALL_TYPE,
	INTERNAL_VSYSCALL_CALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h (INTERNAL_VSYSCALL_CALL):
	Define.
---
 sysdeps/unix/sysv/linux/powerpc/dl-vdso.h     | 69 +++++++++++++++++++
 .../sysv/linux/powerpc/get_timebase_freq.c    | 22 +++---
 .../unix/sysv/linux/powerpc/gettimeofday.c    |  4 +-
 sysdeps/unix/sysv/linux/powerpc/libc-vdso.h   | 30 --------
 .../sysv/linux/powerpc/powerpc32/sysdep.h     | 37 ----------
 .../sysv/linux/powerpc/powerpc64/sysdep.h     | 52 +-------------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      | 10 +++
 sysdeps/unix/sysv/linux/powerpc/time.c        |  4 +-
 8 files changed, 97 insertions(+), 131 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/dl-vdso.h

diff --git a/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h b/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h
new file mode 100644
index 0000000000..f6858f02b2
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/dl-vdso.h
@@ -0,0 +1,69 @@
+/* ELF symbol resolve functions for VDSO objects.  PowerPC version.
+   Copyright (C) 2005-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
+   <http://www.gnu.org/licenses/>.  */
+
+#ifndef _DL_VDSO_POWERPC_H
+#define _DL_VDSO_POWERPC_H	1
+
+#if (defined(__PPC64__) || defined(__powerpc64__)) && _CALL_ELF != 2
+
+# include <dl-machine.h>
+# define get_vdso_symbol        __get_vdso_symbol
+# define get_vdso_mangle_symbol __get_vdso_mangle_symbol
+# include_next <dl-vdso.h>
+# undef get_vdso_symbol
+# undef get_vdso_mangle_symbol
+
+/* The correct solution is for _dl_vdso_vsym to return the address of the OPD
+   for the kernel VDSO function.  That address would then be stored in the
+   __vdso_* variables and returned as the result of the IFUNC resolver function.
+   Yet, the kernel does not contain any OPD entries for the VDSO functions
+   (incomplete implementation).  However, PLT relocations for IFUNCs still expect
+   the address of an OPD to be returned from the IFUNC resolver function (since
+   PLT entries on PPC64 are just copies of OPDs).  The solution for now is to
+   create an artificial static OPD for each VDSO function returned by a resolver
+   function.  The TOC value is set to a non-zero value to avoid triggering lazy
+   symbol resolution via .glink0/.plt0 for a zero TOC (requires thread-safe PLT
+   sequences) when the dynamic linker isn't prepared for it e.g. RTLD_NOW.  None
+   of the kernel VDSO routines use the TOC or AUX values so any non-zero value
+   will work.  Note that function pointer comparisons will not use this artificial
+   static OPD since those are resolved via ADDR64 relocations and will point at
+   the non-IFUNC default OPD for the symbol.  Lastly, because the IFUNC relocations
+   are processed immediately at startup the resolver functions and this code need
+   not be thread-safe, but if the caller writes to a PLT slot it must do so in a
+   thread-safe manner with all the required barriers.  */
+#define get_vdso_symbol(symbol)                                          \
+  ({                                                                     \
+    static Elf64_FuncDesc vdso_opd_##symbol = { .fd_toc = ~0x0 };        \
+    vdso_opd_##symbol.fd_func = (Elf64_Addr) __get_vdso_symbol (symbol); \
+    (void*)&vdso_opd_##symbol;                                           \
+  })
+
+#define get_vdso_mangle_symbol(symbol)					 \
+  ({                                                                     \
+    static Elf64_FuncDesc vdso_opd_##symbol = { .fd_toc = ~0x0 };        \
+    vdso_opd_##symbol.fd_func = (Elf64_Addr) __get_vdso_symbol (symbol); \
+    void *vdsop = &vdso_opd_##symbol;                                    \
+    PTR_MANGLE (vdsop);                                                  \
+    vdsop;                                                               \
+  })
+
+#else
+# include_next <dl-vdso.h>
+#endif
+
+#endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
index 23e7694d87..b551412356 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
@@ -23,17 +23,11 @@
 #include <not-cancel.h>
 #include <libc-vdso.h>
 
-uint64_t
-__get_timebase_freq (void)
+static uint64_t
+get_timebase_freq_fallback (void)
 {
   hp_timing_t result = 0L;
 
-#ifdef SHARED
-  /* The vDSO does not return an error (it clear cr0.so on returning).  */
-  INTERNAL_SYSCALL_DECL (err);
-  result =
-    INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK (get_tbfreq, err, uint64_t, 0);
-#else
   /* We read the information from the /proc filesystem.  /proc/cpuinfo
      contains at least one line like:
      timebase        : 33333333
@@ -99,8 +93,18 @@ __get_timebase_freq (void)
 	    }
 	}
     }
-#endif
 
   return result;
 }
+
+uint64_t
+__get_timebase_freq (void)
+{
+  /* The vDSO does not have a fallback mechanism (such calling a syscall).  */
+  __typeof (VDSO_SYMBOL (get_tbfreq)) vdsop = VDSO_SYMBOL (get_tbfreq);
+  if (vdsop == NULL)
+    return get_timebase_freq_fallback ();
+  PTR_DEMANGLE (vdsop);
+  return vdsop ();
+}
 weak_alias (__get_timebase_freq, __ppc_get_timebase_freq)
diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
index 6b92e2807b..7a4e3cca0c 100644
--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
@@ -58,13 +58,13 @@ __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
 }
 
 # define INIT_ARCH()						\
-  void *vdso_gettimeofday = get_vdso_symbol ("__kernel_gettimeofday")
+  void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL)
   
 
 /* If the vDSO is not available we fall back syscall.  */
 libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
 		   vdso_gettimeofday
-		   ? VDSO_IFUNC_RET (vdso_gettimeofday)
+		   ? vdso_gettimeofday
 		   : (void *) __gettimeofday_syscall);
 libc_hidden_def (__gettimeofday)
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
index 47e925493b..c2da7bd7f1 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
@@ -32,34 +32,4 @@ extern void *VDSO_SYMBOL(sigtramp32);
 extern void *VDSO_SYMBOL(sigtramp_rt32);
 #endif
 
-#if (defined(__PPC64__) || defined(__powerpc64__)) && _CALL_ELF != 2
-/* The correct solution is for _dl_vdso_vsym to return the address of the OPD
-   for the kernel VDSO function.  That address would then be stored in the
-   __vdso_* variables and returned as the result of the IFUNC resolver function.
-   Yet, the kernel does not contain any OPD entries for the VDSO functions
-   (incomplete implementation).  However, PLT relocations for IFUNCs still expect
-   the address of an OPD to be returned from the IFUNC resolver function (since
-   PLT entries on PPC64 are just copies of OPDs).  The solution for now is to
-   create an artificial static OPD for each VDSO function returned by a resolver
-   function.  The TOC value is set to a non-zero value to avoid triggering lazy
-   symbol resolution via .glink0/.plt0 for a zero TOC (requires thread-safe PLT
-   sequences) when the dynamic linker isn't prepared for it e.g. RTLD_NOW.  None
-   of the kernel VDSO routines use the TOC or AUX values so any non-zero value
-   will work.  Note that function pointer comparisons will not use this artificial
-   static OPD since those are resolved via ADDR64 relocations and will point at
-   the non-IFUNC default OPD for the symbol.  Lastly, because the IFUNC relocations
-   are processed immediately at startup the resolver functions and this code need
-   not be thread-safe, but if the caller writes to a PLT slot it must do so in a
-   thread-safe manner with all the required barriers.  */
-#define VDSO_IFUNC_RET(value)                            \
-  ({                                                     \
-    static Elf64_FuncDesc vdso_opd = { .fd_toc = ~0x0 }; \
-    vdso_opd.fd_func = (Elf64_Addr)value;                \
-    &vdso_opd;                                           \
-  })
-
-#else
-#define VDSO_IFUNC_RET(value)  ((void *) (value))
-#endif
-
 #endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
index f459543fcd..889c6ac117 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
@@ -34,43 +34,6 @@
 
 # include <errno.h>
 
-/* Define a macro which expands inline into the wrapper code for a VDSO
-   call. This use is for internal calls that do not need to handle errors
-   normally. It will never touch errno.
-   On powerpc a system call basically clobbers the same registers like a
-   function call, with the exception of LR (which is needed for the
-   "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
-   an error return status).  */
-# define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, nr, type, args...)	      \
-  ({									      \
-    register void *r0  __asm__ ("r0");					      \
-    register long int r3  __asm__ ("r3");				      \
-    register long int r4  __asm__ ("r4");				      \
-    register long int r5  __asm__ ("r5");				      \
-    register long int r6  __asm__ ("r6");				      \
-    register long int r7  __asm__ ("r7");				      \
-    register long int r8  __asm__ ("r8");				      \
-    register long int r9  __asm__ ("r9");				      \
-    register long int r10 __asm__ ("r10");				      \
-    register long int r11 __asm__ ("r11");				      \
-    register long int r12 __asm__ ("r12");				      \
-    register type rval  __asm__ ("r3");					      \
-    LOADARGS_##nr (funcptr, args);					      \
-    __asm__ __volatile__						      \
-      ("mtctr %0\n\t"							      \
-       "bctrl\n\t"							      \
-       "mfcr %0"							      \
-       : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),  "+r" (r7),  \
-	 "+r" (r8), "+r" (r9), "+r" (r10), "+r" (r11), "+r" (r12)	      \
-       : : "cr0", "ctr", "lr", "memory");				      \
-    err = (long int) r0;						      \
-    __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3), "r" (r4));	      \
-    rval;								      \
-  })
-
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
-  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, nr, long int, args)
-
 # undef INLINE_SYSCALL
 # define INLINE_SYSCALL(name, nr, args...)				\
   ({									\
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index 06222f52e6..4e507db00d 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -45,59 +45,9 @@
 
 #endif /* __ASSEMBLER__ */
 
-/* This version is for internal uses when there is no desire
-   to set errno */
-#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, type, nr, args...)   \
-  ({									      \
-    type sc_ret = ENOSYS;						      \
-									      \
-    __typeof (__vdso_##name) vdsop = __vdso_##name;			      \
-    PTR_DEMANGLE (vdsop);						      \
-    if (vdsop != NULL)							      \
-      sc_ret =								      \
-        INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, type, nr, ##args);	      \
-    else								      \
-      err = 1 << 28;							      \
-    sc_ret;								      \
-  })
-
-/* 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
-   normally. It will never touch errno. This returns just what the kernel
-   gave back in the non-error (CR0.SO cleared) case, otherwise (CR0.SO set)
-   the negation of the return value in the kernel gets reverted.  */
-
-#define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...)    \
-  ({									\
-    register void *r0  __asm__ ("r0");					\
-    register long int r3  __asm__ ("r3");				\
-    register long int r4  __asm__ ("r4");				\
-    register long int r5  __asm__ ("r5");				\
-    register long int r6  __asm__ ("r6");				\
-    register long int r7  __asm__ ("r7");				\
-    register long int r8  __asm__ ("r8");				\
-    register type rval  __asm__ ("r3");				        \
-    LOADARGS_##nr (funcptr, args);					\
-    __asm__ __volatile__						\
-      ("mtctr %0\n\t"							\
-       "bctrl\n\t"							\
-       "mfcr  %0\n\t"							\
-       "0:"								\
-       : "+r" (r0), "+r" (r3), "+r" (r4), "+r" (r5),  "+r" (r6),        \
-         "+r" (r7), "+r" (r8)						\
-       : : "r9", "r10", "r11", "r12", "cr0", "ctr", "lr", "memory");	\
-    err = (long int) r0;						\
-    __asm__ __volatile__ ("" : "=r" (rval) : "r" (r3));		        \
-    rval;								\
-  })
-
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
-
-#undef INLINE_SYSCALL
-
 /* This version is for kernels that implement system calls that
    behave like function calls as far as register saving.  */
+#undef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...)				\
   ({									\
     INTERNAL_SYSCALL_DECL (sc_err);					\
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 20167615c8..cf967a8c33 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -24,6 +24,7 @@
 #define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 #define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
 #define HAVE_TIME_VSYSCALL		"__kernel_time"
+#define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
 #define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
 #if defined(__PPC64__) || defined(__powerpc64__)
@@ -32,3 +33,12 @@
 # define HAVE_SIGTRAMP_32		"__kernel_sigtramp32"
 # define HAVE_SIGTRAMP_RT32		"__kernel_sigtramp_rt32"
 #endif
+
+#ifndef __ASSEMBLER__
+
+/* PowerPC vDSO symbols always succeed, so there is no need to emulate a
+   function call and check for CR0.SO value.  */
+#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
+  ({ err = 0; funcptr (args); })
+
+#endif /* __ASSEMBLER__  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c
index 53fd119b00..ca6721cf95 100644
--- a/sysdeps/unix/sysv/linux/powerpc/time.c
+++ b/sysdeps/unix/sysv/linux/powerpc/time.c
@@ -67,12 +67,12 @@ time_syscall (time_t *t)
 }
 
 # define INIT_ARCH()							\
-  void *vdso_time = get_vdso_symbol ("__kernel_time");
+  void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL);
 
 /* If the vDSO is not available we fall back to the syscall.  */
 libc_ifunc_hidden (__redirect_time, time,
 		   vdso_time
-		   ? VDSO_IFUNC_RET (vdso_time)
+		   ? vdso_time
 		   : (void *) time_syscall);
 libc_hidden_def (time)
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 06/12] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
                   ` (8 preceding siblings ...)
  2019-06-14 15:29 ` [PATCH 10/12] sparc64: Use linux generic " Adhemerval Zanella
@ 2019-06-14 15:29 ` Adhemerval Zanella
  2019-06-17 20:26   ` Tulio Magno Quites Machado Filho
  2019-06-14 15:30 ` [PATCH 04/12] sparc: Enable VDSO for static linking Adhemerval Zanella
  2019-06-14 16:12 ` [PATCH 01/12] m68k: Remove vDSO support Andreas Schwab
  11 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

This patch removes the PREPARE_VERSION and PREPARE_VERSION_KNOW macro
and uses a static inline function instead, get_vdso_symbol.  Also,
each architecture that supports vDSO must define the Linux version
and hash for symbol resolution (VDSO_NAME and VDSO_HASH macro
respectively).

It also organizes the HAVE_*_VSYSCALL for mips, powerpc, and s390  to set
them on a common header.

The idea is to require less code to configure and enable vDSO support for
newer ports.  No semantic changes are expected.

Checked with a build against all affected architectures.

	* sysdeps/unix/make-syscalls.sh: Make vDSO call use get_vdso_symbol.
	* sysdeps/unix/sysv/linux/aarch64/gettimeofday.c (__gettimeofday):
	Use get_vdso_symbol instead of _dl_vdso_vsym.
	* sysdeps/unix/sysv/linux/powerpc/time.c (time): Likewise.
	* sysdeps/unix/sysv/linux/riscv/flush-icache.c
	(__lookup_riscv_flush_icache): Likewise.
	* sysdeps/unix/sysv/linux/x86/gettimeofday.c (__gettimeofday):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/time.c (time): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/i386/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h (VDSO_NAME, VDSO_HASH):
	Define.
	* sysdeps/unix/sysv/linux/arm/sysdep.h (VDSO_NAME, VDSO_HASH):
	Likewise.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (VDSO_NAME, VDSO_HASH):
	Likewise.
	* sysdeps/unix/sysv/linux/riscv/sysdep.h (VDSO_NAME, VDSO_HASH):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h (VDSO_NAME, VDSO_HASH):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (VDSO_NAME, VDSO_HASH):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Remove
	definition.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
	(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL, HAVE_GETCPU_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
	(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL, HAVE_GETCPU_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/sysdep.h: New file.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/sysdep.h: Likewise.
	* sysdeps/unix/sysv/linux/dl-vdso.h (PREPARE_VERSION,
	PREPARE_VERSION_KNOWN, VDSO_NAME_LINUX_2_6, VDSO_HASH_LINUX_2_6,
	VDSO_NAME_LINUX_2_6_15, VDSO_HASH_LINUX_2_6_15,
	VDSO_NAME_LINUX_2_6_29, VDSO_HASH_LINUX_2_6_29,
	VDSO_NAME_LINUX_4_15, VDSO_HASH_LINUX_4_15): Remove defines.
	(get_vdso_symbol): New function.
---
 sysdeps/unix/make-syscalls.sh                 |  5 ++-
 .../unix/sysv/linux/aarch64/gettimeofday.c    | 26 ++++-----------
 sysdeps/unix/sysv/linux/aarch64/init-first.c  | 12 ++-----
 sysdeps/unix/sysv/linux/aarch64/sysdep.h      |  7 ++++
 sysdeps/unix/sysv/linux/arm/init-first.c      |  6 ++--
 sysdeps/unix/sysv/linux/arm/sysdep.h          |  3 ++
 sysdeps/unix/sysv/linux/dl-vdso.h             | 32 +++++--------------
 sysdeps/unix/sysv/linux/i386/init-first.c     |  4 +--
 sysdeps/unix/sysv/linux/i386/sysdep.h         |  3 ++
 sysdeps/unix/sysv/linux/mips/init-first.c     |  6 ++--
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h  |  5 +--
 .../unix/sysv/linux/mips/mips64/n32/sysdep.h  |  5 +--
 .../unix/sysv/linux/mips/mips64/n64/sysdep.h  |  5 +--
 sysdeps/unix/sysv/linux/mips/sysdep.h         | 24 ++++++++++++++
 .../unix/sysv/linux/powerpc/gettimeofday.c    |  6 ++--
 sysdeps/unix/sysv/linux/powerpc/init-first.c  | 22 ++++++-------
 .../sysv/linux/powerpc/powerpc32/sysdep.h     |  7 +---
 .../sysv/linux/powerpc/powerpc64/sysdep.h     |  6 +---
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      | 26 +++++++++++++++
 sysdeps/unix/sysv/linux/powerpc/time.c        |  3 +-
 sysdeps/unix/sysv/linux/riscv/flush-icache.c  |  4 +--
 sysdeps/unix/sysv/linux/riscv/init-first.c    | 10 +++---
 sysdeps/unix/sysv/linux/riscv/sysdep.h        |  3 ++
 sysdeps/unix/sysv/linux/s390/init-first.c     | 10 +++---
 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h |  7 +---
 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h |  7 +---
 sysdeps/unix/sysv/linux/s390/sysdep.h         | 27 ++++++++++++++++
 sysdeps/unix/sysv/linux/sparc/init-first.c    |  6 ++--
 sysdeps/unix/sysv/linux/sparc/sysdep.h        |  3 ++
 sysdeps/unix/sysv/linux/x86/gettimeofday.c    | 10 +++---
 sysdeps/unix/sysv/linux/x86/time.c            |  7 ++--
 sysdeps/unix/sysv/linux/x86_64/init-first.c   |  6 ++--
 sysdeps/unix/sysv/linux/x86_64/sysdep.h       |  3 ++
 33 files changed, 167 insertions(+), 149 deletions(-)
 create mode 100644 sysdeps/unix/sysv/linux/mips/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/powerpc/sysdep.h
 create mode 100644 sysdeps/unix/sysv/linux/s390/sysdep.h

diff --git a/sysdeps/unix/make-syscalls.sh b/sysdeps/unix/make-syscalls.sh
index 6a5c10d54e..b49e6b6305 100644
--- a/sysdeps/unix/make-syscalls.sh
+++ b/sysdeps/unix/make-syscalls.sh
@@ -283,10 +283,9 @@ while read file srcfile caller syscall args strong weak; do
 	(echo '#define ${strong} __redirect_${strong}'; \\
 	 echo '#include <dl-vdso.h>'; \\
 	 echo '#undef ${strong}'; \\
-	 echo '#define vdso_ifunc_init() \\'; \\
-	 echo '  PREPARE_VERSION_KNOWN (symver, ${vdso_symver})'; \\
+	 echo '#define vdso_ifunc_init()'; \\
 	 echo '__ifunc (__redirect_${strong}, ${strong},'; \\
-	 echo '         _dl_vdso_vsym ("${vdso_symbol}", &symver), void,'; \\
+	 echo '         get_vdso_symbol ("${vdso_symbol}"), void,'; \\
 	 echo '         vdso_ifunc_init)'; \\
 EOF
     # This is doing "hidden_def (${strong})", but the compiler
diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
index 6c008ed935..2474a2c575 100644
--- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
@@ -20,12 +20,10 @@
    putting it into *tv and *tz.  If tz is null, *tz is not filled.
    Returns 0 on success, -1 on errors.  */
 
+#include <sys/time.h>
+
 #ifdef SHARED
 
-# define __gettimeofday __redirect___gettimeofday
-# include <sys/time.h>
-# undef __gettimeofday
-# define HAVE_VSYSCALL
 # include <dl-vdso.h>
 # include <sysdep-vdso.h>
 
@@ -38,25 +36,15 @@ __gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
   return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
 }
 
-/* PREPARE_VERSION will need an __LP64__ ifdef when ILP32 support
-   goes in.  See _libc_vdso_platform_setup in
-   sysdeps/unix/sysv/linux/aarch64/init-first.c.  */
-
-# undef INIT_ARCH
-# define INIT_ARCH() \
-	   PREPARE_VERSION (linux_version, "LINUX_2.6.39", 123718537); \
-	   void *vdso_gettimeofday = \
-	     _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version);
+# define INIT_ARCH()
 
-libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
-		   vdso_gettimeofday ?: (void *) __gettimeofday_vsyscall)
-
-__hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday,
-	       __gettimeofday_vsyscall);
+libc_ifunc_hidden (__gettimeofday, __gettimeofday,
+		   (get_vdso_symbol ("__vdso_gettimeofday")
+		    ?: __gettimeofday_vsyscall))
+libc_hidden_def (__gettimeofday)
 
 #else
 
-# include <sys/time.h>
 # include <sysdep.h>
 int
 __gettimeofday (struct timeval *tv, struct timezone *tz)
diff --git a/sysdeps/unix/sysv/linux/aarch64/init-first.c b/sysdeps/unix/sysv/linux/aarch64/init-first.c
index ce7319f3c9..c3c27cfd4b 100644
--- a/sysdeps/unix/sysv/linux/aarch64/init-first.c
+++ b/sysdeps/unix/sysv/linux/aarch64/init-first.c
@@ -26,21 +26,15 @@ int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
 static inline void
 _libc_vdso_platform_setup (void)
 {
-#ifdef __LP64__
-  PREPARE_VERSION (linux_version, "LINUX_2.6.39", 123718537);
-#else
-  PREPARE_VERSION (linux_version, "LINUX_4.9", 61765625);
-#endif
-
-  void *p = _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version);
+  void *p = get_vdso_symbol ("__kernel_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL(gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_gettime", &linux_version);
+  p = get_vdso_symbol ("__kernel_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL(clock_gettime) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_getres", &linux_version);
+  p = get_vdso_symbol ("__kernel_clock_getres");
   PTR_MANGLE (p);
   VDSO_SYMBOL(clock_getres) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index a2f4061b58..662d321235 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -151,6 +151,13 @@
 
 #else /* not __ASSEMBLER__ */
 
+# ifdef __LP64__
+#  define VDSO_NAME  "LINUX_2_6_39"
+#  define VDSO_HASH  123718537
+# else
+#  define VDSO_NAME  "LINUX_4.9"
+#  define VDSO_HASH  61765625
+# endif
 
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETRES_VSYSCALL	1
diff --git a/sysdeps/unix/sysv/linux/arm/init-first.c b/sysdeps/unix/sysv/linux/arm/init-first.c
index e1846df661..2852ab135c 100644
--- a/sysdeps/unix/sysv/linux/arm/init-first.c
+++ b/sysdeps/unix/sysv/linux/arm/init-first.c
@@ -27,13 +27,11 @@ int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
-
-  void *p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux26);
+  void *p = get_vdso_symbol ("__vdso_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
+  p = get_vdso_symbol ("__vdso_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
index 6d8d9a47f9..467ccf2631 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -388,6 +388,9 @@ __local_syscall_error:						\
 #undef INTERNAL_SYSCALL_ERRNO
 #define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
 
+#define VDSO_NAME  "LINUX_2_6"
+#define VDSO_HASH  61765110
+
 /* List of system calls which are supported as vsyscalls.  */
 #define HAVE_CLOCK_GETTIME_VSYSCALL	1
 #define HAVE_GETTIMEOFDAY_VSYSCALL	1
diff --git a/sysdeps/unix/sysv/linux/dl-vdso.h b/sysdeps/unix/sysv/linux/dl-vdso.h
index 50ee29067d..bab3779615 100644
--- a/sysdeps/unix/sysv/linux/dl-vdso.h
+++ b/sysdeps/unix/sysv/linux/dl-vdso.h
@@ -22,34 +22,18 @@
 #include <assert.h>
 #include <ldsodefs.h>
 #include <dl-hash.h>
-
-/* Create version number record for lookup.  */
-#define PREPARE_VERSION(var, vname, vhash) \
-  struct r_found_version var;						      \
-  var.name = vname;							      \
-  var.hidden = 1;							      \
-  var.hash = vhash;							      \
-  assert (var.hash == _dl_elf_hash (var.name));				      \
-  /* We don't have a specific file where the symbol can be found.  */	      \
-  var.filename = NULL
-
-/* Use this for the known version sets defined below, where we
-   record their precomputed hash values only once, in this file.  */
-#define PREPARE_VERSION_KNOWN(var, vname) \
-  PREPARE_VERSION (var, VDSO_NAME_##vname, VDSO_HASH_##vname)
-
-#define VDSO_NAME_LINUX_2_6	"LINUX_2.6"
-#define VDSO_HASH_LINUX_2_6	61765110
-#define VDSO_NAME_LINUX_2_6_15	"LINUX_2.6.15"
-#define VDSO_HASH_LINUX_2_6_15	123718565
-#define VDSO_NAME_LINUX_2_6_29	"LINUX_2.6.29"
-#define VDSO_HASH_LINUX_2_6_29	123718585
-#define VDSO_NAME_LINUX_4_15	"LINUX_4.15"
-#define VDSO_HASH_LINUX_4_15	182943605
+#include <libc-vdso.h>
 
 /* Functions for resolving symbols in the VDSO link map.  */
 extern void *_dl_vdso_vsym (const char *name,
 			    const struct r_found_version *version)
       attribute_hidden;
 
+static inline void *
+get_vdso_symbol (const char *symbol)
+{
+  struct r_found_version rfv = { VDSO_NAME, VDSO_HASH, 1, NULL };
+  return _dl_vdso_vsym (symbol, &rfv);
+}
+
 #endif /* dl-vdso.h */
diff --git a/sysdeps/unix/sysv/linux/i386/init-first.c b/sysdeps/unix/sysv/linux/i386/init-first.c
index 60d69777cd..9c03f87b67 100644
--- a/sysdeps/unix/sysv/linux/i386/init-first.c
+++ b/sysdeps/unix/sysv/linux/i386/init-first.c
@@ -34,9 +34,7 @@ clock_gettime_syscall (clockid_t id, struct timespec *tp)
 static inline void
 __vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
-
-  void *p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
+  void *p = get_vdso_symbol ("__vdso_clock_gettime");
   if (p == NULL)
     p = clock_gettime_syscall;
   PTR_MANGLE (p);
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 77154b904a..278028f52e 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -309,6 +309,9 @@ struct libc_do_syscall_args
 #define INLINE_SYSCALL_ERROR_RETURN_VALUE(resultvar) \
   __syscall_error (-(resultvar))
 
+# define VDSO_NAME  "LINUX_2.6"
+# define VDSO_HASH  61765110
+
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETTIME_VSYSCALL    1
 # define HAVE_GETTIMEOFDAY_VSYSCALL     1
diff --git a/sysdeps/unix/sysv/linux/mips/init-first.c b/sysdeps/unix/sysv/linux/mips/init-first.c
index 25884ffd80..2a43bdc8b0 100644
--- a/sysdeps/unix/sysv/linux/mips/init-first.c
+++ b/sysdeps/unix/sysv/linux/mips/init-first.c
@@ -26,13 +26,11 @@ int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
-
-  void *p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux26);
+  void *p = get_vdso_symbol ("__vdso_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
+  p = get_vdso_symbol ("__vdso_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index a310a0acbc..ebe397b701 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -19,6 +19,7 @@
 #define _LINUX_MIPS_MIPS32_SYSDEP_H 1
 
 /* There is some commonality.  */
+#include <sysdeps/unix/sysv/linux/mips/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips32/sysdep.h>
 
@@ -360,10 +361,6 @@ libc_hidden_proto (__mips_syscall7, nomips16)
     _ret;								\
   })
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
index d83e08f96a..bb49429c30 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
@@ -19,6 +19,7 @@
 #define _LINUX_MIPS_SYSDEP_H 1
 
 /* There is some commonality.  */
+#include <sysdeps/unix/sysv/linux/mips/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips64/n32/sysdep.h>
 
@@ -308,10 +309,6 @@
     _ret;								\
   })
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
index bcfaf561a1..84a1ff186b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
@@ -19,6 +19,7 @@
 #define _LINUX_MIPS_SYSDEP_H 1
 
 /* There is some commonality.  */
+#include <sysdeps/unix/sysv/linux/mips/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips64/n64/sysdep.h>
 
@@ -304,10 +305,6 @@
     _ret;								\
   })
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
new file mode 100644
index 0000000000..cabc590961
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
@@ -0,0 +1,24 @@
+/* Syscall definitions, Linux MIPS generic 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
+   <http://www.gnu.org/licenses/>.  */
+
+#define VDSO_NAME  "LINUX_2_6"
+#define VDSO_HASH  61765110
+
+/* List of system calls which are supported as vsyscalls.  */
+#define HAVE_CLOCK_GETTIME_VSYSCALL     1
+#define HAVE_GETTIMEOFDAY_VSYSCALL      1
diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
index c8d7790d8a..6b92e2807b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
@@ -57,9 +57,9 @@ __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
   return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
 }
 
-# define INIT_ARCH()							\
-  PREPARE_VERSION (linux2615, "LINUX_2.6.15", 123718565);		\
-  void *vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615);
+# define INIT_ARCH()						\
+  void *vdso_gettimeofday = get_vdso_symbol ("__kernel_gettimeofday")
+  
 
 /* If the vDSO is not available we fall back syscall.  */
 libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.c b/sysdeps/unix/sysv/linux/powerpc/init-first.c
index 237b5abbf9..0d46563ce3 100644
--- a/sysdeps/unix/sysv/linux/powerpc/init-first.c
+++ b/sysdeps/unix/sysv/linux/powerpc/init-first.c
@@ -37,29 +37,27 @@ void *VDSO_SYMBOL(sigtramp_rt32);
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION (linux2615, "LINUX_2.6.15", 123718565);
-
-  void *p = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615);
+  void *p = get_vdso_symbol ("__kernel_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_gettime", &linux2615);
+  p = get_vdso_symbol ("__kernel_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_getres", &linux2615);
+  p = get_vdso_symbol ("__kernel_clock_getres");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_getres) = p;
 
-  p = _dl_vdso_vsym ("__kernel_get_tbfreq", &linux2615);
+  p = get_vdso_symbol ("__kernel_get_tbfreq");
   PTR_MANGLE (p);
   VDSO_SYMBOL (get_tbfreq) = p;
 
-  p = _dl_vdso_vsym ("__kernel_getcpu", &linux2615);
+  p = get_vdso_symbol ("__kernel_getcpu");
   PTR_MANGLE (p);
   VDSO_SYMBOL (getcpu) = p;
 
-  p = _dl_vdso_vsym ("__kernel_time", &linux2615);
+  p = get_vdso_symbol ("__kernel_time");
   PTR_MANGLE (p);
   VDSO_SYMBOL (time) = p;
 
@@ -69,12 +67,10 @@ _libc_vdso_platform_setup (void)
      There is no need to pointer mangle these symbol because they will
      used only for pointer comparison.  */
 #if defined(__PPC64__) || defined(__powerpc64__)
-  VDSO_SYMBOL(sigtramp_rt64) = _dl_vdso_vsym ("__kernel_sigtramp_rt64",
-					      &linux2615);
+  VDSO_SYMBOL(sigtramp_rt64) =  get_vdso_symbol ("__kernel_sigtramp_rt64");
 #else
-  VDSO_SYMBOL(sigtramp32) = _dl_vdso_vsym ("__kernel_sigtramp32", &linux2615);
-  VDSO_SYMBOL(sigtramp_rt32) = _dl_vdso_vsym ("__kernel_sigtramp_rt32",
-					      &linux2615);
+  VDSO_SYMBOL(sigtramp32) = get_vdso_symbol ("__kernel_sigtramp32");
+  VDSO_SYMBOL(sigtramp_rt32) = get_vdso_symbol ("__kernel_sigtramp_rt32");
 #endif
 }
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
index 62caa265d7..f459543fcd 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
@@ -18,6 +18,7 @@
 #ifndef _LINUX_POWERPC_SYSDEP_H
 #define _LINUX_POWERPC_SYSDEP_H 1
 
+#include <sysdeps/unix/sysv/linux/powerpc/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/powerpc/sysdep.h>
 #include <tls.h>
@@ -144,12 +145,6 @@
     sc_ret;								      \
   })
 
-/* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETRES_VSYSCALL	1
-# define HAVE_CLOCK_GETTIME_VSYSCALL	1
-# define HAVE_GETCPU_VSYSCALL		1
-
-
 # define LOADARGS_0(name, dummy)					      \
 	r0 = name
 # define LOADARGS_1(name, __arg1) \
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index 4122e5c4a9..06222f52e6 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -20,6 +20,7 @@
 #ifndef _LINUX_POWERPC_SYSDEP_H
 #define _LINUX_POWERPC_SYSDEP_H 1
 
+#include <sysdeps/unix/sysv/linux/powerpc/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/powerpc/sysdep.h>
 #include <tls.h>
@@ -60,11 +61,6 @@
     sc_ret;								      \
   })
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	1
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETCPU_VSYSCALL		1
-
 /* 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
    normally. It will never touch errno. This returns just what the kernel
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
new file mode 100644
index 0000000000..5b411d0e8e
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -0,0 +1,26 @@
+/* Syscall definitions, Linux PowerPC generic 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
+   <http://www.gnu.org/licenses/>.  */
+
+#define VDSO_NAME  "LINUX_2.6.15"
+#define VDSO_HASH  123718565
+
+/* List of system calls which are supported as vsyscalls.  */
+#define HAVE_CLOCK_GETRES_VSYSCALL	1
+#define HAVE_CLOCK_GETTIME_VSYSCALL	1
+#define HAVE_GETCPU_VSYSCALL		1
+
diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c
index c2f171b622..53fd119b00 100644
--- a/sysdeps/unix/sysv/linux/powerpc/time.c
+++ b/sysdeps/unix/sysv/linux/powerpc/time.c
@@ -67,8 +67,7 @@ time_syscall (time_t *t)
 }
 
 # define INIT_ARCH()							\
-  PREPARE_VERSION (linux2615, "LINUX_2.6.15", 123718565);		\
-  void *vdso_time = _dl_vdso_vsym ("__kernel_time", &linux2615);
+  void *vdso_time = get_vdso_symbol ("__kernel_time");
 
 /* If the vDSO is not available we fall back to the syscall.  */
 libc_ifunc_hidden (__redirect_time, time,
diff --git a/sysdeps/unix/sysv/linux/riscv/flush-icache.c b/sysdeps/unix/sysv/linux/riscv/flush-icache.c
index f2dfcc50d0..6fbda9a088 100644
--- a/sysdeps/unix/sysv/linux/riscv/flush-icache.c
+++ b/sysdeps/unix/sysv/linux/riscv/flush-icache.c
@@ -38,9 +38,7 @@ __riscv_flush_icache_syscall (void *start, void *end, unsigned long int flags)
 static func_type
 __lookup_riscv_flush_icache (void)
 {
-  PREPARE_VERSION_KNOWN (linux_version, LINUX_4_15);
-
-  func_type func = _dl_vdso_vsym ("__vdso_flush_icache", &linux_version);
+  func_type func = get_vdso_symbol ("__vdso_flush_icache");
 
   /* If there is no vDSO entry then call the system call directly.  All Linux
      versions provide the vDSO entry, but QEMU's user-mode emulation doesn't
diff --git a/sysdeps/unix/sysv/linux/riscv/init-first.c b/sysdeps/unix/sysv/linux/riscv/init-first.c
index 98a8ce33ad..f3d243a192 100644
--- a/sysdeps/unix/sysv/linux/riscv/init-first.c
+++ b/sysdeps/unix/sysv/linux/riscv/init-first.c
@@ -32,21 +32,19 @@ long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux_version, LINUX_4_15);
-
-  void *p = _dl_vdso_vsym ("__vdso_getcpu", &linux_version);
+  void *p = get_vdso_symbol ("__vdso_getcpu");
   PTR_MANGLE (p);
   VDSO_SYMBOL (getcpu) = p;
 
-  p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux_version);
+  p = get_vdso_symbol ("__vdso_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux_version);
+  p = get_vdso_symbol ("__vdso_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_getres", &linux_version);
+  p = get_vdso_symbol ("__vdso_clock_getres");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_getres) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 5470ea3d2a..5de773744c 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -121,6 +121,9 @@
 
 #ifndef __ASSEMBLER__
 
+# define VDSO_NAME  "LINUX_4.15"
+# define VDSO_HASH  182943605
+
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETRES_VSYSCALL	1
 # define HAVE_CLOCK_GETTIME_VSYSCALL	1
diff --git a/sysdeps/unix/sysv/linux/s390/init-first.c b/sysdeps/unix/sysv/linux/s390/init-first.c
index 847977c0d9..63a12d95c8 100644
--- a/sysdeps/unix/sysv/linux/s390/init-first.c
+++ b/sysdeps/unix/sysv/linux/s390/init-first.c
@@ -34,21 +34,19 @@ long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION (linux2629, "LINUX_2.6.29", 123718585);
-
-  void *p = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2629);
+  void *p = get_vdso_symbol ("__kernel_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_gettime", &linux2629);
+  p = get_vdso_symbol ("__kernel_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 
-  p = _dl_vdso_vsym ("__kernel_clock_getres", &linux2629);
+  p = get_vdso_symbol ("__kernel_clock_getres");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_getres) = p;
 
-  p = _dl_vdso_vsym ("__kernel_getcpu", &linux2629);
+  p = get_vdso_symbol ("__kernel_getcpu");
   PTR_MANGLE (p);
   VDSO_SYMBOL (getcpu) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
index 640fb52de1..b780d22d8f 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
@@ -21,6 +21,7 @@
 
 #include <sysdeps/s390/s390-32/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/s390/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
 #include <tls.h>
@@ -271,12 +272,6 @@
 #define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
 #define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	1
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-#define HAVE_GETCPU_VSYSCALL		1
-
 /* Pointer mangling support.  */
 #if IS_IN (rtld)
 /* We cannot use the thread descriptor because in ld.so we use setjmp
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
index 9a9834c750..07cfa64cab 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
@@ -22,6 +22,7 @@
 
 #include <sysdeps/s390/s390-64/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
+#include <sysdeps/unix/sysv/linux/s390/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <dl-sysdep.h>	/* For RTLD_PRIVATE_ERRNO.  */
 #include <tls.h>
@@ -277,12 +278,6 @@
 #define ASMFMT_5 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6)
 #define ASMFMT_6 , "0" (gpr2), "d" (gpr3), "d" (gpr4), "d" (gpr5), "d" (gpr6), "d" (gpr7)
 
-/* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	1
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-#define HAVE_GETCPU_VSYSCALL		1
-
 #define SINGLE_THREAD_BY_GLOBAL		1
 
 /* Pointer mangling support.  */
diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h
new file mode 100644
index 0000000000..eefbd8f007
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/sysdep.h
@@ -0,0 +1,27 @@
+/* Syscall definitions, Linux PowerPC generic version.
+   Copyright (C) 2000-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
+   <http://www.gnu.org/licenses/>.  */
+
+#define VDSO_NAME  "LINUX_2_6_29"
+#define VDSO_HASH  123718585
+
+/* List of system calls which are supported as vsyscalls.  */
+#define HAVE_CLOCK_GETRES_VSYSCALL	1
+#define HAVE_CLOCK_GETTIME_VSYSCALL	1
+#define HAVE_GETTIMEOFDAY_VSYSCALL	1
+#define HAVE_GETCPU_VSYSCALL		1
+
diff --git a/sysdeps/unix/sysv/linux/sparc/init-first.c b/sysdeps/unix/sysv/linux/sparc/init-first.c
index 643d6c7c88..bdaa78fd32 100644
--- a/sysdeps/unix/sysv/linux/sparc/init-first.c
+++ b/sysdeps/unix/sysv/linux/sparc/init-first.c
@@ -28,13 +28,11 @@ long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
 static inline void
 _libc_vdso_platform_setup (void)
 {
-  PREPARE_VERSION_KNOWN (linux_version, LINUX_2_6);
-
-  void *p = _dl_vdso_vsym ("__vdso_gettimeofday", &linux_version);
+  void *p = get_vdso_symbol ("__vdso_gettimeofday");
   PTR_MANGLE (p);
   VDSO_SYMBOL (gettimeofday) = p;
 
-  p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux_version);
+  p = get_vdso_symbol ("__vdso_clock_gettime");
   PTR_MANGLE (p);
   VDSO_SYMBOL (clock_gettime) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 981b2a26b7..3bfb1fc60e 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -41,6 +41,9 @@
     _ret;								\
   })
 
+# define VDSO_NAME  "LINUX_2_6"
+# define VDSO_HASH  61765110
+
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETTIME_VSYSCALL	1
 # define HAVE_GETTIMEOFDAY_VSYSCALL	1
diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c
index 8886ccd707..3ceab633e5 100644
--- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/x86/gettimeofday.c
@@ -22,6 +22,8 @@
 
 # include <dl-vdso.h>
 # include <errno.h>
+# include <sysdep-vdso.h>
+# include <sysdep-vdso.h>
 
 static int
 __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
@@ -36,12 +38,12 @@ __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
 #  define __gettimeofday_type __gettimeofday
 # endif
 
-# undef INIT_ARCH
-# define INIT_ARCH() PREPARE_VERSION_KNOWN (linux26, LINUX_2_6)
+# define INIT_ARCH()
+
 /* If the vDSO is not available we fall back to syscall.  */
 libc_ifunc_hidden (__gettimeofday_type, __gettimeofday,
-		   (_dl_vdso_vsym ("__vdso_gettimeofday", &linux26)
-		    ?: &__gettimeofday_syscall))
+		   (get_vdso_symbol ("__vdso_gettimeofday")
+		    ?: __gettimeofday_syscall));
 libc_hidden_def (__gettimeofday)
 
 #else
diff --git a/sysdeps/unix/sysv/linux/x86/time.c b/sysdeps/unix/sysv/linux/x86/time.c
index 3d72488500..60e6d1b7c0 100644
--- a/sysdeps/unix/sysv/linux/x86/time.c
+++ b/sysdeps/unix/sysv/linux/x86/time.c
@@ -22,6 +22,7 @@
 
 #include <dl-vdso.h>
 #include <errno.h>
+#include <sysdep-vdso.h>
 
 static time_t
 __time_syscall (time_t *t)
@@ -38,11 +39,11 @@ __time_syscall (time_t *t)
 # endif
 
 #undef INIT_ARCH
-#define INIT_ARCH() PREPARE_VERSION_KNOWN (linux26, LINUX_2_6);
+#define INIT_ARCH()
+
 /* If the vDSO is not available we fall back on the syscall.  */
 libc_ifunc_hidden (time_type, time,
-		   (_dl_vdso_vsym ("__vdso_time", &linux26)
-		    ?:  &__time_syscall))
+		   (get_vdso_symbol ("__vdso_time") ?: __time_syscall))
 libc_hidden_def (time)
 
 #else
diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c
index 6a347becbe..aede1c858d 100644
--- a/sysdeps/unix/sysv/linux/x86_64/init-first.c
+++ b/sysdeps/unix/sysv/linux/x86_64/init-first.c
@@ -32,15 +32,13 @@ extern __typeof (clock_gettime) __syscall_clock_gettime attribute_hidden;
 static inline void
 __vdso_platform_setup (void)
 {
-  PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
-
-  void *p = _dl_vdso_vsym ("__vdso_clock_gettime", &linux26);
+  void *p = get_vdso_symbol ("__vdso_clock_gettime");
   if (p == NULL)
     p = __syscall_clock_gettime;
   PTR_MANGLE (p);
   VDSO_SYMBOL(clock_gettime) = p;
 
-  p = _dl_vdso_vsym ("__vdso_getcpu", &linux26);
+  p = get_vdso_symbol ("__vdso_getcpu");
   PTR_MANGLE (p);
   VDSO_SYMBOL(getcpu) = p;
 }
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 0a3ddd37e1..197329f4dc 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -370,6 +370,9 @@
 # undef INTERNAL_SYSCALL_ERRNO
 # define INTERNAL_SYSCALL_ERRNO(val, err)	(-(val))
 
+# define VDSO_NAME  "LINUX_2.6"
+# define VDSO_HASH  61765110
+
 /* List of system calls which are supported as vsyscalls.  */
 # define HAVE_CLOCK_GETTIME_VSYSCALL    1
 # define HAVE_GETTIMEOFDAY_VSYSCALL     1
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 11/12] linux: Consolidate time implementation
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
                   ` (6 preceding siblings ...)
  2019-06-14 15:29 ` [PATCH 03/12] s390: Enable VDSO for static linking Adhemerval Zanella
@ 2019-06-14 15:29 ` Adhemerval Zanella
  2019-06-25 18:24   ` Florian Weimer
                     ` (2 more replies)
  2019-06-14 15:29 ` [PATCH 10/12] sparc64: Use linux generic " Adhemerval Zanella
                   ` (3 subsequent siblings)
  11 siblings, 3 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

The time syscall has currently 3 possible implementations:

   1. Wire-up __NR_time with a vDSO implementation (currently only x86 and
      powerpc).
   2. Wire-up __NR_time (hppa, i686, m68k, microblaze, mips, powerpc,
      powerpc64, s390, sh4, sparcv9, x86_64).
   3. Using internal gettimeofday (aarch64, alpha, arm, mips64, mips64-n32,
      nios2, s390x, sparc64).

This patch consolidates all implementation on Linux generic
sysdeps/unix/sysv/linux/time.c.  To simplify the code, some changes are
made:

   * The wire-up with vDSO implementation route external calls directly
     to vDSO through IFUNC.  To enable it the architecture need to
     explicit define USE_TIME_VSYSCALL_IFUNC.

   * Also, powerpc and x86 tries to route internal time usages to
     IFUNC mechanism, which is problematic since powerpc32 and i686 does
     not really support it.  Instead, all internal calls are routed to
     a default internal symbol which in turn calls INTERNAL_VSYSCALL.

   * Static linking also uses the fallback mechanism which calls
     INTERNAL_VSYSCALL, so vDSO is used for this case as well.

The generic implementation issues a syscall as default, calls the
vDSO if the architecture defines HAVE_TIME_VSYSCALL, and route the external
calls to iFUNC if the architecture also defines USE_TIME_VSYSCALL_IFUNC.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
powerpc64-linux-gnu, powerpc64le-linux-gnu, and aarch64-linux-gnu.

	* include/libc-symbols.h (hidden_def_redir): New macro.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (HAVE_TIME_VSYSCALL,
	USE_TIME_VSYSCALL_IFUNC): Define.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (HAVE_TIME_VSYSCALL,
	USE_TIME_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h (USE_TIME_VSYSCALL_IFUNC):
	Likewise.
	* sysdeps/unix/sysv/linux/i386/time.c: Remove file.
	* sysdeps/unix/sysv/linux/x86/time.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/time.c: Likewise.
	* sysdeps/unix/sysv/linux/time.c (time): Handle all possible Linux
	implementations (wire-up syscall, vDSO implementation, iFUNC).
	(time_syscall): New function.
---
 include/libc-symbols.h                   |  5 ++
 sysdeps/unix/sysv/linux/i386/sysdep.h    |  2 +
 sysdeps/unix/sysv/linux/i386/time.c      | 34 ----------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h |  1 +
 sysdeps/unix/sysv/linux/powerpc/time.c   | 83 ------------------------
 sysdeps/unix/sysv/linux/time.c           | 53 ++++++++++++---
 sysdeps/unix/sysv/linux/x86/time.c       | 60 -----------------
 sysdeps/unix/sysv/linux/x86_64/sysdep.h  |  2 +
 8 files changed, 55 insertions(+), 185 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/i386/time.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/time.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/time.c

diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index b68ec4b7f5..dc6f2e31e2 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -548,6 +548,7 @@ for linking")
 #  define hidden_ver(local, name)	__hidden_ver1(local, __GI_##name, name);
 #  define hidden_data_ver(local, name)	hidden_ver(local, name)
 #  define hidden_def(name)		__hidden_ver1(__GI_##name, name, name);
+#  define hidden_def_redir(redir, name)	__hidden_ver1(redir, __GI_##name, redir);
 #  define hidden_data_def(name)		hidden_def(name)
 #  define hidden_tls_def(name)				\
   __hidden_ver2 (__thread, __GI_##name, name, name);
@@ -575,6 +576,7 @@ for linking")
    hidden_proto doesn't make sense for assembly but the equivalent
    is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET.  */
 #  define hidden_def(name)	strong_alias (name, __GI_##name)
+#  define hidden_def_redir(redir, name)	strong_alias(redir, __GI_##name);
 #  define hidden_weak(name)	hidden_def (name)
 #  define hidden_ver(local, name) strong_alias (local, __GI_##name)
 #  define hidden_data_def(name)	strong_data_alias (name, __GI_##name)
@@ -605,6 +607,7 @@ for linking")
 # endif /* Not  __ASSEMBLER__ */
 # define hidden_weak(name)
 # define hidden_def(name)
+# define hidden_def_redir(redir, name)
 # define hidden_ver(local, name)
 # define hidden_data_weak(name)
 # define hidden_data_def(name)
@@ -617,6 +620,7 @@ for linking")
 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
 # define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
 # define libc_hidden_def(name) hidden_def (name)
+# define libc_hidden_def_redir(redir, name) hidden_def_redir (redir, name)
 # define libc_hidden_weak(name) hidden_weak (name)
 # ifdef LINK_OBSOLETE_RPC
    /* libc_hidden_nolink_sunrpc should only get used in sunrpc code.  */
@@ -633,6 +637,7 @@ for linking")
 # define libc_hidden_proto(name, attrs...)
 # define libc_hidden_tls_proto(name, attrs...)
 # define libc_hidden_def(name)
+# define libc_hidden_def_redir(redir, name)
 # define libc_hidden_weak(name)
 # define libc_hidden_ver(local, name)
 # define libc_hidden_data_def(name)
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index e793fdc936..4f79f25989 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 USE_TIME_VSYSCALL_IFUNC	1
 
 /* 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/i386/time.c b/sysdeps/unix/sysv/linux/i386/time.c
deleted file mode 100644
index 440e3e6ab4..0000000000
--- a/sysdeps/unix/sysv/linux/i386/time.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* time -- Get number of seconds since Epoch.  Linux/i386 version.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifdef SHARED
-# define time __redirect_time
-#endif
-
-#include <time.h>
-
-#ifdef SHARED
-# undef time
-# define time_type __redirect_time
-
-# undef libc_hidden_def
-# define libc_hidden_def(name)  \
-  __hidden_ver1 (__time_syscall, __GI_time, __time_syscall);
-#endif
-
-#include <sysdeps/unix/sysv/linux/x86/time.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index cf967a8c33..44bfa3f1b6 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -24,6 +24,7 @@
 #define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 #define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
 #define HAVE_TIME_VSYSCALL		"__kernel_time"
+#define USE_TIME_VSYSCALL_IFUNC		1
 #define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
 #define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c
deleted file mode 100644
index ca6721cf95..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/time.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* time system call for Linux/PowerPC.
-   Copyright (C) 2013-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifdef SHARED
-# ifndef __powerpc64__
-#  define time __redirect_time
-# else
-#  define __redirect_time time
-# endif
-
-# include <time.h>
-# include <sysdep.h>
-# include <dl-vdso.h>
-# include <libc-vdso.h>
-# include <dl-machine.h>
-
-# ifndef __powerpc64__
-#  undef time
-
-time_t
-__time_vsyscall (time_t *t)
-{
-  return INLINE_VSYSCALL (time, 1, t);
-}
-
-/* __GI_time is defined as hidden and for ppc32 it enables the
-   compiler make a local call (symbol@local) for internal GLIBC usage. It
-   means the PLT won't be used and the ifunc resolver will be called directly.
-   For ppc64 a call to a function in another translation unit might use a
-   different toc pointer thus disallowing direct branchess and making internal
-   ifuncs calls safe.  */
-#  undef libc_hidden_def
-#  define libc_hidden_def(name)					\
-  __hidden_ver1 (__time_vsyscall, __GI_time, __time_vsyscall);
-
-# endif /* !__powerpc64__  */
-
-static time_t
-time_syscall (time_t *t)
-{
-  struct timeval tv;
-  time_t result;
-
-  if (INLINE_VSYSCALL (gettimeofday, 2, &tv, NULL) < 0)
-    result = (time_t) -1;
-  else
-    result = (time_t) tv.tv_sec;
-
-  if (t != NULL)
-    *t = result;
-  return result;
-}
-
-# define INIT_ARCH()							\
-  void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL);
-
-/* If the vDSO is not available we fall back to the syscall.  */
-libc_ifunc_hidden (__redirect_time, time,
-		   vdso_time
-		   ? vdso_time
-		   : (void *) time_syscall);
-libc_hidden_def (time)
-
-#else
-
-#include <sysdeps/posix/time.c>
-
-#endif /* !SHARED */
diff --git a/sysdeps/unix/sysv/linux/time.c b/sysdeps/unix/sysv/linux/time.c
index 1978f6d817..93e036fe16 100644
--- a/sysdeps/unix/sysv/linux/time.c
+++ b/sysdeps/unix/sysv/linux/time.c
@@ -15,27 +15,64 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <stddef.h>
+/* Currently we have 3 possible time implementations, which is also selected
+   in the order:
+
+   1. Wire-up __NR_time with a vDSO implementation (currently only x86 and
+      powerpc).
+   2. Only wire-up __NR_time (usually old kABIs).
+   3. Using internal gettimeofday (which may call a vDSO as well).  */
+
+#define time __redirect_time
 #include <time.h>
+#undef time
+#include <sys/time.h>
 
 #include <sysdep.h>
+#ifdef HAVE_TIME_VSYSCALL
+# define HAVE_VSYSCALL
+#endif
+#include <sysdep-vdso.h>
+#include <libc-vdso.h>
 
-#ifdef __NR_time
-
-time_t
-time (time_t *t)
+static time_t
+time_syscall (time_t *t)
 {
+  time_t res;
+#ifdef __NR_time
   INTERNAL_SYSCALL_DECL (err);
-  time_t res = INTERNAL_SYSCALL (time, err, 1, NULL);
+  res = INTERNAL_VSYSCALL (time, err, 1, NULL);
   /* There cannot be any error.  */
+#else
+  struct timeval tv;
+  /* gettimeofday does not fail with valid 'tv' and null timezone.  */
+  __gettimeofday (&tv, NULL);
+  res = tv.tv_sec;
+#endif
   if (t != NULL)
     *t = res;
   return res;
 }
-libc_hidden_def (time)
 
+#if HAVE_IFUNC && defined USE_TIME_VSYSCALL_IFUNC
+/* Route externals calls direct to vDSO and static and internal calls to
+   fallback implementation (which also might call the vDSO).  */
+# ifdef SHARED
+#  define INIT_ARCH()
+libc_ifunc_redirected (__redirect_time, time,
+		       get_vdso_symbol (HAVE_TIME_VSYSCALL)
+		       ?: time_syscall);
+libc_hidden_def_redir (time_syscall, time)
+#  else
+strong_alias (time_syscall, time)
+#  endif /* SHARED  */
 #else
 
-# include <sysdeps/posix/time.c>
+time_t
+time (time_t *t)
+{
+  return time_syscall (t);
+}
+libc_hidden_def_redir (time, time)
 
 #endif
diff --git a/sysdeps/unix/sysv/linux/x86/time.c b/sysdeps/unix/sysv/linux/x86/time.c
deleted file mode 100644
index 60e6d1b7c0..0000000000
--- a/sysdeps/unix/sysv/linux/x86/time.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* time -- Get number of seconds since Epoch.  Linux/x86 version.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <time.h>
-
-#ifdef SHARED
-
-#include <dl-vdso.h>
-#include <errno.h>
-#include <sysdep-vdso.h>
-
-static time_t
-__time_syscall (time_t *t)
-{
-  INTERNAL_SYSCALL_DECL (err);
-  return INTERNAL_SYSCALL (time, err, 1, t);
-}
-
-# ifndef time_type
-/* The i386 time.c includes this file with a defined time_type macro.
-   For x86_64 we have to define it to time as the internal symbol is the
-   ifunc'ed one.  */
-#  define time_type time
-# endif
-
-#undef INIT_ARCH
-#define INIT_ARCH()
-
-/* If the vDSO is not available we fall back on the syscall.  */
-libc_ifunc_hidden (time_type, time,
-		   (get_vdso_symbol ("__vdso_time") ?: __time_syscall))
-libc_hidden_def (time)
-
-#else
-
-# include <sysdep.h>
-
-time_t
-time (time_t *t)
-{
-  INTERNAL_SYSCALL_DECL (err);
-  return INTERNAL_SYSCALL (time, err, 1, t);
-}
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 4541c0d492..c64fbd1e26 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -376,6 +376,8 @@
 /* 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 USE_TIME_VSYSCALL_IFUNC	1
 # define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
 
 # define SINGLE_THREAD_BY_GLOBAL		1
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 05/12] linux: Enable vDSO for static linking as default (BZ#19767)
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
                   ` (3 preceding siblings ...)
  2019-06-14 15:29 ` [PATCH 02/12] riscv: Enable VDSO for static linking Adhemerval Zanella
@ 2019-06-14 15:29 ` Adhemerval Zanella
  2019-06-17 19:57   ` Tulio Magno Quites Machado Filho
  2019-08-02 12:34   ` Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 08/12] powerpc: Refactor vsyscall internal macros Adhemerval Zanella
                   ` (6 subsequent siblings)
  11 siblings, 2 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

This patch assumes static vDSO is supported as default, it is now supported
on all current architectures that support vDSO.  It allows removing both
ALWAYS_USE_VSYSCALL define, which an architecture requires to explicit define
and USE_VSYSCALL (which defines vDSO only for shared or if architecture defines
ALWAYS_USE_VSYSCALL).

Checked with a build against all affected ABIs.

	[BZ #19767]
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h (ALWAYS_USE_VSYSCALL):
	Remove definition.
	* sysdeps/unix/sysv/linux/arm/sysdep.h (ALWAYS_USE_VSYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (ALWAYS_USE_VSYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h (ALWAYS_USE_VSYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
	(ALWAYS_USE_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
	(ALWAYS_USE_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
	(ALWAYS_USE_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
	(ALWAYS_USE_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/riscv/sysdep.h (ALWAYS_USE_VSYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
	(ALWAYS_USE_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
	(ALWAYS_USE_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h (ALWAYS_USE_VSYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (ALWAYS_USE_VSYSCALL):
	Likewise.
	* sysdeps/unix/sysv/linux/x86/libc-vdso.h: Remove #if USE_VSYSCALL.
	* sysdeps/unix/sysv/linux/sysdep-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/sysdep.h (ALWAYS_USE_VSYSCALL,
	USE_VSYSCALL): Remove defitions.
---
 sysdeps/unix/sysv/linux/aarch64/sysdep.h           | 3 ---
 sysdeps/unix/sysv/linux/arm/sysdep.h               | 3 ---
 sysdeps/unix/sysv/linux/i386/sysdep.h              | 3 ---
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h       | 3 ---
 sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h   | 3 ---
 sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h   | 3 ---
 sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h | 3 ---
 sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h | 3 ---
 sysdeps/unix/sysv/linux/riscv/sysdep.h             | 3 ---
 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h      | 3 ---
 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h      | 4 ----
 sysdeps/unix/sysv/linux/sparc/sysdep.h             | 3 ---
 sysdeps/unix/sysv/linux/sysdep-vdso.h              | 2 +-
 sysdeps/unix/sysv/linux/sysdep.h                   | 7 -------
 sysdeps/unix/sysv/linux/x86/libc-vdso.h            | 6 +-----
 sysdeps/unix/sysv/linux/x86_64/sysdep.h            | 3 ---
 16 files changed, 2 insertions(+), 53 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index 935c507f8c..a2f4061b58 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -19,9 +19,6 @@
 #ifndef _LINUX_AARCH64_SYSDEP_H
 #define _LINUX_AARCH64_SYSDEP_H 1
 
-/* Always enable vsyscalls on aarch64 */
-#define ALWAYS_USE_VSYSCALL 1
-
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/aarch64/sysdep.h>
 #include <sysdeps/unix/sysv/linux/generic/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
index 9b4ed8d6a5..6d8d9a47f9 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -20,9 +20,6 @@
 #ifndef _LINUX_ARM_SYSDEP_H
 #define _LINUX_ARM_SYSDEP_H 1
 
-/* Always enable vsyscalls on arm */
-#define ALWAYS_USE_VSYSCALL 1
-
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/arm/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 0be10744ff..77154b904a 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -19,9 +19,6 @@
 #ifndef _LINUX_I386_SYSDEP_H
 #define _LINUX_I386_SYSDEP_H 1
 
-/* Always enable vsyscalls on i386 */
-#define ALWAYS_USE_VSYSCALL 1
-
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/i386/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index 5a2704e3e8..a310a0acbc 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -18,9 +18,6 @@
 #ifndef _LINUX_MIPS_MIPS32_SYSDEP_H
 #define _LINUX_MIPS_MIPS32_SYSDEP_H 1
 
-/* Always enable vsyscalls on mips32.  */
-#define ALWAYS_USE_VSYSCALL 1
-
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips32/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
index a4f3547030..d83e08f96a 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
@@ -18,9 +18,6 @@
 #ifndef _LINUX_MIPS_SYSDEP_H
 #define _LINUX_MIPS_SYSDEP_H 1
 
-/* Always enable vsyscalls on n32.  */
-#define ALWAYS_USE_VSYSCALL 1
-
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips64/n32/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
index 5b4d27757d..bcfaf561a1 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
@@ -18,9 +18,6 @@
 #ifndef _LINUX_MIPS_SYSDEP_H
 #define _LINUX_MIPS_SYSDEP_H 1
 
-/* Always enable vsyscalls on n64.  */
-#define ALWAYS_USE_VSYSCALL 1
-
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/mips/mips64/n64/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
index bdbab8e41b..62caa265d7 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
@@ -18,9 +18,6 @@
 #ifndef _LINUX_POWERPC_SYSDEP_H
 #define _LINUX_POWERPC_SYSDEP_H 1
 
-/* Always enable vsyscalls on powerpc32 */
-#define ALWAYS_USE_VSYSCALL 1
-
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/powerpc/sysdep.h>
 #include <tls.h>
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index 294517e3f3..4122e5c4a9 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -20,9 +20,6 @@
 #ifndef _LINUX_POWERPC_SYSDEP_H
 #define _LINUX_POWERPC_SYSDEP_H 1
 
-/* Always enable vsyscalls on powerpc64 */
-#define ALWAYS_USE_VSYSCALL 1
-
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/powerpc/sysdep.h>
 #include <tls.h>
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index caf013a9a1..5470ea3d2a 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -19,9 +19,6 @@
 #ifndef _LINUX_RISCV_SYSDEP_H
 #define _LINUX_RISCV_SYSDEP_H 1
 
-/* Always enable vsyscalls on riscv */
-#define ALWAYS_USE_VSYSCALL 1
-
 #include <sysdeps/unix/sysv/linux/generic/sysdep.h>
 #include <tls.h>
 
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
index 47d1c5cdb2..640fb52de1 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
@@ -19,9 +19,6 @@
 #ifndef _LINUX_S390_SYSDEP_H
 #define _LINUX_S390_SYSDEP_H
 
-/* Always enable vsyscalls on s390-32.  */
-#define ALWAYS_USE_VSYSCALL 1
-
 #include <sysdeps/s390/s390-32/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
index 95829390e2..9a9834c750 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
@@ -20,10 +20,6 @@
 #ifndef _LINUX_S390_SYSDEP_H
 #define _LINUX_S390_SYSDEP_H
 
-/* Always enable vsyscalls on s390-64.  */
-#define ALWAYS_USE_VSYSCALL 1
-
-
 #include <sysdeps/s390/s390-64/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index fc4053c5ce..981b2a26b7 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -19,9 +19,6 @@
 #ifndef _LINUX_SPARC_SYSDEP_H
 #define _LINUX_SPARC_SYSDEP_H 1
 
-/* Always enable vsyscalls on sparc */
-#define ALWAYS_USE_VSYSCALL 1
-
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/sparc/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
index c5a1ae0670..5fec208380 100644
--- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
+++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
@@ -26,7 +26,7 @@
      funcptr (args)
 #endif
 
-#if USE_VSYSCALL && defined HAVE_VSYSCALL
+#ifdef HAVE_VSYSCALL
 
 # include <libc-vdso.h>
 
diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
index f94cfa2fa9..af1c9a26fe 100644
--- a/sysdeps/unix/sysv/linux/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sysdep.h
@@ -18,13 +18,6 @@
 #include <bits/wordsize.h>
 #include <kernel-features.h>
 
-/* By default only shared builds use vdso. */
-#ifndef ALWAYS_USE_VSYSCALL
-#define ALWAYS_USE_VSYSCALL 0
-#endif
-
-#define USE_VSYSCALL (defined (SHARED) || ALWAYS_USE_VSYSCALL)
-
 /* Set error number and return -1.  A target may choose to return the
    internal function, __syscall_error, which sets errno and returns -1.
    We use -1l, instead of -1, so that it can be casted to (void *).  */
diff --git a/sysdeps/unix/sysv/linux/x86/libc-vdso.h b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
index ea35c71664..c9aa1c8a72 100644
--- a/sysdeps/unix/sysv/linux/x86/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
@@ -22,9 +22,7 @@
 #include <time.h>
 #include <sys/time.h>
 
-#if USE_VSYSCALL
-
-# include <sysdep-vdso.h>
+#include <sysdep-vdso.h>
 
 extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
   attribute_hidden;
@@ -32,6 +30,4 @@ extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
 extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
   attribute_hidden;
 
-#endif
-
 #endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index b88c46b589..0a3ddd37e1 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -18,9 +18,6 @@
 #ifndef _LINUX_X86_64_SYSDEP_H
 #define _LINUX_X86_64_SYSDEP_H 1
 
-/* Always enable vsyscalls on x86_64 */
-#define ALWAYS_USE_VSYSCALL 1
-
 /* There is some commonality.  */
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/unix/x86_64/sysdep.h>
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 07/12] Refactor vDSO initialization code
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
@ 2019-06-14 15:29 ` Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 12/12] linux: Consolidate gettimeofday implementation Adhemerval Zanella
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

Linux vDSO initialization code the internal function pointers require a lot
of duplicated boilerplate over different architectures.  This patch aims to
simplify not only the code but the required definition to enable a vDSO
symbol to be enabled and used internally on glibc.

The changes are:

  1. Consolidate all init-first.c on only one implementation and enable
     the symbol based on HAVE_*_VSYSCALL existence.

  2. Set the HAVE_*_VSYSCALL to the architecture expected names string.

  3. Add a new internal implementation, get_vdso_mangle_symbol, which
     returns a mangled function pointer.

Currently the clock_gettime, clock_getres, gettimeofday, getcpu, and time
are handled in an arch-independent way, powerpc still uses some arch-specific
vDSO symbol handled in a specific init-first implementation.

Checked on aarch64-linux-gnu, arm-linux-gnueabihf, i386-linux-gnu,
mips64-linux-gnu, powerpc64le-linux-gnu, s390x-linux-gu, sparc64-linux-gnu,
and x86_64-linux-gnu.

	* sysdeps/powerpc/powerpc32/backtrace.c (is_sigtramp_address,
	is_sigtramp_address_rt): Use HAVE_SIGTRAMP_{RT}32 instead of SHARED.
	* sysdeps/powerpc/powerpc64/backtrace.c (is_sigtramp_address):
	Likewise.
	* sysdeps/unix/sysv/linux/aarch64/init-first.c: Remove file.
	* sysdeps/unix/sysv/linux/aarch64/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/mips/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/riscv/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/riscv/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/s390/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/sparc/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/init-first.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h
	(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL): Define value based on kernel exported
	name.
	* sysdeps/unix/sysv/linux/arm/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h
	(HAVE_CLOCK_GETRES_VSYSCALL, HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETCPU_VSYSCALL, HAVE_TIME_VSYSCALL, HAVE_GET_TBFREQ,
	HAVE_SIGTRAMP_RT64, HAVE_SIGTRAMP_32, HAVE_SIGTRAMP_RT32): Likewise.
	* sysdeps/unix/sysv/linux/riscv/sysdep.h (HAVE_CLOCK_GETRES_VSYSCALL,
	HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
	HAVE_GETCPU_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/s390/sysdep.h (HAVE_CLOCK_GETRES_VSYSCALL,
	HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
	HAVE_GETCPU_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h (HAVE_CLOCK_GETTIME_VSYSCALL,
	HAVE_GETTIMEOFDAY_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h
	(HAVE_CLOCK_GETTIME_VSYSCALL, HAVE_GETTIMEOFDAY_VSYSCALL,
	HAVE_GETCPU_VSYSCALL): Likewise.
	* sysdeps/unix/sysv/linux/dl-vdso.h (VDSO_NAME, VDSO_HASH): Define to
	invalid names if architecture does not define them.
	(get_vdso_mangle_symbol): New symbol.
	* sysdeps/unix/sysv/linux/init-first.c: New file.
	* sysdeps/unix/sysv/linux/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/init-first.c (gettimeofday,
	clock_gettime, clock_getres, getcpu, time): Remove declaration.
	(__libc_vdso_platform_setup_arch): Likewise and use
	get_vdso_mangle_symbol to setup vDSO symbols.
	(sigtramp_rt64, sigtramp32, sigtramp_rt32, get_tbfreq): Add
	attribute_hidden.
	* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/sysdep-vdso.h (VDSO_SYMBOL): Remove
	definition.
---
 sysdeps/powerpc/powerpc32/backtrace.c         |  4 +-
 sysdeps/powerpc/powerpc64/backtrace.c         |  2 +-
 sysdeps/unix/sysv/linux/aarch64/init-first.c  | 44 ----------
 sysdeps/unix/sysv/linux/aarch64/sysdep.h      |  6 +-
 sysdeps/unix/sysv/linux/arm/init-first.c      | 41 ----------
 sysdeps/unix/sysv/linux/arm/libc-vdso.h       | 29 -------
 sysdeps/unix/sysv/linux/arm/sysdep.h          |  4 +-
 sysdeps/unix/sysv/linux/dl-vdso.h             | 21 ++++-
 sysdeps/unix/sysv/linux/i386/init-first.c     | 46 -----------
 sysdeps/unix/sysv/linux/i386/sysdep.h         |  4 +-
 sysdeps/unix/sysv/linux/init-first.c          | 80 +++++++++++++++++++
 .../unix/sysv/linux/{aarch64 => }/libc-vdso.h | 18 ++++-
 sysdeps/unix/sysv/linux/mips/init-first.c     | 40 ----------
 sysdeps/unix/sysv/linux/mips/libc-vdso.h      | 29 -------
 sysdeps/unix/sysv/linux/mips/sysdep.h         |  4 +-
 sysdeps/unix/sysv/linux/powerpc/init-first.c  | 51 +++---------
 sysdeps/unix/sysv/linux/powerpc/libc-vdso.h   | 12 +--
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      | 14 +++-
 sysdeps/unix/sysv/linux/riscv/init-first.c    | 54 -------------
 sysdeps/unix/sysv/linux/riscv/libc-vdso.h     | 34 --------
 sysdeps/unix/sysv/linux/riscv/sysdep.h        |  8 +-
 sysdeps/unix/sysv/linux/s390/init-first.c     | 54 -------------
 sysdeps/unix/sysv/linux/s390/libc-vdso.h      | 35 --------
 sysdeps/unix/sysv/linux/s390/sysdep.h         |  8 +-
 sysdeps/unix/sysv/linux/sparc/init-first.c    | 42 ----------
 sysdeps/unix/sysv/linux/sparc/libc-vdso.h     | 29 -------
 sysdeps/unix/sysv/linux/sparc/sysdep.h        |  4 +-
 sysdeps/unix/sysv/linux/sysdep-vdso.h         |  2 +-
 sysdeps/unix/sysv/linux/x86/libc-vdso.h       | 33 --------
 sysdeps/unix/sysv/linux/x86_64/init-first.c   | 48 -----------
 sysdeps/unix/sysv/linux/x86_64/sysdep.h       |  6 +-
 31 files changed, 164 insertions(+), 642 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/aarch64/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/arm/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/i386/init-first.c
 create mode 100644 sysdeps/unix/sysv/linux/init-first.c
 rename sysdeps/unix/sysv/linux/{aarch64 => }/libc-vdso.h (70%)
 delete mode 100644 sysdeps/unix/sysv/linux/mips/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/mips/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/riscv/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/riscv/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/s390/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/s390/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/sparc/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/x86/libc-vdso.h
 delete mode 100644 sysdeps/unix/sysv/linux/x86_64/init-first.c

diff --git a/sysdeps/powerpc/powerpc32/backtrace.c b/sysdeps/powerpc/powerpc32/backtrace.c
index 857a8aad7b..2978632017 100644
--- a/sysdeps/powerpc/powerpc32/backtrace.c
+++ b/sysdeps/powerpc/powerpc32/backtrace.c
@@ -54,7 +54,7 @@ struct signal_frame_32 {
 static inline int
 is_sigtramp_address (void *nip)
 {
-#ifdef SHARED
+#ifdef HAVE_SIGTRAMP_RT32
   if (nip == VDSO_SYMBOL (sigtramp32))
     return 1;
 #endif
@@ -71,7 +71,7 @@ struct rt_signal_frame_32 {
 static inline int
 is_sigtramp_address_rt (void * nip)
 {
-#ifdef SHARED
+#ifdef HAVE_SIGTRAMP_32
   if (nip == VDSO_SYMBOL (sigtramp_rt32))
     return 1;
 #endif
diff --git a/sysdeps/powerpc/powerpc64/backtrace.c b/sysdeps/powerpc/powerpc64/backtrace.c
index 7a167838d9..0fa7e9c403 100644
--- a/sysdeps/powerpc/powerpc64/backtrace.c
+++ b/sysdeps/powerpc/powerpc64/backtrace.c
@@ -57,7 +57,7 @@ struct signal_frame_64 {
 static inline int
 is_sigtramp_address (void *nip)
 {
-#ifdef SHARED
+#ifdef HAVE_SIGTRAMP_RT64
   if (nip == VDSO_SYMBOL (sigtramp_rt64))
     return 1;
 #endif
diff --git a/sysdeps/unix/sysv/linux/aarch64/init-first.c b/sysdeps/unix/sysv/linux/aarch64/init-first.c
deleted file mode 100644
index c3c27cfd4b..0000000000
--- a/sysdeps/unix/sysv/linux/aarch64/init-first.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/* Copyright (C) 2007-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
-int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__kernel_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL(gettimeofday) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL(clock_gettime) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_getres");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL(clock_getres) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index 662d321235..d57f7232e2 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -160,9 +160,9 @@
 # endif
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETRES_VSYSCALL	1
-# define HAVE_CLOCK_GETTIME_VSYSCALL	1
-# define HAVE_GETTIMEOFDAY_VSYSCALL	1
+# define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
+# define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
+# define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
 
 /* Previously AArch64 used the generic version without the libc_hidden_def
    which lead in a non existent __send symbol in libc.so.  */
diff --git a/sysdeps/unix/sysv/linux/arm/init-first.c b/sysdeps/unix/sysv/linux/arm/init-first.c
deleted file mode 100644
index 2852ab135c..0000000000
--- a/sysdeps/unix/sysv/linux/arm/init-first.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.  Linux/ARM.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-#include <sysdep-vdso.h>
-
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
-int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__vdso_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/arm/libc-vdso.h b/sysdeps/unix/sysv/linux/arm/libc-vdso.h
deleted file mode 100644
index 8702165c6b..0000000000
--- a/sysdeps/unix/sysv/linux/arm/libc-vdso.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* VDSO function pointer declarations.  Linux/ARM.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <sysdep-vdso.h>
-
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
-extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
index 467ccf2631..634aa2bc6b 100644
--- a/sysdeps/unix/sysv/linux/arm/sysdep.h
+++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
@@ -392,8 +392,8 @@ __local_syscall_error:						\
 #define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
+#define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_gettimeofday"
+#define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_clock_gettime"
 
 #define LOAD_ARGS_0()
 #define ASM_ARGS_0
diff --git a/sysdeps/unix/sysv/linux/dl-vdso.h b/sysdeps/unix/sysv/linux/dl-vdso.h
index bab3779615..dcf065ef23 100644
--- a/sysdeps/unix/sysv/linux/dl-vdso.h
+++ b/sysdeps/unix/sysv/linux/dl-vdso.h
@@ -19,16 +19,25 @@
 #ifndef _DL_VDSO_H
 #define _DL_VDSO_H	1
 
-#include <assert.h>
 #include <ldsodefs.h>
 #include <dl-hash.h>
-#include <libc-vdso.h>
 
 /* Functions for resolving symbols in the VDSO link map.  */
 extern void *_dl_vdso_vsym (const char *name,
 			    const struct r_found_version *version)
       attribute_hidden;
 
+/* If the architecture support vDSO it should define which is the expected
+   kernel version and hash value through both VDSO_NAME and VDSO_HASH
+   (usually defined at architecture sysdep.h).  */
+
+#ifndef VDSO_NAME
+# define VDSO_NAME "LINUX_0.0"
+#endif
+#ifndef VDSO_HASH
+# define VDSO_HASH 0
+#endif
+
 static inline void *
 get_vdso_symbol (const char *symbol)
 {
@@ -36,4 +45,12 @@ get_vdso_symbol (const char *symbol)
   return _dl_vdso_vsym (symbol, &rfv);
 }
 
+static inline void *
+get_vdso_mangle_symbol (const char *symbol)
+{
+  void *vdsop = get_vdso_symbol (symbol);
+  PTR_MANGLE (vdsop);
+  return vdsop;
+}
+
 #endif /* dl-vdso.h */
diff --git a/sysdeps/unix/sysv/linux/i386/init-first.c b/sysdeps/unix/sysv/linux/i386/init-first.c
deleted file mode 100644
index 9c03f87b67..0000000000
--- a/sysdeps/unix/sysv/linux/i386/init-first.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.  Linux/i386.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <time.h>
-#include <sysdep.h>
-#include <dl-vdso.h>
-#include <sysdep-vdso.h>
-
-long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
-  attribute_hidden;
-
-static long int
-clock_gettime_syscall (clockid_t id, struct timespec *tp)
-{
-  INTERNAL_SYSCALL_DECL (err);
-  return INTERNAL_SYSCALL (clock_gettime, err, 2, id, tp);
-}
-
-static inline void
-__vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_clock_gettime");
-  if (p == NULL)
-    p = clock_gettime_syscall;
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-}
-
-#define VDSO_SETUP __vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 278028f52e..e793fdc936 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -313,8 +313,8 @@ struct libc_do_syscall_args
 # define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETTIME_VSYSCALL    1
-# define HAVE_GETTIMEOFDAY_VSYSCALL     1
+# define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
+# define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
 
 /* 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/init-first.c b/sysdeps/unix/sysv/linux/init-first.c
new file mode 100644
index 0000000000..194194d319
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/init-first.c
@@ -0,0 +1,80 @@
+/* vDSO internal symbols.  Linux generic 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <dl-vdso.h>
+#include <libc-vdso.h>
+
+/* vDSO symbol used on clock_gettime implementation.  */
+#ifdef HAVE_CLOCK_GETTIME_VSYSCALL
+int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
+  attribute_hidden;
+#endif
+/* vDSO symbol used on clock_getres implementation.  */
+#ifdef HAVE_CLOCK_GETRES_VSYSCALL
+int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *)
+  attribute_hidden;
+#endif
+/* vDSO symbol used on gettimeofday implementation.  */
+#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
+int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
+  attribute_hidden;
+#endif
+/* vDSO symbol used on GNU extension getcpu implementation.  */
+#ifdef HAVE_GETCPU_VSYSCALL
+long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
+   attribute_hidden;
+#endif
+/* vDSO symbol used on time implementation.  */
+#ifdef HAVE_TIME_VSYSCALL
+time_t (*VDSO_SYMBOL(time)) (time_t *) attribute_hidden;
+#endif
+
+static inline void
+__libc_vdso_platform_setup (void)
+{
+#ifdef HAVE_CLOCK_GETTIME_VSYSCALL
+  VDSO_SYMBOL(clock_gettime) 
+    = get_vdso_mangle_symbol (HAVE_CLOCK_GETTIME_VSYSCALL);
+#endif
+
+#ifdef HAVE_CLOCK_GETRES_VSYSCALL
+  VDSO_SYMBOL(clock_getres)
+    = get_vdso_mangle_symbol (HAVE_CLOCK_GETRES_VSYSCALL);
+#endif
+
+#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
+  VDSO_SYMBOL(gettimeofday)
+    = get_vdso_mangle_symbol (HAVE_GETTIMEOFDAY_VSYSCALL);
+#endif
+
+#ifdef HAVE_GETCPU_VSYSCALL
+  VDSO_SYMBOL(getcpu) = get_vdso_mangle_symbol (HAVE_GETCPU_VSYSCALL);
+#endif
+
+#ifdef HAVE_TIME_VSYSCALL
+  VDSO_SYMBOL(time) = get_vdso_mangle_symbol (HAVE_TIME_VSYSCALL);
+#endif
+
+#ifdef VDSO_SETUP_ARCH
+  VDSO_SETUP_ARCH ();
+#endif
+}
+
+#define VDSO_SETUP __libc_vdso_platform_setup
+
+#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/aarch64/libc-vdso.h b/sysdeps/unix/sysv/linux/libc-vdso.h
similarity index 70%
rename from sysdeps/unix/sysv/linux/aarch64/libc-vdso.h
rename to sysdeps/unix/sysv/linux/libc-vdso.h
index 3fcbaa9fce..f681868137 100644
--- a/sysdeps/unix/sysv/linux/aarch64/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/libc-vdso.h
@@ -19,12 +19,22 @@
 #ifndef _LIBC_VDSO_H
 #define _LIBC_VDSO_H
 
-#include <sysdep.h>
-#include <sysdep-vdso.h>
+#define VDSO_SYMBOL(__name) __vdso_##__name
 
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
+#ifdef HAVE_CLOCK_GETTIME_VSYSCALL
 extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
+#endif
+#ifdef HAVE_CLOCK_GETRES_VSYSCALL
 extern int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
+#endif
+#ifdef HAVE_GETTIMEOFDAY_VSYSCALL
+extern int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *);
+#endif
+#ifdef HAVE_GETCPU_VSYSCALL
+extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *);
+#endif
+#ifdef HAVE_TIME_VSYSCALL
+extern time_t (*VDSO_SYMBOL(time)) (time_t *);
+#endif
 
 #endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/mips/init-first.c b/sysdeps/unix/sysv/linux/mips/init-first.c
deleted file mode 100644
index 2a43bdc8b0..0000000000
--- a/sysdeps/unix/sysv/linux/mips/init-first.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.
-   Copyright (C) 2016-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *) attribute_hidden;
-int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__vdso_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/mips/libc-vdso.h b/sysdeps/unix/sysv/linux/mips/libc-vdso.h
deleted file mode 100644
index 344ea2d750..0000000000
--- a/sysdeps/unix/sysv/linux/mips/libc-vdso.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* VDSO function pointer declarations.
-   Copyright (C) 2016-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <sysdep-vdso.h>
-
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
-extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
index cabc590961..58a7244581 100644
--- a/sysdeps/unix/sysv/linux/mips/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
@@ -20,5 +20,5 @@
 #define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETTIME_VSYSCALL     1
-#define HAVE_GETTIMEOFDAY_VSYSCALL      1
+#define HAVE_CLOCK_GETTIME_VSYSCALL     "__vdso_gettimeofday"
+#define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_clock_gettime"
diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.c b/sysdeps/unix/sysv/linux/powerpc/init-first.c
index 0d46563ce3..6e72d9ca84 100644
--- a/sysdeps/unix/sysv/linux/powerpc/init-first.c
+++ b/sysdeps/unix/sysv/linux/powerpc/init-first.c
@@ -19,47 +19,18 @@
 #include <dl-vdso.h>
 #include <libc-vdso.h>
 
-int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-  attribute_hidden;
-int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
-unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
-int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *);
-time_t (*VDSO_SYMBOL(time)) (time_t *);
-
+unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void) attribute_hidden;
 #if defined(__PPC64__) || defined(__powerpc64__)
-void *VDSO_SYMBOL(sigtramp_rt64);
+void *VDSO_SYMBOL(sigtramp_rt64) attribute_hidden;
 #else
-void *VDSO_SYMBOL(sigtramp32);
-void *VDSO_SYMBOL(sigtramp_rt32);
+void *VDSO_SYMBOL(sigtramp32) attribute_hidden;
+void *VDSO_SYMBOL(sigtramp_rt32) attribute_hidden;
 #endif
 
 static inline void
-_libc_vdso_platform_setup (void)
+__libc_vdso_platform_setup_arch (void)
 {
-  void *p = get_vdso_symbol ("__kernel_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_getres");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_getres) = p;
-
-  p = get_vdso_symbol ("__kernel_get_tbfreq");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (get_tbfreq) = p;
-
-  p = get_vdso_symbol ("__kernel_getcpu");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (getcpu) = p;
-
-  p = get_vdso_symbol ("__kernel_time");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (time) = p;
+  VDSO_SYMBOL (get_tbfreq) = get_vdso_mangle_symbol (HAVE_GET_TBFREQ);
 
   /* PPC64 uses only one signal trampoline symbol, while PPC32 will use
      two depending if SA_SIGINFO is used (__kernel_sigtramp_rt32) or not
@@ -67,13 +38,13 @@ _libc_vdso_platform_setup (void)
      There is no need to pointer mangle these symbol because they will
      used only for pointer comparison.  */
 #if defined(__PPC64__) || defined(__powerpc64__)
-  VDSO_SYMBOL(sigtramp_rt64) =  get_vdso_symbol ("__kernel_sigtramp_rt64");
+  VDSO_SYMBOL(sigtramp_rt64) =  get_vdso_symbol (HAVE_SIGTRAMP_RT64);
 #else
-  VDSO_SYMBOL(sigtramp32) = get_vdso_symbol ("__kernel_sigtramp32");
-  VDSO_SYMBOL(sigtramp_rt32) = get_vdso_symbol ("__kernel_sigtramp_rt32");
+  VDSO_SYMBOL(sigtramp32) = get_vdso_symbol (HAVE_SIGTRAMP_32);
+  VDSO_SYMBOL(sigtramp_rt32) = get_vdso_symbol (HAVE_SIGTRAMP_RT32);
 #endif
 }
 
-#define VDSO_SETUP _libc_vdso_platform_setup
+#define VDSO_SETUP_ARCH __libc_vdso_platform_setup_arch
 
-#include <csu/init-first.c>
+#include <sysdeps/unix/sysv/linux/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
index f8184061c0..47e925493b 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
@@ -17,20 +17,14 @@
    <http://www.gnu.org/licenses/>.  */
 
 
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
+#ifndef _LIBC_POWERPC_VDSO_H
+#define _LIBC_POWERPC_VDSO_H
 
 #include <sysdep.h>
 #include <sysdep-vdso.h>
+#include_next <libc-vdso.h>
 
-extern int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-  attribute_hidden;
-extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-extern int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
 extern unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
-extern int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *);
-extern time_t (*VDSO_SYMBOL(time)) (time_t *);
-
 #if defined(__PPC64__) || defined(__powerpc64__)
 extern void *VDSO_SYMBOL(sigtramp_rt64);
 #else
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 5b411d0e8e..20167615c8 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -20,7 +20,15 @@
 #define VDSO_HASH  123718565
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	1
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETCPU_VSYSCALL		1
+#define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
+#define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
+#define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
+#define HAVE_TIME_VSYSCALL		"__kernel_time"
+#define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
+#if defined(__PPC64__) || defined(__powerpc64__)
+# define HAVE_SIGTRAMP_RT64		"__kernel_sigtramp_rt64"
+#else
+# define HAVE_SIGTRAMP_32		"__kernel_sigtramp32"
+# define HAVE_SIGTRAMP_RT32		"__kernel_sigtramp_rt32"
+#endif
diff --git a/sysdeps/unix/sysv/linux/riscv/init-first.c b/sysdeps/unix/sysv/linux/riscv/init-first.c
deleted file mode 100644
index f3d243a192..0000000000
--- a/sysdeps/unix/sysv/linux/riscv/init-first.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* RISC-V VDSO initialization
-   Copyright (C) 2017-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
-    attribute_hidden;
-long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
-    attribute_hidden;
-long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
-    attribute_hidden;
-long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
-    attribute_hidden;
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_getcpu");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (getcpu) = p;
-
-  p = get_vdso_symbol ("__vdso_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__vdso_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-
-  p = get_vdso_symbol ("__vdso_clock_getres");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_getres) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h b/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
deleted file mode 100644
index 2373292ab9..0000000000
--- a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* RISC-V VDSO function declarations
-   Copyright (C) 2017-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <sysdep-vdso.h>
-
-extern long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
-    attribute_hidden;
-extern long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
-    attribute_hidden;
-extern long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
-    attribute_hidden;
-extern long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
-    attribute_hidden;
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 5de773744c..22835aa12f 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -125,10 +125,10 @@
 # define VDSO_HASH  182943605
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETRES_VSYSCALL	1
-# define HAVE_CLOCK_GETTIME_VSYSCALL	1
-# define HAVE_GETTIMEOFDAY_VSYSCALL	1
-# define HAVE_GETCPU_VSYSCALL		1
+# define HAVE_CLOCK_GETRES_VSYSCALL	"__vdso_clock_getres"
+# define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_clock_gettime"
+# define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
+# define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
 
 /* Define a macro which expands into the inline wrapper code for a system
    call.  */
diff --git a/sysdeps/unix/sysv/linux/s390/init-first.c b/sysdeps/unix/sysv/linux/s390/init-first.c
deleted file mode 100644
index 63a12d95c8..0000000000
--- a/sysdeps/unix/sysv/linux/s390/init-first.c
+++ /dev/null
@@ -1,54 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.  Linux/s390.
-   Copyright (C) 2008-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
-
-long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
-  __attribute__ ((nocommon));
-
-long int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *)
-  __attribute__ ((nocommon));
-
-long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
-   attribute_hidden;
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__kernel_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-
-  p = get_vdso_symbol ("__kernel_clock_getres");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_getres) = p;
-
-  p = get_vdso_symbol ("__kernel_getcpu");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (getcpu) = p;
-}
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/s390/libc-vdso.h b/sysdeps/unix/sysv/linux/s390/libc-vdso.h
deleted file mode 100644
index cc97601383..0000000000
--- a/sysdeps/unix/sysv/linux/s390/libc-vdso.h
+++ /dev/null
@@ -1,35 +0,0 @@
-/* Resolve function pointers to VDSO functions.
-   Copyright (C) 2008-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
-   <http://www.gnu.org/licenses/>.  */
-
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <sysdep-vdso.h>
-
-extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
-
-extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-extern long int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
-
-extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
-   attribute_hidden;
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h
index eefbd8f007..386efb1896 100644
--- a/sysdeps/unix/sysv/linux/s390/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/sysdep.h
@@ -20,8 +20,8 @@
 #define VDSO_HASH  123718585
 
 /* List of system calls which are supported as vsyscalls.  */
-#define HAVE_CLOCK_GETRES_VSYSCALL	1
-#define HAVE_CLOCK_GETTIME_VSYSCALL	1
-#define HAVE_GETTIMEOFDAY_VSYSCALL	1
-#define HAVE_GETCPU_VSYSCALL		1
+#define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
+#define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
+#define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
+#define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
 
diff --git a/sysdeps/unix/sysv/linux/sparc/init-first.c b/sysdeps/unix/sysv/linux/sparc/init-first.c
deleted file mode 100644
index bdaa78fd32..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/init-first.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* SPARC VDSO initialization
-   Copyright (C) 2018-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
-    attribute_hidden;
-long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
-    attribute_hidden;
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_gettimeofday");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (gettimeofday) = p;
-
-  p = get_vdso_symbol ("__vdso_clock_gettime");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL (clock_gettime) = p;
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/libc-vdso.h b/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
deleted file mode 100644
index d20afcdf04..0000000000
--- a/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/* VDSO function pointer declarations.
-   Copyright (C) 2018-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <sysdep-vdso.h>
-
-extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
-   attribute_hidden;
-extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 3bfb1fc60e..925b57082d 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -45,8 +45,8 @@
 # define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETTIME_VSYSCALL	1
-# define HAVE_GETTIMEOFDAY_VSYSCALL	1
+# define HAVE_CLOCK_GETTIME_VSYSCALL	"__vdso_clock_gettime"
+# define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
 
 #undef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...) 				\
diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
index 5fec208380..3da5417fff 100644
--- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
+++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
@@ -19,7 +19,7 @@
 #ifndef SYSDEP_VDSO_LINUX_H
 # define SYSDEP_VDSO_LINUX_H
 
-#define VDSO_SYMBOL(__name) __vdso_##__name
+#include <dl-vdso.h>
 
 #ifndef INTERNAL_VSYSCALL_CALL
 # define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		      \
diff --git a/sysdeps/unix/sysv/linux/x86/libc-vdso.h b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
deleted file mode 100644
index c9aa1c8a72..0000000000
--- a/sysdeps/unix/sysv/linux/x86/libc-vdso.h
+++ /dev/null
@@ -1,33 +0,0 @@
-/* Resolve function pointers to VDSO functions.
-   Copyright (C) 2005-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifndef _LIBC_VDSO_H
-#define _LIBC_VDSO_H
-
-#include <time.h>
-#include <sys/time.h>
-
-#include <sysdep-vdso.h>
-
-extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
-  attribute_hidden;
-
-extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
-  attribute_hidden;
-
-#endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/x86_64/init-first.c b/sysdeps/unix/sysv/linux/x86_64/init-first.c
deleted file mode 100644
index aede1c858d..0000000000
--- a/sysdeps/unix/sysv/linux/x86_64/init-first.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.  Linux/x86-64.
-   Copyright (C) 2007-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <time.h>
-#include <sysdep.h>
-#include <dl-vdso.h>
-#include <libc-vdso.h>
-
-long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
-  attribute_hidden;
-long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
-  attribute_hidden;
-
-extern __typeof (clock_gettime) __syscall_clock_gettime attribute_hidden;
-
-
-static inline void
-__vdso_platform_setup (void)
-{
-  void *p = get_vdso_symbol ("__vdso_clock_gettime");
-  if (p == NULL)
-    p = __syscall_clock_gettime;
-  PTR_MANGLE (p);
-  VDSO_SYMBOL(clock_gettime) = p;
-
-  p = get_vdso_symbol ("__vdso_getcpu");
-  PTR_MANGLE (p);
-  VDSO_SYMBOL(getcpu) = p;
-}
-
-#define VDSO_SETUP __vdso_platform_setup
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 197329f4dc..4541c0d492 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -374,9 +374,9 @@
 # define VDSO_HASH  61765110
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETTIME_VSYSCALL    1
-# define HAVE_GETTIMEOFDAY_VSYSCALL     1
-# define HAVE_GETCPU_VSYSCALL		1
+# define HAVE_CLOCK_GETTIME_VSYSCALL    "__vdso_clock_gettime"
+# define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
+# define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
 
 # define SINGLE_THREAD_BY_GLOBAL		1
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 09/12] mips: Consolidate INTERNAL_VSYSCALL_CALL
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 07/12] Refactor vDSO initialization code Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 12/12] linux: Consolidate gettimeofday implementation Adhemerval Zanella
@ 2019-06-14 15:29 ` Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 02/12] riscv: Enable VDSO for static linking Adhemerval Zanella
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

This patch consolidates the mips, mips64, and mips64-n32
INTERNAL_VSYSCALL_CALL on a single implementation.

No semantic changes. I checked against a build for mips-linux-gnu,
mips64-linux-gnu, and mips64-n32-linux-gnu.

	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
	(INTERNAL_VSYSCALL_CALL): Remove.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
	(INTERNAL_VSYSCALL_CALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
	(INTERNAL_VSYSCALL_CALL): Likewise.
	* sysdeps/unix/sysv/linux/mips/sysdep.h (INTERNAL_VSYSCALL_CALL):
	New macro.
---
 sysdeps/unix/sysv/linux/mips/mips32/sysdep.h     | 12 ------------
 sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h | 12 ------------
 sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h | 12 ------------
 sysdeps/unix/sysv/linux/mips/sysdep.h            | 16 ++++++++++++++++
 4 files changed, 16 insertions(+), 36 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
index ebe397b701..bfcb916f15 100644
--- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
@@ -349,18 +349,6 @@ libc_hidden_proto (__mips_syscall7, nomips16)
 #define __SYSCALL_CLOBBERS "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", \
 	"$14", "$15", "$24", "$25", "hi", "lo", "memory"
 
-/* Standard MIPS syscalls have an error flag, and return a positive errno
-   when the error flag is set. Emulate this behaviour for vsyscalls so that
-   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  ({									\
-    long _ret = funcptr (args);						\
-    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
-    if (err)								\
-      _ret = -_ret;							\
-    _ret;								\
-  })
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
index bb49429c30..49e94a1706 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
@@ -297,18 +297,6 @@
 #define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
 	"$14", "$15", "$24", "$25", "hi", "lo", "memory"
 
-/* Standard MIPS syscalls have an error flag, and return a positive errno
-   when the error flag is set. Emulate this behaviour for vsyscalls so that
-   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  ({									\
-    long _ret = funcptr (args);						\
-    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
-    if (err)								\
-      _ret = -_ret;							\
-    _ret;								\
-  })
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
index 84a1ff186b..5911a62e5b 100644
--- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
@@ -293,18 +293,6 @@
 #define __SYSCALL_CLOBBERS "$1", "$3", "$10", "$11", "$12", "$13", \
 	"$14", "$15", "$24", "$25", "hi", "lo", "memory"
 
-/* Standard MIPS syscalls have an error flag, and return a positive errno
-   when the error flag is set. Emulate this behaviour for vsyscalls so that
-   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
-#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
-  ({									\
-    long _ret = funcptr (args);						\
-    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
-    if (err)								\
-      _ret = -_ret;							\
-    _ret;								\
-  })
-
 #endif /* __ASSEMBLER__ */
 
 /* Pointer mangling is not yet supported for MIPS.  */
diff --git a/sysdeps/unix/sysv/linux/mips/sysdep.h b/sysdeps/unix/sysv/linux/mips/sysdep.h
index 58a7244581..77b1f9c2fb 100644
--- a/sysdeps/unix/sysv/linux/mips/sysdep.h
+++ b/sysdeps/unix/sysv/linux/mips/sysdep.h
@@ -22,3 +22,19 @@
 /* List of system calls which are supported as vsyscalls.  */
 #define HAVE_CLOCK_GETTIME_VSYSCALL     "__vdso_gettimeofday"
 #define HAVE_GETTIMEOFDAY_VSYSCALL      "__vdso_clock_gettime"
+
+#ifndef __ASSEMBLER__
+
+/* Standard MIPS syscalls have an error flag, and return a positive errno
+   when the error flag is set. Emulate this behaviour for vsyscalls so that
+   the INTERNAL_SYSCALL_{ERROR_P,ERRNO} macros work correctly.  */
+#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
+  ({									\
+    long _ret = funcptr (args);						\
+    err = ((unsigned long) (_ret) >= (unsigned long) -4095L);		\
+    if (err)								\
+      _ret = -_ret;							\
+    _ret;								\
+  })
+
+#endif /* __ASSEMBLER__  */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 01/12] m68k: Remove vDSO support
@ 2019-06-14 15:29 Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 07/12] Refactor vDSO initialization code Adhemerval Zanella
                   ` (11 more replies)
  0 siblings, 12 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

Although defined in initial TLS/NPTL ABI for m68k and ColdFire [1], kernel
support was never pushed upstream.  This patch removes the unused m68k
vDSO support.

Checked with a build against m68k and m68k-coldfire and some basic
tests on ARAnyM.

	* sysdeps/unix/sysv/linux/m68k/Makefile (sysdep_routines,
	sysdep-rtld-routines): Remove rules.
	* sysdeps/unix/sysv/linux/m68k/Versions (libc) [GLIBC_PRIVATE]:
	Remove __vdso_atomic_cmpxchg_32 and __vdso_atomic_barrier.
	(ld) [GLIBC_PRIVATE]: __rtld___vdso_read_tp,
	__rtld___vdso_atomic_cmpxchg_32, and __rtld___vdso_atomic_barrier.
	* sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
	(atomic_compare_and_exchange_val_acq, atomic_full_barrier): Remove
	vDSO path for SHARED.
	* sysdeps/unix/sysv/linux/m68k/init-first.c: Remove file.
	* sysdeps/unix/sysv/linux/m68k/libc-m68k-vdso.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m68k-helpers.S: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m68k-vdso.c: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m68k-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m68k-helpers.c: New file.

[1] https://lists.debian.org/debian-68k/2007/11/msg00071.html
---
 sysdeps/unix/sysv/linux/m68k/Makefile         |  2 -
 sysdeps/unix/sysv/linux/m68k/Versions         | 11 ---
 .../sysv/linux/m68k/coldfire/atomic-machine.h | 45 +--------
 sysdeps/unix/sysv/linux/m68k/init-first.c     | 74 ---------------
 sysdeps/unix/sysv/linux/m68k/libc-m68k-vdso.c |  1 -
 sysdeps/unix/sysv/linux/m68k/m68k-helpers.S   | 95 -------------------
 sysdeps/unix/sysv/linux/m68k/m68k-helpers.c   | 26 +++++
 sysdeps/unix/sysv/linux/m68k/m68k-vdso.c      | 34 -------
 sysdeps/unix/sysv/linux/m68k/m68k-vdso.h      | 60 ------------
 9 files changed, 27 insertions(+), 321 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/init-first.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/libc-m68k-vdso.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/m68k-helpers.S
 create mode 100644 sysdeps/unix/sysv/linux/m68k/m68k-helpers.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/m68k-vdso.c
 delete mode 100644 sysdeps/unix/sysv/linux/m68k/m68k-vdso.h

diff --git a/sysdeps/unix/sysv/linux/m68k/Makefile b/sysdeps/unix/sysv/linux/m68k/Makefile
index ce1f696a6f..be40fae68a 100644
--- a/sysdeps/unix/sysv/linux/m68k/Makefile
+++ b/sysdeps/unix/sysv/linux/m68k/Makefile
@@ -18,8 +18,6 @@ endif
 
 ifeq ($(subdir),elf)
 sysdep-dl-routines += dl-static
-sysdep_routines += dl-vdso libc-m68k-vdso
-sysdep-rtld-routines += m68k-vdso
 sysdep-others += lddlibc4
 install-bin += lddlibc4
 endif
diff --git a/sysdeps/unix/sysv/linux/m68k/Versions b/sysdeps/unix/sysv/linux/m68k/Versions
index 7ecc96ea97..8e72cd18cb 100644
--- a/sysdeps/unix/sysv/linux/m68k/Versions
+++ b/sysdeps/unix/sysv/linux/m68k/Versions
@@ -40,15 +40,4 @@ libc {
   GLIBC_2.12 {
     __m68k_read_tp;
   }
-  GLIBC_PRIVATE {
-    __vdso_atomic_cmpxchg_32; __vdso_atomic_barrier;
-  }
-}
-
-ld {
-  GLIBC_PRIVATE {
-    __rtld___vdso_read_tp;
-    __rtld___vdso_atomic_cmpxchg_32;
-    __rtld___vdso_atomic_barrier;
-  }
 }
diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
index 7465a98fef..0a2aa9ffa5 100644
--- a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
+++ b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
@@ -21,7 +21,6 @@
 
 #include <stdint.h>
 #include <sysdep.h>
-#include <m68k-vdso.h>
 
 /* Coldfire has no atomic compare-and-exchange operation, but the
    kernel provides userspace atomicity operations.  Use them.  */
@@ -43,33 +42,7 @@ typedef uintmax_t uatomic_max_t;
 #define ATOMIC_EXCHANGE_USES_CAS 1
 
 /* The only basic operation needed is compare and exchange.  */
-/* For ColdFire we'll have to trap into the kernel mode anyway,
-   so trap from the library rather then from the kernel wrapper.  */
-#ifdef SHARED
-# define atomic_compare_and_exchange_val_acq(mem, newval, oldval)	\
-  ({									\
-    /* Use temporary variables to workaround call-clobberness of 	\
-       the registers.  */						\
-    __typeof (mem) _mem = mem;						\
-    __typeof (oldval) _oldval = oldval;					\
-    __typeof (newval) _newval = newval;					\
-    register uint32_t *_a0 asm ("a0") = (uint32_t *) _mem;		\
-    register uint32_t _d0 asm ("d0") = (uint32_t) _oldval;		\
-    register uint32_t _d1 asm ("d1") = (uint32_t) _newval;		\
-    void *tmp;								\
-									\
-    asm ("movel #_GLOBAL_OFFSET_TABLE_@GOTPC, %2\n\t"			\
-	 "lea (-6, %%pc, %2), %2\n\t"					\
-	 "movel " STR_M68K_VDSO_SYMBOL (__vdso_atomic_cmpxchg_32)	\
-	 "@GOT(%2), %2\n\t"						\
-	 "movel (%2), %2\n\t"						\
-	 "jsr (%2)\n\t"							\
-	 : "+d" (_d0), "+m" (*_a0), "=&a" (tmp)				\
-	 : "a" (_a0), "d" (_d1));					\
-    (__typeof (oldval)) _d0;						\
-  })
-#else
-# define atomic_compare_and_exchange_val_acq(mem, newval, oldval)	\
+#define atomic_compare_and_exchange_val_acq(mem, newval, oldval)	\
   ({									\
     /* Use temporary variables to workaround call-clobberness of 	\
        the registers.  */						\
@@ -86,24 +59,8 @@ typedef uintmax_t uatomic_max_t;
 	 : "a" (_a0), "d" (_d2), "d" (_d1));				\
     (__typeof (oldval)) _d0;						\
   })
-#endif
 
-#ifdef SHARED
-# define atomic_full_barrier()					 \
-  ({								 \
-    void *tmp;							 \
-								 \
-    asm ("movel #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t"		 \
-	 "lea (-6, %pc, %0), %0\n\t"				 \
-	 "movel " STR_M68K_VDSO_SYMBOL (__vdso_atomic_barrier)	 \
-	 "@GOT(%0), %0\n\t"					 \
-	 "movel (%0), %0\n\t"					 \
-	 "jsr (%0)\n\t"						 \
-	 : "=&a" (tmp));					 \
-  })
-#else
 # define atomic_full_barrier()				\
   (INTERNAL_SYSCALL (atomic_barrier, , 0), (void) 0)
-#endif
 
 #endif
diff --git a/sysdeps/unix/sysv/linux/m68k/init-first.c b/sysdeps/unix/sysv/linux/m68k/init-first.c
deleted file mode 100644
index f8f0910839..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/init-first.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* Initialization code run first thing by the ELF startup code.  Linux/m68k.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010.
-
-   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
-   <http://www.gnu.org/licenses/>.  */
-
-/* Note: linking in vDSO to a static binary requires changes to
-   the main GLIBC proper.  Not yet implemented.  */
-#ifdef SHARED
-
-#include <dl-vdso.h>
-#include <m68k-vdso.h>
-
-static inline void
-_libc_vdso_platform_setup (void)
-{
-  void *p;
-
-  PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
-
-  /* It may happen that rtld didn't initialize the vDSO, so fallback
-     to the syscall implementations if _dl_vdso_vsym returns NULL.
-     This may happen when a static executable dlopen's a dynamic library.
-     This really is nothing more than a workaround for rtld/csu
-     deficiency.  Ideally, init code would setup the vDSO for static
-     binaries too.  */
-
-  p = _dl_vdso_vsym ("__kernel_read_tp", &linux26);
-  if (p != NULL)
-    {
-      __vdso_read_tp = p;
-      __rtld___vdso_read_tp = p;
-    }
-  else
-    assert (__vdso_read_tp == (void *) __vdso_read_tp_stub);
-
-  p = _dl_vdso_vsym ("__kernel_atomic_cmpxchg_32", &linux26);
-  if (p != NULL)
-    {
-      __vdso_atomic_cmpxchg_32 = p;
-      __rtld___vdso_atomic_cmpxchg_32 = p;
-    }
-  else
-    assert (__vdso_atomic_cmpxchg_32
-	    == (void *) __vdso_atomic_cmpxchg_32_stub);
-
-  p = _dl_vdso_vsym ("__kernel_atomic_barrier", &linux26);
-  if (p != NULL)
-    {
-      __vdso_atomic_barrier = p;
-      __rtld___vdso_atomic_barrier = p;
-    }
-  else
-    assert (__vdso_atomic_barrier == (void *) __vdso_atomic_barrier_stub);
-}
-
-#define VDSO_SETUP _libc_vdso_platform_setup
-
-#endif /* SHARED */
-
-#include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/m68k/libc-m68k-vdso.c b/sysdeps/unix/sysv/linux/m68k/libc-m68k-vdso.c
deleted file mode 100644
index 45982e99b9..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/libc-m68k-vdso.c
+++ /dev/null
@@ -1 +0,0 @@
-#include "m68k-vdso.c"
diff --git a/sysdeps/unix/sysv/linux/m68k/m68k-helpers.S b/sysdeps/unix/sysv/linux/m68k/m68k-helpers.S
deleted file mode 100644
index 5e3ffb0a7f..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/m68k-helpers.S
+++ /dev/null
@@ -1,95 +0,0 @@
-/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010.
-
-   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.
-
-   In addition to the permissions in the GNU Lesser General Public
-   License, the Free Software Foundation gives you unlimited
-   permission to link the compiled version of this file with other
-   programs, and to distribute those programs without any restriction
-   coming from the use of this file. (The GNU Lesser General Public
-   License restrictions do apply in other respects; for example, they
-   cover modification of the file, and distribution when not linked
-   into another program.)
-
-   Note that people who make modified versions of this file are not
-   obligated to grant this special exception for their modified
-   versions; it is their choice whether to do so. The GNU Lesser
-   General Public License gives permission to release a modified
-   version without this exception; this exception also makes it
-   possible to release a modified version which carries forward this
-   exception.
-
-   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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sysdep.h>
-#include <m68k-vdso.h>
-
-	.text
-
-	.hidden __vdso_read_tp_stub
-ENTRY (__vdso_read_tp_stub)
-	move.l	#__NR_get_thread_area, %d0
-	trap	#0
-	move.l	%d0, %a0
-	rts
-END (__vdso_read_tp_stub)
-
-# ifdef SHARED
-/* GCC will emit calls to this routine.  Linux has an
-   equivalent helper function (which clobbers fewer registers than
-   a normal function call) in a vdso; tail call to the
-   helper.  */
-# if IS_IN (rtld)
-/* rtld gets a hidden copy of __m68k_read_tp.  */
-	.hidden __m68k_read_tp
-# endif
-ENTRY (__m68k_read_tp)
-	LOAD_GOT (%a0)
-	move.l	M68K_VDSO_SYMBOL (__vdso_read_tp)@GOT(%a0), %a0
-	move.l	(%a0), %a0
-	jmp	(%a0)
-END (__m68k_read_tp)
-
-/* The following two stubs are for macros in atomic.h, they can't
-   clobber anything.  */
-
-	.hidden __vdso_atomic_cmpxchg_32_stub
-ENTRY (__vdso_atomic_cmpxchg_32_stub)
-	move.l	%d2, -(%sp)
-	cfi_adjust_cfa_offset (4)
-	cfi_rel_offset (%d2, 0)
-	move.l	%d0, %d2
-	move.l	#SYS_ify (atomic_cmpxchg_32), %d0
-	trap	#0
-	move.l	(%sp)+, %d2
-	cfi_adjust_cfa_offset (-4)
-	cfi_restore (%d2)
-	rts
-END (__vdso_atomic_cmpxchg_32_stub)
-
-	.hidden __vdso_atomic_barrier_stub
-ENTRY (__vdso_atomic_barrier_stub)
-	move.l	%d0, -(%sp)
-	cfi_adjust_cfa_offset (4)
-	move.l	#SYS_ify (atomic_barrier), %d0
-	trap	#0
-	move.l	(%sp)+, %d0
-	cfi_adjust_cfa_offset (-4)
-	rts
-END (__vdso_atomic_barrier_stub)
-# else /* !SHARED */
-/* If the vDSO is not available, use a syscall to get TP.  */
-	strong_alias (__vdso_read_tp_stub, __m68k_read_tp)
-# endif /* SHARED */
diff --git a/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c b/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c
new file mode 100644
index 0000000000..df02d560aa
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/m68k/m68k-helpers.c
@@ -0,0 +1,26 @@
+/* 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
+   <http://www.gnu.org/licenses/>.  */
+
+#include <sysdep.h>
+
+void *
+__m68k_read_tp (void)
+{
+  INTERNAL_SYSCALL_DECL (err);
+  return (void*) INTERNAL_SYSCALL_CALL (get_thread_area, err);
+}
diff --git a/sysdeps/unix/sysv/linux/m68k/m68k-vdso.c b/sysdeps/unix/sysv/linux/m68k/m68k-vdso.c
deleted file mode 100644
index a1345a3a5b..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/m68k-vdso.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010.
-
-   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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifdef SHARED
-
-#include <m68k-vdso.h>
-
-/* Because these pointers are used from other libraries than libc,
-   they are exported at GLIBC_PRIVATE version.
-   We initialize them to syscall implementation so that they will be ready
-   to use from the very beginning.  */
-void * M68K_VDSO_SYMBOL (__vdso_read_tp)
-= (void *) __vdso_read_tp_stub;
-void * M68K_VDSO_SYMBOL (__vdso_atomic_cmpxchg_32)
-= (void *) __vdso_atomic_cmpxchg_32_stub;
-void * M68K_VDSO_SYMBOL (__vdso_atomic_barrier)
-= (void *) __vdso_atomic_barrier_stub;
-
-#endif /* SHARED */
diff --git a/sysdeps/unix/sysv/linux/m68k/m68k-vdso.h b/sysdeps/unix/sysv/linux/m68k/m68k-vdso.h
deleted file mode 100644
index fc71c0f4e1..0000000000
--- a/sysdeps/unix/sysv/linux/m68k/m68k-vdso.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/* Resolve function pointers to VDSO functions.
-   Copyright (C) 2010-2019 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-   Contributed by Maxim Kuvyrkov <maxim@codesourcery.com>, 2010.
-
-   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
-   <http://www.gnu.org/licenses/>.  */
-
-
-#ifndef _M68K_VDSO_H
-#define _M68K_VDSO_H
-
-#ifdef SHARED
-
-# if IS_IN (rtld)
-# define M68K_VDSO_SYMBOL(name) __rtld_##name
-# define STR_M68K_VDSO_SYMBOL(name) "__rtld_" #name
-# else
-# define M68K_VDSO_SYMBOL(name) name
-# define STR_M68K_VDSO_SYMBOL(name) #name
-# endif
-
-# ifndef __ASSEMBLER__
-
-/* We define __rtld_* copies for rtld.
-   We need them visible in libc to initialize.  */
-#  if IS_IN (rtld) || IS_IN (libc)
-extern void *__rtld___vdso_read_tp;
-extern void *__rtld___vdso_atomic_cmpxchg_32;
-extern void *__rtld___vdso_atomic_barrier;
-
-/* These stubs are meant to be invoked only from the assembly.  */
-extern void __vdso_read_tp_stub (void);
-extern void __vdso_atomic_cmpxchg_32_stub (void);
-extern void __vdso_atomic_barrier_stub (void);
-#  endif /* IS_IN (rtld) || IS_IN (libc) */
-
-/* RTLD should only use its own copies.  */
-#  if !IS_IN (rtld)
-extern void *__vdso_read_tp;
-extern void *__vdso_atomic_cmpxchg_32;
-extern void *__vdso_atomic_barrier;
-#  endif /* !IS_IN (rtld) */
-
-# endif /* !__ASSEMBLER__ */
-
-#endif /* SHARED */
-
-#endif /* _M68K_VDSO_H */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 12/12] linux: Consolidate gettimeofday implementation
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 07/12] Refactor vDSO initialization code Adhemerval Zanella
@ 2019-06-14 15:29 ` Adhemerval Zanella
  2019-07-08 20:47   ` Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 09/12] mips: Consolidate INTERNAL_VSYSCALL_CALL Adhemerval Zanella
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

The gettimeofday syscall has currently 3 possible implementations:

  1. Wire-up __NR_gettimeofday with a VDSO implementation accessed
     directly through IFUNC (aarch64, x86, and powerpc*).

  2. vDSO gettimeofday (arm, mips*, riscv*, s390, and sparc).

  3. Wire-up __NR_gettimeofday (alpha, hppa, ia64, m68k, microblaze,
     nios, sh4).

This patch consolidates all implementation on Linux generic
sysdeps/unix/sysv/linux/gettimeofday.c.  To simplify the code, some changes
are made:

   * The wire-up with vDSO implementation may route external calls directly
     to vDSO through IFUNC.  To enable it the architecture need to
     explicit define USE_GETTIMEOFDAY_VSYSCALL_IFUNC.

   * Also, powerpc and x86 tries to route internal time usages to
     IFUNC mechanism, which is problematic since powerpc32 and i686 does
     not really support it.  Instead, all internal calls are routed to
     a default internal symbol which in turn calls INTERNAL_VSYSCALL.

   * Static linking also uses the fallback mechanism which calls
     INTERNAL_VSYSCALL, so vDSO is used for this case as well.

The generic implementation issues a syscall as default, calls the
vDSO if the architecture defines HAVE_GETTIMEOFDAY_VSYSCALL, and
route the external calls to iFUNC if the architecture also defines
USE_GETTIMEOFDAY_VSYSCALL_IFUNC.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
powerpc64-linux-gnu, powerpc64le-linux-gnu, and aarch64-linux-gnu.

	* sysdeps/unix/sysv/linux/aarch64/gettimeofday.c: Remove file.
	* sysdeps/unix/sysv/linux/i386/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Define.
	* sysdeps/unix/sysv/linux/i386/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/gettimeofday.c (gettimeofday): Handle all
	possible Linux implementations (wire-up syscall, vDSO implementation,
	and iFUNC).
        (gettimeofday_syscall): New function.
---
 .../unix/sysv/linux/aarch64/gettimeofday.c    | 59 -------------
 sysdeps/unix/sysv/linux/aarch64/sysdep.h      |  1 +
 sysdeps/unix/sysv/linux/gettimeofday.c        | 47 ++++++++--
 sysdeps/unix/sysv/linux/i386/gettimeofday.c   | 35 --------
 sysdeps/unix/sysv/linux/i386/sysdep.h         |  1 +
 .../unix/sysv/linux/powerpc/gettimeofday.c    | 85 -------------------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      |  1 +
 sysdeps/unix/sysv/linux/x86/gettimeofday.c    | 63 --------------
 sysdeps/unix/sysv/linux/x86_64/sysdep.h       |  1 +
 9 files changed, 44 insertions(+), 249 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/gettimeofday.c

diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
deleted file mode 100644
index 2474a2c575..0000000000
--- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Copyright (C) 2018-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
-   <http://www.gnu.org/licenses/>.  */
-
-/* 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 <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <sysdep-vdso.h>
-
-/* 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 *tv, struct timezone *tz)
-{
-  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
-}
-
-# define INIT_ARCH()
-
-libc_ifunc_hidden (__gettimeofday, __gettimeofday,
-		   (get_vdso_symbol ("__vdso_gettimeofday")
-		    ?: __gettimeofday_vsyscall))
-libc_hidden_def (__gettimeofday)
-
-#else
-
-# include <sysdep.h>
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-libc_hidden_def (__gettimeofday)
-
-#endif
-
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index d57f7232e2..526741ed82 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -163,6 +163,7 @@
 # define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
 # define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 # define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
+# define USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 
 /* Previously AArch64 used the generic version without the libc_hidden_def
    which lead in a non existent __send symbol in libc.so.  */
diff --git a/sysdeps/unix/sysv/linux/gettimeofday.c b/sysdeps/unix/sysv/linux/gettimeofday.c
index a74f03825a..ed46723803 100644
--- a/sysdeps/unix/sysv/linux/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/gettimeofday.c
@@ -16,24 +16,57 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <sys/time.h>
+/* Currently we have 3 possible gettimeofday implementations, which is also
+   selected in the order:
+
+   1. Wire-up __NR_gettimeofday with a vDSO implementation (currently aarch64,
+      x86, and powerpc).
+
+   2. vDSO gettimeofday (arm, mips*, riscv*, s390, and sparc).
 
+   3. Wire-up __NR_gettimeofday (alpha, hppa, ia64, m68k, microblaze,
+      nios, sh4).  */
+
+#define __gettimeofday __redirect___gettimeofday
+#include <sys/time.h>
 #undef __gettimeofday
 
+#include <sysdep.h>
 #ifdef HAVE_GETTIMEOFDAY_VSYSCALL
 # define HAVE_VSYSCALL
 #endif
 #include <sysdep-vdso.h>
+#include <libc-vdso.h>
+
+/* 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.  */
+static int
+gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
+{
+  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
+}
+
+#if HAVE_IFUNC && defined USE_GETTIMEOFDAY_VSYSCALL_IFUNC
+/* Route externals calls direct to vDSO and static and internal calls to
+   fallback implementation (which also might call the vDSO).  */
+# ifdef SHARED
+#  define INIT_ARCH()
+libc_ifunc_redirected (__redirect___gettimeofday, __gettimeofday,
+		       get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL)
+		       ?: gettimeofday_syscall);
+libc_hidden_def_redir (gettimeofday_syscall, __gettimeofday)
+#  else
+strong_alias (gettimeofday_syscall, __gettimeofday)
+#  endif /* SHARED  */
+#else
 
-/* 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.  */
 int
 __gettimeofday (struct timeval *tv, struct timezone *tz)
 {
-  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
+  return gettimeofday_syscall (tv, tz);
 }
-libc_hidden_def (__gettimeofday)
+libc_hidden_def_redir (__gettimeofday, __gettimeofday)
+#endif
 weak_alias (__gettimeofday, gettimeofday)
 libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/i386/gettimeofday.c b/sysdeps/unix/sysv/linux/i386/gettimeofday.c
deleted file mode 100644
index 185450ece6..0000000000
--- a/sysdeps/unix/sysv/linux/i386/gettimeofday.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* gettimeofday - get the time.  Linux/i386 version.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifdef SHARED
-# define __gettimeofday __redirect___gettimeofday
-#endif
-
-#include <sys/time.h>
-
-#ifdef SHARED
-# undef __gettimeofday
-# define __gettimeofday_type __redirect___gettimeofday
-
-# undef libc_hidden_def
-# define libc_hidden_def(name) \
-  __hidden_ver1 (__gettimeofday_syscall, __GI___gettimeofday, \
-	       __gettimeofday_syscall);
-#endif
-
-#include <sysdeps/unix/sysv/linux/x86/gettimeofday.c>
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 4f79f25989..076e4393d3 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -315,6 +315,7 @@ 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 USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 # define HAVE_TIME_VSYSCALL             "__vdso_time"
 # define USE_TIME_VSYSCALL_IFUNC	1
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
deleted file mode 100644
index 7a4e3cca0c..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Copyright (C) 2005-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
-   <http://www.gnu.org/licenses/>.  */
-
-#if defined SHARED && !defined __powerpc64__
-# define __gettimeofday __redirect___gettimeofday
-#else
-# define __redirect___gettimeofday __gettimeofday
-#endif
-
-#include <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <libc-vdso.h>
-# include <dl-machine.h>
-
-# ifndef __powerpc64__
-#  undef __gettimeofday
-
-int
-__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
-}
-
-/* __GI___gettimeofday is defined as hidden and for ppc32 it enables the
-   compiler make a local call (symbol@local) for internal GLIBC usage. It
-   means the PLT won't be used and the ifunc resolver will be called directly.
-   For ppc64 a call to a function in another translation unit might use a
-   different toc pointer thus disallowing direct branchess and making internal
-   ifuncs calls safe.  */
-#  undef libc_hidden_def
-#  define libc_hidden_def(name)					\
-  __hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday,	\
-	       __gettimeofday_vsyscall);
-
-# endif /* !__powerpc64__  */
-
-static int
-__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-
-# define INIT_ARCH()						\
-  void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL)
-  
-
-/* If the vDSO is not available we fall back syscall.  */
-libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
-		   vdso_gettimeofday
-		   ? vdso_gettimeofday
-		   : (void *) __gettimeofday_syscall);
-libc_hidden_def (__gettimeofday)
-
-#else
-
-# include <sysdep.h>
-# include <errno.h>
-
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-libc_hidden_def (__gettimeofday)
-
-#endif
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 44bfa3f1b6..754832d580 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -26,6 +26,7 @@
 #define HAVE_TIME_VSYSCALL		"__kernel_time"
 #define USE_TIME_VSYSCALL_IFUNC		1
 #define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
+#define USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 #define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
 #if defined(__PPC64__) || defined(__powerpc64__)
diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c
deleted file mode 100644
index 3ceab633e5..0000000000
--- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* gettimeofday - get the time.  Linux/x86 version.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <errno.h>
-# include <sysdep-vdso.h>
-# include <sysdep-vdso.h>
-
-static int
-__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-
-# ifndef __gettimeofday_type
-/* The i386 gettimeofday.c includes this file with a defined
-   __gettimeofday_type macro.  For x86_64 we have to define it to __gettimeofday
-   as the internal symbol is the ifunc'ed one.  */
-#  define __gettimeofday_type __gettimeofday
-# endif
-
-# define INIT_ARCH()
-
-/* If the vDSO is not available we fall back to syscall.  */
-libc_ifunc_hidden (__gettimeofday_type, __gettimeofday,
-		   (get_vdso_symbol ("__vdso_gettimeofday")
-		    ?: __gettimeofday_syscall));
-libc_hidden_def (__gettimeofday)
-
-#else
-
-# include <sysdep.h>
-# include <errno.h>
-
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-libc_hidden_def (__gettimeofday)
-
-#endif
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index c64fbd1e26..4ea9c4fa31 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -376,6 +376,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 USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 # define HAVE_TIME_VSYSCALL		"__vdso_time"
 # define USE_TIME_VSYSCALL_IFUNC	1
 # define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 03/12] s390: Enable VDSO for static linking
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
                   ` (5 preceding siblings ...)
  2019-06-14 15:29 ` [PATCH 08/12] powerpc: Refactor vsyscall internal macros Adhemerval Zanella
@ 2019-06-14 15:29 ` Adhemerval Zanella
  2019-08-02 12:34   ` Adhemerval Zanella
  2019-06-14 15:29 ` [PATCH 11/12] linux: Consolidate time implementation Adhemerval Zanella
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:29 UTC (permalink / raw)
  To: libc-alpha

Although s390 explicit does not enable vDSO for binaries without
(arch/s390/kernel/vdso.c:217), there is no indication in the code
the rationale for disabling it.  In fact, I rebuilt a kernel with the
check removed and the vDSO does work for static build for supplied
symbols.

Checked on s390x-linux-gnu.

	[BZ #19767]
	* sysdeps/unix/sysv/linux/s390/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/s390/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
	(ALWAYS_USE_VSYSCALL): Define.
	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
	(ALWAYS_USE_VSYSCALL): Likewise.
---
 sysdeps/unix/sysv/linux/s390/init-first.c     | 8 ++------
 sysdeps/unix/sysv/linux/s390/libc-vdso.h      | 3 ---
 sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h | 3 +++
 sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h | 4 ++++
 4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/s390/init-first.c b/sysdeps/unix/sysv/linux/s390/init-first.c
index 71dd43f738..847977c0d9 100644
--- a/sysdeps/unix/sysv/linux/s390/init-first.c
+++ b/sysdeps/unix/sysv/linux/s390/init-first.c
@@ -16,9 +16,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef SHARED
-# include <dl-vdso.h>
-# include <libc-vdso.h>
+#include <dl-vdso.h>
+#include <libc-vdso.h>
 
 long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
    attribute_hidden;
@@ -54,7 +53,4 @@ _libc_vdso_platform_setup (void)
   VDSO_SYMBOL (getcpu) = p;
 }
 
-# define VDSO_SETUP _libc_vdso_platform_setup
-#endif
-
 #include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/s390/libc-vdso.h b/sysdeps/unix/sysv/linux/s390/libc-vdso.h
index 5e2d1e4b3f..cc97601383 100644
--- a/sysdeps/unix/sysv/linux/s390/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/s390/libc-vdso.h
@@ -20,8 +20,6 @@
 #ifndef _LIBC_VDSO_H
 #define _LIBC_VDSO_H
 
-#ifdef SHARED
-
 #include <sysdep-vdso.h>
 
 extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
@@ -33,6 +31,5 @@ extern long int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
 
 extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
    attribute_hidden;
-#endif
 
 #endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
index 640fb52de1..47d1c5cdb2 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
@@ -19,6 +19,9 @@
 #ifndef _LINUX_S390_SYSDEP_H
 #define _LINUX_S390_SYSDEP_H
 
+/* Always enable vsyscalls on s390-32.  */
+#define ALWAYS_USE_VSYSCALL 1
+
 #include <sysdeps/s390/s390-32/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
index 9a9834c750..95829390e2 100644
--- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
@@ -20,6 +20,10 @@
 #ifndef _LINUX_S390_SYSDEP_H
 #define _LINUX_S390_SYSDEP_H
 
+/* Always enable vsyscalls on s390-64.  */
+#define ALWAYS_USE_VSYSCALL 1
+
+
 #include <sysdeps/s390/s390-64/sysdep.h>
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 04/12] sparc: Enable VDSO for static linking
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
                   ` (9 preceding siblings ...)
  2019-06-14 15:29 ` [PATCH 06/12] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
@ 2019-06-14 15:30 ` Adhemerval Zanella
  2019-08-02 12:34   ` Adhemerval Zanella
  2019-06-14 16:12 ` [PATCH 01/12] m68k: Remove vDSO support Andreas Schwab
  11 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-14 15:30 UTC (permalink / raw)
  To: libc-alpha

Checked on sparc64-linux-gnu and sparcv9-linux-gnu.

	[BZ #19767]
	* sysdeps/unix/sysv/linux/sparc/init-first.c: Remove #ifdef SHARED.
	* sysdeps/unix/sysv/linux/sparc/libc-vdso.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sysdep.h (ALWAYS_USE_VSYSCALL):
	Define.
---
 sysdeps/unix/sysv/linux/sparc/init-first.c | 8 +++-----
 sysdeps/unix/sysv/linux/sparc/libc-vdso.h  | 6 +-----
 sysdeps/unix/sysv/linux/sparc/sysdep.h     | 3 +++
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/sparc/init-first.c b/sysdeps/unix/sysv/linux/sparc/init-first.c
index de83321713..643d6c7c88 100644
--- a/sysdeps/unix/sysv/linux/sparc/init-first.c
+++ b/sysdeps/unix/sysv/linux/sparc/init-first.c
@@ -17,9 +17,8 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifdef SHARED
-# include <dl-vdso.h>
-# include <libc-vdso.h>
+#include <dl-vdso.h>
+#include <libc-vdso.h>
 
 long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
     attribute_hidden;
@@ -40,7 +39,6 @@ _libc_vdso_platform_setup (void)
   VDSO_SYMBOL (clock_gettime) = p;
 }
 
-# define VDSO_SETUP _libc_vdso_platform_setup
-#endif
+#define VDSO_SETUP _libc_vdso_platform_setup
 
 #include <csu/init-first.c>
diff --git a/sysdeps/unix/sysv/linux/sparc/libc-vdso.h b/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
index 4009b00a28..d20afcdf04 100644
--- a/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
@@ -20,14 +20,10 @@
 #ifndef _LIBC_VDSO_H
 #define _LIBC_VDSO_H
 
-#ifdef SHARED
-
-# include <sysdep-vdso.h>
+#include <sysdep-vdso.h>
 
 extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
    attribute_hidden;
 extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
 
-#endif
-
 #endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
index 981b2a26b7..fc4053c5ce 100644
--- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
@@ -19,6 +19,9 @@
 #ifndef _LINUX_SPARC_SYSDEP_H
 #define _LINUX_SPARC_SYSDEP_H 1
 
+/* Always enable vsyscalls on sparc */
+#define ALWAYS_USE_VSYSCALL 1
+
 #include <sysdeps/unix/sysdep.h>
 #include <sysdeps/unix/sysv/linux/sysdep.h>
 #include <sysdeps/sparc/sysdep.h>
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 01/12] m68k: Remove vDSO support
  2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
                   ` (10 preceding siblings ...)
  2019-06-14 15:30 ` [PATCH 04/12] sparc: Enable VDSO for static linking Adhemerval Zanella
@ 2019-06-14 16:12 ` Andreas Schwab
  11 siblings, 0 replies; 33+ messages in thread
From: Andreas Schwab @ 2019-06-14 16:12 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

On Jun 14 2019, Adhemerval Zanella <adhemerval.zanella@linaro.org> wrote:

> 	* sysdeps/unix/sysv/linux/m68k/Makefile (sysdep_routines,
> 	sysdep-rtld-routines): Remove rules.
> 	* sysdeps/unix/sysv/linux/m68k/Versions (libc) [GLIBC_PRIVATE]:
> 	Remove __vdso_atomic_cmpxchg_32 and __vdso_atomic_barrier.
> 	(ld) [GLIBC_PRIVATE]: __rtld___vdso_read_tp,
> 	__rtld___vdso_atomic_cmpxchg_32, and __rtld___vdso_atomic_barrier.
> 	* sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
> 	(atomic_compare_and_exchange_val_acq, atomic_full_barrier): Remove
> 	vDSO path for SHARED.
> 	* sysdeps/unix/sysv/linux/m68k/init-first.c: Remove file.
> 	* sysdeps/unix/sysv/linux/m68k/libc-m68k-vdso.c: Likewise.
> 	* sysdeps/unix/sysv/linux/m68k/m68k-helpers.S: Likewise.
> 	* sysdeps/unix/sysv/linux/m68k/m68k-vdso.c: Likewise.
> 	* sysdeps/unix/sysv/linux/m68k/m68k-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/m68k/m68k-helpers.c: New file.

Ok.

> diff --git a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
> index 7465a98fef..0a2aa9ffa5 100644
> --- a/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h
> +++ b/sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h

> @@ -86,24 +59,8 @@ typedef uintmax_t uatomic_max_t;
>  	 : "a" (_a0), "d" (_d2), "d" (_d1));				\
>      (__typeof (oldval)) _d0;						\
>    })
> -#endif
>  
> -#ifdef SHARED
> -# define atomic_full_barrier()					 \
> -  ({								 \
> -    void *tmp;							 \
> -								 \
> -    asm ("movel #_GLOBAL_OFFSET_TABLE_@GOTPC, %0\n\t"		 \
> -	 "lea (-6, %pc, %0), %0\n\t"				 \
> -	 "movel " STR_M68K_VDSO_SYMBOL (__vdso_atomic_barrier)	 \
> -	 "@GOT(%0), %0\n\t"					 \
> -	 "movel (%0), %0\n\t"					 \
> -	 "jsr (%0)\n\t"						 \
> -	 : "=&a" (tmp));					 \
> -  })
> -#else
>  # define atomic_full_barrier()				\

Missing unindent.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/12] linux: Enable vDSO for static linking as default (BZ#19767)
  2019-06-14 15:29 ` [PATCH 05/12] linux: Enable vDSO for static linking as default (BZ#19767) Adhemerval Zanella
@ 2019-06-17 19:57   ` Tulio Magno Quites Machado Filho
  2019-08-02 12:34   ` Adhemerval Zanella
  1 sibling, 0 replies; 33+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2019-06-17 19:57 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:

> 	* sysdeps/unix/sysv/linux/sysdep.h (ALWAYS_USE_VSYSCALL,
> 	USE_VSYSCALL): Remove defitions.

Typo here.   s/defitions/definitions/

LGTM.

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 06/12] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW
  2019-06-14 15:29 ` [PATCH 06/12] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
@ 2019-06-17 20:26   ` Tulio Magno Quites Machado Filho
  0 siblings, 0 replies; 33+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2019-06-17 20:26 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:

> This patch removes the PREPARE_VERSION and PREPARE_VERSION_KNOW macro
> and uses a static inline function instead, get_vdso_symbol.  Also,
> each architecture that supports vDSO must define the Linux version
> and hash for symbol resolution (VDSO_NAME and VDSO_HASH macro
> respectively).
>
> It also organizes the HAVE_*_VSYSCALL for mips, powerpc, and s390  to set
> them on a common header.
>
> The idea is to require less code to configure and enable vDSO support for
> newer ports.  No semantic changes are expected.
>
> Checked with a build against all affected architectures.

I found a few whitespace errors while applying your patches.
LGTM after fixing them.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
> index c8d7790d8a..6b92e2807b 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
> +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
> @@ -57,9 +57,9 @@ __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
>    return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
>  }
>  
> -# define INIT_ARCH()							\
> -  PREPARE_VERSION (linux2615, "LINUX_2.6.15", 123718565);		\
> -  void *vdso_gettimeofday = _dl_vdso_vsym ("__kernel_gettimeofday", &linux2615);
> +# define INIT_ARCH()						\
> +  void *vdso_gettimeofday = get_vdso_symbol ("__kernel_gettimeofday")
> +  

Trailing whitespaces here.

> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> new file mode 100644
> index 0000000000..5b411d0e8e
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> @@ -0,0 +1,26 @@
> +/* Syscall definitions, Linux PowerPC generic 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
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#define VDSO_NAME  "LINUX_2.6.15"
> +#define VDSO_HASH  123718565
> +
> +/* List of system calls which are supported as vsyscalls.  */
> +#define HAVE_CLOCK_GETRES_VSYSCALL	1
> +#define HAVE_CLOCK_GETTIME_VSYSCALL	1
> +#define HAVE_GETCPU_VSYSCALL		1
> +

Extra line at EOF.

> diff --git a/sysdeps/unix/sysv/linux/s390/sysdep.h b/sysdeps/unix/sysv/linux/s390/sysdep.h
> new file mode 100644
> index 0000000000..eefbd8f007
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/s390/sysdep.h
> @@ -0,0 +1,27 @@
> +/* Syscall definitions, Linux PowerPC generic version.
> +   Copyright (C) 2000-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
> +   <http://www.gnu.org/licenses/>.  */
> +
> +#define VDSO_NAME  "LINUX_2_6_29"
> +#define VDSO_HASH  123718585
> +
> +/* List of system calls which are supported as vsyscalls.  */
> +#define HAVE_CLOCK_GETRES_VSYSCALL	1
> +#define HAVE_CLOCK_GETTIME_VSYSCALL	1
> +#define HAVE_GETTIMEOFDAY_VSYSCALL	1
> +#define HAVE_GETCPU_VSYSCALL		1
> +

Extra line here too.

I wouldn't be surprised if I forgot other whitespace errors and I suggest to
rebase your patchset using 'git rebase --whitespace=error-all'.

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 08/12] powerpc: Refactor vsyscall internal macros
  2019-06-14 15:29 ` [PATCH 08/12] powerpc: Refactor vsyscall internal macros Adhemerval Zanella
@ 2019-06-17 21:49   ` Tulio Magno Quites Machado Filho
  2019-06-18 17:31     ` Adhemerval Zanella
  0 siblings, 1 reply; 33+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2019-06-17 21:49 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:

> 	* sysdeps/unix/sysv/linux/powerpc/dl-vdso.h: New file.
> 	* sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
> 	(get_timebase_freq_fallback): New symbol.
> 	(__get_timebase_freq): Call vDSO as a function pointer instead of
> 	arch-specific macros.
> 	* .../unix/sysv/linux/powerpc/gettimeofday.c (gettimeofday): Use
> 	get_vdso_symbol.

It's the first time a see a ChangeLog entry starting with '\t* ...'.
Is this really valid?

> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> index 20167615c8..cf967a8c33 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
> @@ -32,3 +33,12 @@
>  # define HAVE_SIGTRAMP_32		"__kernel_sigtramp32"
>  # define HAVE_SIGTRAMP_RT32		"__kernel_sigtramp_rt32"
>  #endif
> +
> +#ifndef __ASSEMBLER__
> +
> +/* PowerPC vDSO symbols always succeed, so there is no need to emulate a
> +   function call and check for CR0.SO value.  */
> +#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
> +  ({ err = 0; funcptr (args); })

After applying this patch, rt/cpu-clock1 started to fail with:

clock_gettime on reaped PID 26033 clock fffffffffffcd272 => Success
clock_getres on reaped PID 26033 clock fffffffffffcd272 => Success

Both cases are expecting to receive errno = EINVAL instead of Success.

Isn't CR0.SO important?

Reference:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/vdso64/gettimeofday.S#n190

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 08/12] powerpc: Refactor vsyscall internal macros
  2019-06-17 21:49   ` Tulio Magno Quites Machado Filho
@ 2019-06-18 17:31     ` Adhemerval Zanella
  2019-06-28 22:01       ` Tulio Magno Quites Machado Filho
  0 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-18 17:31 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho, libc-alpha



On 17/06/2019 18:48, Tulio Magno Quites Machado Filho wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> 
>> 	* sysdeps/unix/sysv/linux/powerpc/dl-vdso.h: New file.
>> 	* sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
>> 	(get_timebase_freq_fallback): New symbol.
>> 	(__get_timebase_freq): Call vDSO as a function pointer instead of
>> 	arch-specific macros.
>> 	* .../unix/sysv/linux/powerpc/gettimeofday.c (gettimeofday): Use
>> 	get_vdso_symbol.
> 
> It's the first time a see a ChangeLog entry starting with '\t* ...'.
> Is this really valid?
> 
>> diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>> index 20167615c8..cf967a8c33 100644
>> --- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>> +++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
>> @@ -32,3 +33,12 @@
>>  # define HAVE_SIGTRAMP_32		"__kernel_sigtramp32"
>>  # define HAVE_SIGTRAMP_RT32		"__kernel_sigtramp_rt32"
>>  #endif
>> +
>> +#ifndef __ASSEMBLER__
>> +
>> +/* PowerPC vDSO symbols always succeed, so there is no need to emulate a
>> +   function call and check for CR0.SO value.  */
>> +#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
>> +  ({ err = 0; funcptr (args); })
> 
> After applying this patch, rt/cpu-clock1 started to fail with:
> 
> clock_gettime on reaped PID 26033 clock fffffffffffcd272 => Success
> clock_getres on reaped PID 26033 clock fffffffffffcd272 => Success
> 
> Both cases are expecting to receive errno = EINVAL instead of Success.
> 
> Isn't CR0.SO important?
> 
> Reference:
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/arch/powerpc/kernel/vdso64/gettimeofday.S#n190
> 

In fact we can't really remove the CR0.SO check because the vDSO symbol
might itself fallback to a syscall (the case of rt/cpu-clock1 where
is check for invalid clockid).  The vDSO simplification turned out to
be less than I expected, but it is moving towards consolidate the
time and gettimeofday.

Updated patch below.

---

Subject: [PATCH 08/12] powerpc: Simplify vsyscall internal macros

This patch simplifies the powerpc internal macros for vDSO calls
by:

  - Removing INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK, used solely on
    get_timebase_freq.

  - Adjust INTERNAL_VSYSCALL_CALL_TYPE powerpc32 to follow powerpc64
    argument ordering.

  - Use HAVE_*_VSYSCALL instead of explicit strings.

  - Make powerpc libc-vdso.h include generic implementation.

No semantic change expected, checked on powerpc-linux-gnu-power4,
powerpc64-linux-gnu, and powerpc64le-linux-gnu.

	* sysdeps/unix/sysv/linux/libc-vdso.h (VDSO_IFUNC_RET): Define if not
	defined.
	* sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
	(__get_timebase_freq): Remove use of
	INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK.
	(get_timebase_freq_fallback): New symbol.
	* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c (time): Use
	HAVE_GETTIMEOFDAY_VSYSCALL.
	* sysdeps/unix/sysv/linux/powerpc/time.c (gettimeofday): Use
	HAVE_TIME_VSYSCALL.
	* sysdeps/unix/sysv/linux/powerpc/libc-vdso.h: Include generic
	implementation.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
	(INTERNAL_VSYSCALL_CALL_TYPE): Make calling convention similar to
	powerpc64.
	(INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK): Remove macro.
	* .../sysv/linux/powerpc/powerpc64/sysdep.h
	(INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h
	(HAVE_GETTIMEOFDAY_VSYSCALL): Define.
---
 sysdeps/unix/sysv/linux/libc-vdso.h           |  7 ++++++
 .../sysv/linux/powerpc/get_timebase_freq.c    | 24 ++++++++++++-------
 .../unix/sysv/linux/powerpc/gettimeofday.c    |  2 +-
 sysdeps/unix/sysv/linux/powerpc/libc-vdso.h   | 24 ++++++++++---------
 .../sysv/linux/powerpc/powerpc32/sysdep.h     | 18 ++------------
 .../sysv/linux/powerpc/powerpc64/sysdep.h     | 19 +--------------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      |  1 +
 sysdeps/unix/sysv/linux/powerpc/time.c        |  2 +-
 8 files changed, 41 insertions(+), 56 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/libc-vdso.h b/sysdeps/unix/sysv/linux/libc-vdso.h
index f681868137..199ae9a033 100644
--- a/sysdeps/unix/sysv/linux/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/libc-vdso.h
@@ -21,6 +21,13 @@
 
 #define VDSO_SYMBOL(__name) __vdso_##__name
 
+/* Adjust the return IFUNC value from a vDSO symbol accordingly required
+   architecture ABI.  It is used for powerpc64 elfv1 to create a ODP
+   entry since kernvel vDSO does not provide it.  */
+#ifndef VDSO_IFUNC_RET
+# define VDSO_IFUNC_RET(__value) (__value)
+#endif
+
 #ifdef HAVE_CLOCK_GETTIME_VSYSCALL
 extern int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
 #endif
diff --git a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
index 23e7694d87..57eb0e19d9 100644
--- a/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
+++ b/sysdeps/unix/sysv/linux/powerpc/get_timebase_freq.c
@@ -23,17 +23,11 @@
 #include <not-cancel.h>
 #include <libc-vdso.h>
 
-uint64_t
-__get_timebase_freq (void)
+static uint64_t
+get_timebase_freq_fallback (void)
 {
   hp_timing_t result = 0L;
 
-#ifdef SHARED
-  /* The vDSO does not return an error (it clear cr0.so on returning).  */
-  INTERNAL_SYSCALL_DECL (err);
-  result =
-    INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK (get_tbfreq, err, uint64_t, 0);
-#else
   /* We read the information from the /proc filesystem.  /proc/cpuinfo
      contains at least one line like:
      timebase        : 33333333
@@ -99,8 +93,20 @@ __get_timebase_freq (void)
 	    }
 	}
     }
-#endif
 
   return result;
 }
+
+uint64_t
+__get_timebase_freq (void)
+{
+  /* The vDSO does not have a fallback mechanism (such calling a syscall).  */
+  __typeof (VDSO_SYMBOL (get_tbfreq)) vdsop = VDSO_SYMBOL (get_tbfreq);
+  PTR_DEMANGLE (vdsop);
+  if (vdsop == NULL)
+    return get_timebase_freq_fallback ();
+
+  INTERNAL_SYSCALL_DECL (err);
+  return INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, uint64_t, 0);
+}
 weak_alias (__get_timebase_freq, __ppc_get_timebase_freq)
diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
index 6b92e2807b..47859abf7a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
@@ -58,7 +58,7 @@ __gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
 }
 
 # define INIT_ARCH()						\
-  void *vdso_gettimeofday = get_vdso_symbol ("__kernel_gettimeofday")
+  void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL)
   
 
 /* If the vDSO is not available we fall back syscall.  */
diff --git a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
index 47e925493b..170adcc964 100644
--- a/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
+++ b/sysdeps/unix/sysv/linux/powerpc/libc-vdso.h
@@ -22,17 +22,9 @@
 
 #include <sysdep.h>
 #include <sysdep-vdso.h>
-#include_next <libc-vdso.h>
-
-extern unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
-#if defined(__PPC64__) || defined(__powerpc64__)
-extern void *VDSO_SYMBOL(sigtramp_rt64);
-#else
-extern void *VDSO_SYMBOL(sigtramp32);
-extern void *VDSO_SYMBOL(sigtramp_rt32);
-#endif
 
 #if (defined(__PPC64__) || defined(__powerpc64__)) && _CALL_ELF != 2
+# include <dl-machine.h>
 /* The correct solution is for _dl_vdso_vsym to return the address of the OPD
    for the kernel VDSO function.  That address would then be stored in the
    __vdso_* variables and returned as the result of the IFUNC resolver function.
@@ -51,7 +43,7 @@ extern void *VDSO_SYMBOL(sigtramp_rt32);
    are processed immediately at startup the resolver functions and this code need
    not be thread-safe, but if the caller writes to a PLT slot it must do so in a
    thread-safe manner with all the required barriers.  */
-#define VDSO_IFUNC_RET(value)                            \
+# define VDSO_IFUNC_RET(value)                           \
   ({                                                     \
     static Elf64_FuncDesc vdso_opd = { .fd_toc = ~0x0 }; \
     vdso_opd.fd_func = (Elf64_Addr)value;                \
@@ -59,7 +51,17 @@ extern void *VDSO_SYMBOL(sigtramp_rt32);
   })
 
 #else
-#define VDSO_IFUNC_RET(value)  ((void *) (value))
+# define VDSO_IFUNC_RET(value)  ((void *) (value))
+#endif
+
+#include_next <libc-vdso.h>
+
+extern unsigned long long (*VDSO_SYMBOL(get_tbfreq)) (void);
+#if defined(__PPC64__) || defined(__powerpc64__)
+extern void *VDSO_SYMBOL(sigtramp_rt64);
+#else
+extern void *VDSO_SYMBOL(sigtramp32);
+extern void *VDSO_SYMBOL(sigtramp_rt32);
 #endif
 
 #endif /* _LIBC_VDSO_H */
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
index f459543fcd..703c668a92 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
@@ -41,7 +41,7 @@
    function call, with the exception of LR (which is needed for the
    "sc; bnslr+" sequence) and CR (where only CR0.SO is clobbered to signal
    an error return status).  */
-# define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, nr, type, args...)	      \
+# define INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, type, nr, args...)	      \
   ({									      \
     register void *r0  __asm__ ("r0");					      \
     register long int r3  __asm__ ("r3");				      \
@@ -69,7 +69,7 @@
   })
 
 #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \
-  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, nr, long int, args)
+  INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
 
 # undef INLINE_SYSCALL
 # define INLINE_SYSCALL(name, nr, args...)				\
@@ -131,20 +131,6 @@
 # undef INTERNAL_SYSCALL_ERRNO
 # define INTERNAL_SYSCALL_ERRNO(val, err)     (val)
 
-# define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, type, nr, args...)  \
-  ({									      \
-    type sc_ret = ENOSYS;						      \
-									      \
-    __typeof (__vdso_##name) vdsop = __vdso_##name;			      \
-    PTR_DEMANGLE (vdsop);						      \
-    if (vdsop != NULL)							      \
-      sc_ret = 								      \
-        INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, nr, type, ##args);	      \
-    else								      \
-      err = 1 << 28;							      \
-    sc_ret;								      \
-  })
-
 # define LOADARGS_0(name, dummy)					      \
 	r0 = name
 # define LOADARGS_1(name, __arg1) \
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
index 06222f52e6..e7b2fce05f 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
@@ -45,22 +45,6 @@
 
 #endif /* __ASSEMBLER__ */
 
-/* This version is for internal uses when there is no desire
-   to set errno */
-#define INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK(name, err, type, nr, args...)   \
-  ({									      \
-    type sc_ret = ENOSYS;						      \
-									      \
-    __typeof (__vdso_##name) vdsop = __vdso_##name;			      \
-    PTR_DEMANGLE (vdsop);						      \
-    if (vdsop != NULL)							      \
-      sc_ret =								      \
-        INTERNAL_VSYSCALL_CALL_TYPE (vdsop, err, type, nr, ##args);	      \
-    else								      \
-      err = 1 << 28;							      \
-    sc_ret;								      \
-  })
-
 /* 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
    normally. It will never touch errno. This returns just what the kernel
@@ -94,10 +78,9 @@
 #define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...)		\
   INTERNAL_VSYSCALL_CALL_TYPE(funcptr, err, long int, nr, args)
 
-#undef INLINE_SYSCALL
-
 /* This version is for kernels that implement system calls that
    behave like function calls as far as register saving.  */
+#undef INLINE_SYSCALL
 #define INLINE_SYSCALL(name, nr, args...)				\
   ({									\
     INTERNAL_SYSCALL_DECL (sc_err);					\
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 20167615c8..357d1b5243 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -24,6 +24,7 @@
 #define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 #define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
 #define HAVE_TIME_VSYSCALL		"__kernel_time"
+#define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
 #define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
 #if defined(__PPC64__) || defined(__powerpc64__)
diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c
index 53fd119b00..4856da0862 100644
--- a/sysdeps/unix/sysv/linux/powerpc/time.c
+++ b/sysdeps/unix/sysv/linux/powerpc/time.c
@@ -67,7 +67,7 @@ time_syscall (time_t *t)
 }
 
 # define INIT_ARCH()							\
-  void *vdso_time = get_vdso_symbol ("__kernel_time");
+  void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL);
 
 /* If the vDSO is not available we fall back to the syscall.  */
 libc_ifunc_hidden (__redirect_time, time,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 11/12] linux: Consolidate time implementation
  2019-06-14 15:29 ` [PATCH 11/12] linux: Consolidate time implementation Adhemerval Zanella
@ 2019-06-25 18:24   ` Florian Weimer
  2019-06-25 19:47     ` Adhemerval Zanella
  2019-06-28 22:45   ` Tulio Magno Quites Machado Filho
  2019-07-08 20:47   ` Adhemerval Zanella
  2 siblings, 1 reply; 33+ messages in thread
From: Florian Weimer @ 2019-06-25 18:24 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> 	* include/libc-symbols.h (hidden_def_redir): New macro.

This macro should have documentation in the large common block above it.
Its purpose isn't obvious to me.

> +#if HAVE_IFUNC && defined USE_TIME_VSYSCALL_IFUNC
> +/* Route externals calls direct to vDSO and static and internal calls to
> +   fallback implementation (which also might call the vDSO).  */
> +# ifdef SHARED
> +#  define INIT_ARCH()
> +libc_ifunc_redirected (__redirect_time, time,
> +		       get_vdso_symbol (HAVE_TIME_VSYSCALL)
> +		       ?: time_syscall);
> +libc_hidden_def_redir (time_syscall, time)
> +#  else
> +strong_alias (time_syscall, time)
> +#  endif /* SHARED  */

Does this really work on x86-64?  I don't think it's possible to call
IFUNCs through hidden aliases.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 11/12] linux: Consolidate time implementation
  2019-06-25 18:24   ` Florian Weimer
@ 2019-06-25 19:47     ` Adhemerval Zanella
  2019-06-26 13:03       ` Florian Weimer
  0 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2019-06-25 19:47 UTC (permalink / raw)
  To: Florian Weimer; +Cc: libc-alpha



On 25/06/2019 15:24, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> 	* include/libc-symbols.h (hidden_def_redir): New macro.
> 
> This macro should have documentation in the large common block above it.
> Its purpose isn't obvious to me.
> 
>> +#if HAVE_IFUNC && defined USE_TIME_VSYSCALL_IFUNC
>> +/* Route externals calls direct to vDSO and static and internal calls to
>> +   fallback implementation (which also might call the vDSO).  */
>> +# ifdef SHARED
>> +#  define INIT_ARCH()
>> +libc_ifunc_redirected (__redirect_time, time,
>> +		       get_vdso_symbol (HAVE_TIME_VSYSCALL)
>> +		       ?: time_syscall);
>> +libc_hidden_def_redir (time_syscall, time)
>> +#  else
>> +strong_alias (time_syscall, time)
>> +#  endif /* SHARED  */
> 
> Does this really work on x86-64?  I don't think it's possible to call
> IFUNCs through hidden aliases.

The idea is to not call an IFUNC in the static case nor on internal 
hidden case for shared case. Only external calls are routes through
iFUNC.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 11/12] linux: Consolidate time implementation
  2019-06-25 19:47     ` Adhemerval Zanella
@ 2019-06-26 13:03       ` Florian Weimer
  0 siblings, 0 replies; 33+ messages in thread
From: Florian Weimer @ 2019-06-26 13:03 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> On 25/06/2019 15:24, Florian Weimer wrote:
>> * Adhemerval Zanella:
>> 
>>> 	* include/libc-symbols.h (hidden_def_redir): New macro.
>> 
>> This macro should have documentation in the large common block above it.
>> Its purpose isn't obvious to me.
>> 
>>> +#if HAVE_IFUNC && defined USE_TIME_VSYSCALL_IFUNC
>>> +/* Route externals calls direct to vDSO and static and internal calls to
>>> +   fallback implementation (which also might call the vDSO).  */
>>> +# ifdef SHARED
>>> +#  define INIT_ARCH()
>>> +libc_ifunc_redirected (__redirect_time, time,
>>> +		       get_vdso_symbol (HAVE_TIME_VSYSCALL)
>>> +		       ?: time_syscall);
>>> +libc_hidden_def_redir (time_syscall, time)
>>> +#  else
>>> +strong_alias (time_syscall, time)
>>> +#  endif /* SHARED  */
>> 
>> Does this really work on x86-64?  I don't think it's possible to call
>> IFUNCs through hidden aliases.
>
> The idea is to not call an IFUNC in the static case nor on internal 
> hidden case for shared case. Only external calls are routes through
> iFUNC.

I see.  I will try to review the change with this in mind.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 08/12] powerpc: Refactor vsyscall internal macros
  2019-06-18 17:31     ` Adhemerval Zanella
@ 2019-06-28 22:01       ` Tulio Magno Quites Machado Filho
  0 siblings, 0 replies; 33+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2019-06-28 22:01 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:

> Subject: [PATCH 08/12] powerpc: Simplify vsyscall internal macros
>
> This patch simplifies the powerpc internal macros for vDSO calls
> by:
>
>   - Removing INTERNAL_VSYSCALL_NO_SYSCALL_FALLBACK, used solely on
>     get_timebase_freq.
>
>   - Adjust INTERNAL_VSYSCALL_CALL_TYPE powerpc32 to follow powerpc64
>     argument ordering.
>
>   - Use HAVE_*_VSYSCALL instead of explicit strings.
>
>   - Make powerpc libc-vdso.h include generic implementation.
>
> No semantic change expected, checked on powerpc-linux-gnu-power4,
> powerpc64-linux-gnu, and powerpc64le-linux-gnu.

LGTM.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 11/12] linux: Consolidate time implementation
  2019-06-14 15:29 ` [PATCH 11/12] linux: Consolidate time implementation Adhemerval Zanella
  2019-06-25 18:24   ` Florian Weimer
@ 2019-06-28 22:45   ` Tulio Magno Quites Machado Filho
  2019-07-01 21:00     ` Adhemerval Zanella
  2019-07-08 20:47   ` Adhemerval Zanella
  2 siblings, 1 reply; 33+ messages in thread
From: Tulio Magno Quites Machado Filho @ 2019-06-28 22:45 UTC (permalink / raw)
  To: Adhemerval Zanella, libc-alpha

Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:

> The time syscall has currently 3 possible implementations:
>
>    1. Wire-up __NR_time with a vDSO implementation (currently only x86 and
>       powerpc).
>    2. Wire-up __NR_time (hppa, i686, m68k, microblaze, mips, powerpc,
>       powerpc64, s390, sh4, sparcv9, x86_64).
>    3. Using internal gettimeofday (aarch64, alpha, arm, mips64, mips64-n32,
>       nios2, s390x, sparc64).
>
> This patch consolidates all implementation on Linux generic
> sysdeps/unix/sysv/linux/time.c.  To simplify the code, some changes are
> made:
>
>    * The wire-up with vDSO implementation route external calls directly
>      to vDSO through IFUNC.  To enable it the architecture need to
>      explicit define USE_TIME_VSYSCALL_IFUNC.
>
>    * Also, powerpc and x86 tries to route internal time usages to
>      IFUNC mechanism, which is problematic since powerpc32 and i686 does
>      not really support it.  Instead, all internal calls are routed to
>      a default internal symbol which in turn calls INTERNAL_VSYSCALL.
>
>    * Static linking also uses the fallback mechanism which calls
>      INTERNAL_VSYSCALL, so vDSO is used for this case as well.
>
> The generic implementation issues a syscall as default, calls the
> vDSO if the architecture defines HAVE_TIME_VSYSCALL, and route the external
> calls to iFUNC if the architecture also defines USE_TIME_VSYSCALL_IFUNC.
>
> Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
> powerpc64-linux-gnu, powerpc64le-linux-gnu, and aarch64-linux-gnu.

This patch is causing segmentation faults in powerpc64, e.g.
$ ./testrun.sh ./io/test-utime
Segmentation fault

> diff --git a/sysdeps/unix/sysv/linux/time.c b/sysdeps/unix/sysv/linux/time.c
> index 1978f6d817..93e036fe16 100644
> --- a/sysdeps/unix/sysv/linux/time.c
> +++ b/sysdeps/unix/sysv/linux/time.c
> ...
> +#if HAVE_IFUNC && defined USE_TIME_VSYSCALL_IFUNC
> +/* Route externals calls direct to vDSO and static and internal calls to
> +   fallback implementation (which also might call the vDSO).  */
> +# ifdef SHARED
> +#  define INIT_ARCH()
> +libc_ifunc_redirected (__redirect_time, time,
> +		       get_vdso_symbol (HAVE_TIME_VSYSCALL)
> +		       ?: time_syscall);

Missing VDSO_IFUNC_RET ?

-- 
Tulio Magno

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 11/12] linux: Consolidate time implementation
  2019-06-28 22:45   ` Tulio Magno Quites Machado Filho
@ 2019-07-01 21:00     ` Adhemerval Zanella
  0 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-07-01 21:00 UTC (permalink / raw)
  To: Tulio Magno Quites Machado Filho, libc-alpha



On 28/06/2019 19:45, Tulio Magno Quites Machado Filho wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> 
>> The time syscall has currently 3 possible implementations:
>>
>>    1. Wire-up __NR_time with a vDSO implementation (currently only x86 and
>>       powerpc).
>>    2. Wire-up __NR_time (hppa, i686, m68k, microblaze, mips, powerpc,
>>       powerpc64, s390, sh4, sparcv9, x86_64).
>>    3. Using internal gettimeofday (aarch64, alpha, arm, mips64, mips64-n32,
>>       nios2, s390x, sparc64).
>>
>> This patch consolidates all implementation on Linux generic
>> sysdeps/unix/sysv/linux/time.c.  To simplify the code, some changes are
>> made:
>>
>>    * The wire-up with vDSO implementation route external calls directly
>>      to vDSO through IFUNC.  To enable it the architecture need to
>>      explicit define USE_TIME_VSYSCALL_IFUNC.
>>
>>    * Also, powerpc and x86 tries to route internal time usages to
>>      IFUNC mechanism, which is problematic since powerpc32 and i686 does
>>      not really support it.  Instead, all internal calls are routed to
>>      a default internal symbol which in turn calls INTERNAL_VSYSCALL.
>>
>>    * Static linking also uses the fallback mechanism which calls
>>      INTERNAL_VSYSCALL, so vDSO is used for this case as well.
>>
>> The generic implementation issues a syscall as default, calls the
>> vDSO if the architecture defines HAVE_TIME_VSYSCALL, and route the external
>> calls to iFUNC if the architecture also defines USE_TIME_VSYSCALL_IFUNC.
>>
>> Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
>> powerpc64-linux-gnu, powerpc64le-linux-gnu, and aarch64-linux-gnu.
> 
> This patch is causing segmentation faults in powerpc64, e.g.
> $ ./testrun.sh ./io/test-utime
> Segmentation fault
> 

Indeed when I had to refactor the 'powerpc: Refactor vsyscall internal macros'
I forgot to update both the gettimeofday and time one, which required some
changes as well.  I will send an updated version.

>> diff --git a/sysdeps/unix/sysv/linux/time.c b/sysdeps/unix/sysv/linux/time.c
>> index 1978f6d817..93e036fe16 100644
>> --- a/sysdeps/unix/sysv/linux/time.c
>> +++ b/sysdeps/unix/sysv/linux/time.c
>> ...
>> +#if HAVE_IFUNC && defined USE_TIME_VSYSCALL_IFUNC
>> +/* Route externals calls direct to vDSO and static and internal calls to
>> +   fallback implementation (which also might call the vDSO).  */
>> +# ifdef SHARED
>> +#  define INIT_ARCH()
>> +libc_ifunc_redirected (__redirect_time, time,
>> +		       get_vdso_symbol (HAVE_TIME_VSYSCALL)
>> +		       ?: time_syscall);
> 
> Missing VDSO_IFUNC_RET ?
> 


^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 11/12] linux: Consolidate time implementation
  2019-06-14 15:29 ` [PATCH 11/12] linux: Consolidate time implementation Adhemerval Zanella
  2019-06-25 18:24   ` Florian Weimer
  2019-06-28 22:45   ` Tulio Magno Quites Machado Filho
@ 2019-07-08 20:47   ` Adhemerval Zanella
  2 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-07-08 20:47 UTC (permalink / raw)
  To: libc-alpha

Updated patch from previous comment and requirements.  I have added more
comments for the hidden_def macros and adjusted due powerpc64 required
changes.

---

The time syscall has currently 3 possible implementations:

   1. Wire-up __NR_time with a vDSO implementation (currently only x86 and
      powerpc).
   2. Wire-up __NR_time (hppa, i686, m68k, microblaze, mips, powerpc,
      powerpc64, s390, sh4, sparcv9, x86_64).
   3. Using internal gettimeofday (aarch64, alpha, arm, mips64, mips64-n32,
      nios2, s390x, sparc64).

This patch consolidates all implementation on Linux generic
sysdeps/unix/sysv/linux/time.c.  To simplify the code, some changes are
made:

   * The wire-up with vDSO implementation route external calls directly
     to vDSO through IFUNC.  To enable it the architecture need to
     explicit define USE_TIME_VSYSCALL_IFUNC.

   * Also, powerpc and x86 tries to route internal time usages to
     IFUNC mechanism, which is problematic since powerpc32 and i686 does
     not really support it.  Instead, all internal calls are routed to
     a default internal symbol which in turn calls INTERNAL_VSYSCALL.

   * Static linking also uses the fallback mechanism which calls
     INTERNAL_VSYSCALL, so vDSO is used for this case as well.

The generic implementation issues a syscall as default, calls the
vDSO if the architecture defines HAVE_TIME_VSYSCALL, and route the external
calls to iFUNC if the architecture also defines USE_TIME_VSYSCALL_IFUNC.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
powerpc64-linux-gnu, powerpc64le-linux-gnu, and aarch64-linux-gnu.

	* include/libc-symbols.h (hidden_def_redir): New macro.
	* sysdeps/unix/sysv/linux/i386/sysdep.h (HAVE_TIME_VSYSCALL,
	USE_TIME_VSYSCALL_IFUNC): Define.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (HAVE_TIME_VSYSCALL,
	USE_TIME_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h (USE_TIME_VSYSCALL_IFUNC):
	Likewise.
	* sysdeps/unix/sysv/linux/i386/time.c: Remove file.
	* sysdeps/unix/sysv/linux/x86/time.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/time.c: Likewise.
	* sysdeps/unix/sysv/linux/time.c (time): Handle all possible Linux
	implementations (wire-up syscall, vDSO implementation, iFUNC).
	(time_syscall): New function.
---
 include/libc-symbols.h                   | 11 ++++
 sysdeps/unix/sysv/linux/i386/sysdep.h    |  2 +
 sysdeps/unix/sysv/linux/i386/time.c      | 34 ----------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h |  1 +
 sysdeps/unix/sysv/linux/powerpc/time.c   | 83 ------------------------
 sysdeps/unix/sysv/linux/time.c           | 57 +++++++++++++---
 sysdeps/unix/sysv/linux/x86/time.c       | 60 -----------------
 sysdeps/unix/sysv/linux/x86_64/sysdep.h  |  2 +
 8 files changed, 65 insertions(+), 185 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/i386/time.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/time.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/time.c

diff --git a/include/libc-symbols.h b/include/libc-symbols.h
index b68ec4b7f5..a585a04e63 100644
--- a/include/libc-symbols.h
+++ b/include/libc-symbols.h
@@ -491,6 +491,12 @@ for linking")
    int foo = INITIAL_FOO_VALUE;
    libc_hidden_data_weak (foo)
 
+   If the internal foo should use a different internal symbol (for instance
+   if the symbol is exported as an IFUNC, but internal calls should use a
+   default version) then you may use:
+
+   libc_hidden_def_redir (foo_internal, foo)
+
    If foo is normally just an alias (strong or weak) to some other function,
    you should use the normal strong_alias first, then add libc_hidden_def
    or libc_hidden_weak:
@@ -548,6 +554,7 @@ for linking")
 #  define hidden_ver(local, name)	__hidden_ver1(local, __GI_##name, name);
 #  define hidden_data_ver(local, name)	hidden_ver(local, name)
 #  define hidden_def(name)		__hidden_ver1(__GI_##name, name, name);
+#  define hidden_def_redir(redir, name)	__hidden_ver1(redir, __GI_##name, redir);
 #  define hidden_data_def(name)		hidden_def(name)
 #  define hidden_tls_def(name)				\
   __hidden_ver2 (__thread, __GI_##name, name, name);
@@ -575,6 +582,7 @@ for linking")
    hidden_proto doesn't make sense for assembly but the equivalent
    is to call via the HIDDEN_JUMPTARGET macro instead of JUMPTARGET.  */
 #  define hidden_def(name)	strong_alias (name, __GI_##name)
+#  define hidden_def_redir(redir, name)	strong_alias(redir, __GI_##name);
 #  define hidden_weak(name)	hidden_def (name)
 #  define hidden_ver(local, name) strong_alias (local, __GI_##name)
 #  define hidden_data_def(name)	strong_data_alias (name, __GI_##name)
@@ -605,6 +613,7 @@ for linking")
 # endif /* Not  __ASSEMBLER__ */
 # define hidden_weak(name)
 # define hidden_def(name)
+# define hidden_def_redir(redir, name)
 # define hidden_ver(local, name)
 # define hidden_data_weak(name)
 # define hidden_data_def(name)
@@ -617,6 +626,7 @@ for linking")
 # define libc_hidden_proto(name, attrs...) hidden_proto (name, ##attrs)
 # define libc_hidden_tls_proto(name, attrs...) hidden_tls_proto (name, ##attrs)
 # define libc_hidden_def(name) hidden_def (name)
+# define libc_hidden_def_redir(redir, name) hidden_def_redir (redir, name)
 # define libc_hidden_weak(name) hidden_weak (name)
 # ifdef LINK_OBSOLETE_RPC
    /* libc_hidden_nolink_sunrpc should only get used in sunrpc code.  */
@@ -633,6 +643,7 @@ for linking")
 # define libc_hidden_proto(name, attrs...)
 # define libc_hidden_tls_proto(name, attrs...)
 # define libc_hidden_def(name)
+# define libc_hidden_def_redir(redir, name)
 # define libc_hidden_weak(name)
 # define libc_hidden_ver(local, name)
 # define libc_hidden_data_def(name)
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index e793fdc936..4f79f25989 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 USE_TIME_VSYSCALL_IFUNC	1
 
 /* 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/i386/time.c b/sysdeps/unix/sysv/linux/i386/time.c
deleted file mode 100644
index 440e3e6ab4..0000000000
--- a/sysdeps/unix/sysv/linux/i386/time.c
+++ /dev/null
@@ -1,34 +0,0 @@
-/* time -- Get number of seconds since Epoch.  Linux/i386 version.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifdef SHARED
-# define time __redirect_time
-#endif
-
-#include <time.h>
-
-#ifdef SHARED
-# undef time
-# define time_type __redirect_time
-
-# undef libc_hidden_def
-# define libc_hidden_def(name)  \
-  __hidden_ver1 (__time_syscall, __GI_time, __time_syscall);
-#endif
-
-#include <sysdeps/unix/sysv/linux/x86/time.c>
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 357d1b5243..084b6525ca 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -24,6 +24,7 @@
 #define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 #define HAVE_GETCPU_VSYSCALL		"__kernel_getcpu"
 #define HAVE_TIME_VSYSCALL		"__kernel_time"
+#define USE_TIME_VSYSCALL_IFUNC		1
 #define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
 #define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/time.c b/sysdeps/unix/sysv/linux/powerpc/time.c
deleted file mode 100644
index f0537a2307..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/time.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/* time system call for Linux/PowerPC.
-   Copyright (C) 2013-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifdef SHARED
-# ifndef __powerpc64__
-#  define time __redirect_time
-# else
-#  define __redirect_time time
-# endif
-
-# include <time.h>
-# include <sysdep.h>
-# include <dl-vdso.h>
-# include <libc-vdso.h>
-# include <dl-machine.h>
-
-# ifndef __powerpc64__
-#  undef time
-
-time_t
-__time_vsyscall (time_t *t)
-{
-  return INLINE_VSYSCALL (time, 1, t);
-}
-
-/* __GI_time is defined as hidden and for ppc32 it enables the
-   compiler make a local call (symbol@local) for internal GLIBC usage. It
-   means the PLT won't be used and the ifunc resolver will be called directly.
-   For ppc64 a call to a function in another translation unit might use a
-   different toc pointer thus disallowing direct branchess and making internal
-   ifuncs calls safe.  */
-#  undef libc_hidden_def
-#  define libc_hidden_def(name)					\
-  __hidden_ver1 (__time_vsyscall, __GI_time, __time_vsyscall);
-
-# endif /* !__powerpc64__  */
-
-static time_t
-time_syscall (time_t *t)
-{
-  struct timeval tv;
-  time_t result;
-
-  if (INLINE_VSYSCALL (gettimeofday, 2, &tv, NULL) < 0)
-    result = (time_t) -1;
-  else
-    result = (time_t) tv.tv_sec;
-
-  if (t != NULL)
-    *t = result;
-  return result;
-}
-
-# define INIT_ARCH() \
-  void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL);
-
-/* If the vDSO is not available we fall back to the syscall.  */
-libc_ifunc_hidden (__redirect_time, time,
-		   vdso_time
-		   ? VDSO_IFUNC_RET (vdso_time)
-		   : (void *) time_syscall);
-libc_hidden_def (time)
-
-#else
-
-#include <sysdeps/posix/time.c>
-
-#endif /* !SHARED */
diff --git a/sysdeps/unix/sysv/linux/time.c b/sysdeps/unix/sysv/linux/time.c
index 1978f6d817..9176fe6ed7 100644
--- a/sysdeps/unix/sysv/linux/time.c
+++ b/sysdeps/unix/sysv/linux/time.c
@@ -15,27 +15,68 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <stddef.h>
+/* Currently we have 3 possible time implementations, which is also selected
+   in the order:
+
+   1. Wire-up __NR_time with a vDSO implementation (currently only x86 and
+      powerpc).
+   2. Only wire-up __NR_time (usually old kABIs).
+   3. Using internal gettimeofday (which may call a vDSO as well).  */
+
+#define time __redirect_time
 #include <time.h>
+#undef time
+#include <sys/time.h>
 
 #include <sysdep.h>
+#ifdef HAVE_TIME_VSYSCALL
+# define HAVE_VSYSCALL
+#endif
+#include <sysdep-vdso.h>
+#include <libc-vdso.h>
 
-#ifdef __NR_time
-
-time_t
-time (time_t *t)
+static time_t
+time_syscall (time_t *t)
 {
+  time_t res;
+#ifdef __NR_time
   INTERNAL_SYSCALL_DECL (err);
-  time_t res = INTERNAL_SYSCALL (time, err, 1, NULL);
+  res = INTERNAL_VSYSCALL (time, err, 1, NULL);
   /* There cannot be any error.  */
+#else
+  struct timeval tv;
+  /* gettimeofday does not fail with valid 'tv' and null timezone.  */
+  __gettimeofday (&tv, NULL);
+  res = tv.tv_sec;
+#endif
   if (t != NULL)
     *t = res;
   return res;
 }
-libc_hidden_def (time)
 
+#if HAVE_IFUNC && defined USE_TIME_VSYSCALL_IFUNC
+/* Route externals calls direct to vDSO and static and internal calls to
+   fallback implementation (which also might call the vDSO).  */
+# ifdef SHARED
+#  undef INIT_ARCH
+#  define INIT_ARCH() \
+  void *vdso_time = get_vdso_symbol (HAVE_TIME_VSYSCALL);
+
+libc_ifunc_redirected (__redirect_time, time,
+		       vdso_time
+		       ? VDSO_IFUNC_RET (vdso_time)
+		       : (void *) time_syscall);
+libc_hidden_def_redir (time_syscall, time)
+#  else
+strong_alias (time_syscall, time)
+#  endif /* SHARED  */
 #else
 
-# include <sysdeps/posix/time.c>
+time_t
+time (time_t *t)
+{
+  return time_syscall (t);
+}
+libc_hidden_def_redir (time, time)
 
 #endif
diff --git a/sysdeps/unix/sysv/linux/x86/time.c b/sysdeps/unix/sysv/linux/x86/time.c
deleted file mode 100644
index 60e6d1b7c0..0000000000
--- a/sysdeps/unix/sysv/linux/x86/time.c
+++ /dev/null
@@ -1,60 +0,0 @@
-/* time -- Get number of seconds since Epoch.  Linux/x86 version.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <time.h>
-
-#ifdef SHARED
-
-#include <dl-vdso.h>
-#include <errno.h>
-#include <sysdep-vdso.h>
-
-static time_t
-__time_syscall (time_t *t)
-{
-  INTERNAL_SYSCALL_DECL (err);
-  return INTERNAL_SYSCALL (time, err, 1, t);
-}
-
-# ifndef time_type
-/* The i386 time.c includes this file with a defined time_type macro.
-   For x86_64 we have to define it to time as the internal symbol is the
-   ifunc'ed one.  */
-#  define time_type time
-# endif
-
-#undef INIT_ARCH
-#define INIT_ARCH()
-
-/* If the vDSO is not available we fall back on the syscall.  */
-libc_ifunc_hidden (time_type, time,
-		   (get_vdso_symbol ("__vdso_time") ?: __time_syscall))
-libc_hidden_def (time)
-
-#else
-
-# include <sysdep.h>
-
-time_t
-time (time_t *t)
-{
-  INTERNAL_SYSCALL_DECL (err);
-  return INTERNAL_SYSCALL (time, err, 1, t);
-}
-
-#endif
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index 4541c0d492..c64fbd1e26 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -376,6 +376,8 @@
 /* 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 USE_TIME_VSYSCALL_IFUNC	1
 # define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
 
 # define SINGLE_THREAD_BY_GLOBAL		1
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 12/12] linux: Consolidate gettimeofday implementation
  2019-06-14 15:29 ` [PATCH 12/12] linux: Consolidate gettimeofday implementation Adhemerval Zanella
@ 2019-07-08 20:47   ` Adhemerval Zanella
  0 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-07-08 20:47 UTC (permalink / raw)
  To: libc-alpha

Updated patch from previous comment and requirements.  I have added more
comments for the hidden_def macros and adjusted due powerpc64 required
changes.

---

The gettimeofday syscall has currently 3 possible implementations:

  1. Wire-up __NR_gettimeofday with a VDSO implementation accessed
     directly through IFUNC (aarch64, x86, and powerpc*).

  2. vDSO gettimeofday (arm, mips*, riscv*, s390, and sparc).

  3. Wire-up __NR_gettimeofday (alpha, hppa, ia64, m68k, microblaze,
     nios, sh4).

This patch consolidates all implementation on Linux generic
sysdeps/unix/sysv/linux/gettimeofday.c.  To simplify the code, some changes
are made:

   * The wire-up with vDSO implementation may route external calls directly
     to vDSO through IFUNC.  To enable it the architecture need to
     explicit define USE_GETTIMEOFDAY_VSYSCALL_IFUNC.

   * Also, powerpc and x86 tries to route internal time usages to
     IFUNC mechanism, which is problematic since powerpc32 and i686 does
     not really support it.  Instead, all internal calls are routed to
     a default internal symbol which in turn calls INTERNAL_VSYSCALL.

   * Static linking also uses the fallback mechanism which calls
     INTERNAL_VSYSCALL, so vDSO is used for this case as well.

The generic implementation issues a syscall as default, calls the
vDSO if the architecture defines HAVE_GETTIMEOFDAY_VSYSCALL, and
route the external calls to iFUNC if the architecture also defines
USE_GETTIMEOFDAY_VSYSCALL_IFUNC.

Checked on x86_64-linux-gnu, i686-linux-gnu, powerpc-linux-gnu,
powerpc64-linux-gnu, powerpc64le-linux-gnu, and aarch64-linux-gnu.

	* sysdeps/unix/sysv/linux/aarch64/gettimeofday.c: Remove file.
	* sysdeps/unix/sysv/linux/i386/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/gettimeofday.c: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Define.
	* sysdeps/unix/sysv/linux/i386/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sysdep.h
	(USE_GETTIMEOFDAY_VSYSCALL_IFUNC): Likewise.
	* sysdeps/unix/sysv/linux/gettimeofday.c (gettimeofday): Handle all
	possible Linux implementations (wire-up syscall, vDSO implementation,
	and iFUNC).
        (gettimeofday_syscall): New function.
---
 .../unix/sysv/linux/aarch64/gettimeofday.c    | 58 -------------
 sysdeps/unix/sysv/linux/aarch64/sysdep.h      |  1 +
 sysdeps/unix/sysv/linux/gettimeofday.c        | 51 +++++++++--
 sysdeps/unix/sysv/linux/i386/gettimeofday.c   | 35 --------
 sysdeps/unix/sysv/linux/i386/sysdep.h         |  1 +
 .../unix/sysv/linux/powerpc/gettimeofday.c    | 84 -------------------
 sysdeps/unix/sysv/linux/powerpc/sysdep.h      |  1 +
 sysdeps/unix/sysv/linux/x86/gettimeofday.c    | 63 --------------
 sysdeps/unix/sysv/linux/x86_64/sysdep.h       |  1 +
 9 files changed, 48 insertions(+), 247 deletions(-)
 delete mode 100644 sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/i386/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
 delete mode 100644 sysdeps/unix/sysv/linux/x86/gettimeofday.c

diff --git a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c b/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
deleted file mode 100644
index 9499a11fda..0000000000
--- a/sysdeps/unix/sysv/linux/aarch64/gettimeofday.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Copyright (C) 2018-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
-   <http://www.gnu.org/licenses/>.  */
-
-/* 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 <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <sysdep-vdso.h>
-
-/* 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 *tv, struct timezone *tz)
-{
-  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
-}
-
-# define INIT_ARCH()
-libc_ifunc_hidden (__gettimeofday, __gettimeofday,
-		   (get_vdso_symbol ("__vdso_gettimeofday")
-		    ?: __gettimeofday_vsyscall))
-libc_hidden_def (__gettimeofday)
-
-#else
-
-# include <sysdep.h>
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-libc_hidden_def (__gettimeofday)
-
-#endif
-
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
index d57f7232e2..526741ed82 100644
--- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
@@ -163,6 +163,7 @@
 # define HAVE_CLOCK_GETRES_VSYSCALL	"__kernel_clock_getres"
 # define HAVE_CLOCK_GETTIME_VSYSCALL	"__kernel_clock_gettime"
 # define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
+# define USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 
 /* Previously AArch64 used the generic version without the libc_hidden_def
    which lead in a non existent __send symbol in libc.so.  */
diff --git a/sysdeps/unix/sysv/linux/gettimeofday.c b/sysdeps/unix/sysv/linux/gettimeofday.c
index a74f03825a..833e97ca7d 100644
--- a/sysdeps/unix/sysv/linux/gettimeofday.c
+++ b/sysdeps/unix/sysv/linux/gettimeofday.c
@@ -16,24 +16,61 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <errno.h>
-#include <sys/time.h>
+/* Currently we have 3 possible gettimeofday implementations, which is also
+   selected in the order:
+
+   1. Wire-up __NR_gettimeofday with a vDSO implementation (currently aarch64,
+      x86, and powerpc).
+
+   2. vDSO gettimeofday (arm, mips*, riscv*, s390, and sparc).
+
+   3. Wire-up __NR_gettimeofday (alpha, hppa, ia64, m68k, microblaze,
+      nios, sh4).  */
 
+#define __gettimeofday __redirect___gettimeofday
+#include <sys/time.h>
 #undef __gettimeofday
 
+#include <sysdep.h>
 #ifdef HAVE_GETTIMEOFDAY_VSYSCALL
 # define HAVE_VSYSCALL
 #endif
 #include <sysdep-vdso.h>
+#include <libc-vdso.h>
+
+/* 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.  */
+static int
+gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
+{
+  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
+}
+
+#if HAVE_IFUNC && defined USE_GETTIMEOFDAY_VSYSCALL_IFUNC
+/* Route externals calls direct to vDSO and static and internal calls to
+   fallback implementation (which also might call the vDSO).  */
+# ifdef SHARED
+#  undef INIT_ARCH
+#  define INIT_ARCH() \
+  void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL)
+
+libc_ifunc_redirected (__redirect___gettimeofday, __gettimeofday,
+		       vdso_gettimeofday
+		       ? VDSO_IFUNC_RET (vdso_gettimeofday)
+		       : (void *) gettimeofday_syscall);
+libc_hidden_def_redir (gettimeofday_syscall, __gettimeofday)
+#  else
+strong_alias (gettimeofday_syscall, __gettimeofday)
+#  endif /* SHARED  */
+#else
 
-/* 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.  */
 int
 __gettimeofday (struct timeval *tv, struct timezone *tz)
 {
-  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
+  return gettimeofday_syscall (tv, tz);
 }
-libc_hidden_def (__gettimeofday)
+libc_hidden_def_redir (__gettimeofday, __gettimeofday)
+#endif
 weak_alias (__gettimeofday, gettimeofday)
 libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/i386/gettimeofday.c b/sysdeps/unix/sysv/linux/i386/gettimeofday.c
deleted file mode 100644
index 185450ece6..0000000000
--- a/sysdeps/unix/sysv/linux/i386/gettimeofday.c
+++ /dev/null
@@ -1,35 +0,0 @@
-/* gettimeofday - get the time.  Linux/i386 version.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#ifdef SHARED
-# define __gettimeofday __redirect___gettimeofday
-#endif
-
-#include <sys/time.h>
-
-#ifdef SHARED
-# undef __gettimeofday
-# define __gettimeofday_type __redirect___gettimeofday
-
-# undef libc_hidden_def
-# define libc_hidden_def(name) \
-  __hidden_ver1 (__gettimeofday_syscall, __GI___gettimeofday, \
-	       __gettimeofday_syscall);
-#endif
-
-#include <sysdeps/unix/sysv/linux/x86/gettimeofday.c>
diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
index 4f79f25989..076e4393d3 100644
--- a/sysdeps/unix/sysv/linux/i386/sysdep.h
+++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
@@ -315,6 +315,7 @@ 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 USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 # define HAVE_TIME_VSYSCALL             "__vdso_time"
 # define USE_TIME_VSYSCALL_IFUNC	1
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
deleted file mode 100644
index e046594d40..0000000000
--- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c
+++ /dev/null
@@ -1,84 +0,0 @@
-/* Copyright (C) 2005-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
-   <http://www.gnu.org/licenses/>.  */
-
-#if defined SHARED && !defined __powerpc64__
-# define __gettimeofday __redirect___gettimeofday
-#else
-# define __redirect___gettimeofday __gettimeofday
-#endif
-
-#include <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <libc-vdso.h>
-# include <dl-machine.h>
-
-# ifndef __powerpc64__
-#  undef __gettimeofday
-
-int
-__gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_VSYSCALL (gettimeofday, 2, tv, tz);
-}
-
-/* __GI___gettimeofday is defined as hidden and for ppc32 it enables the
-   compiler make a local call (symbol@local) for internal GLIBC usage. It
-   means the PLT won't be used and the ifunc resolver will be called directly.
-   For ppc64 a call to a function in another translation unit might use a
-   different toc pointer thus disallowing direct branchess and making internal
-   ifuncs calls safe.  */
-#  undef libc_hidden_def
-#  define libc_hidden_def(name)					\
-  __hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday,	\
-	       __gettimeofday_vsyscall);
-
-# endif /* !__powerpc64__  */
-
-static int
-__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-
-# define INIT_ARCH() \
-  void *vdso_gettimeofday = get_vdso_symbol (HAVE_GETTIMEOFDAY_VSYSCALL)
-  
-/* If the vDSO is not available we fall back syscall.  */
-libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday,
-		   vdso_gettimeofday
-		   ? VDSO_IFUNC_RET (vdso_gettimeofday)
-		   : (void *) __gettimeofday_syscall);
-libc_hidden_def (__gettimeofday)
-
-#else
-
-# include <sysdep.h>
-# include <errno.h>
-
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-libc_hidden_def (__gettimeofday)
-
-#endif
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/powerpc/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
index 084b6525ca..743eb67557 100644
--- a/sysdeps/unix/sysv/linux/powerpc/sysdep.h
+++ b/sysdeps/unix/sysv/linux/powerpc/sysdep.h
@@ -26,6 +26,7 @@
 #define HAVE_TIME_VSYSCALL		"__kernel_time"
 #define USE_TIME_VSYSCALL_IFUNC		1
 #define HAVE_GETTIMEOFDAY_VSYSCALL	"__kernel_gettimeofday"
+#define USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 #define HAVE_GET_TBFREQ                 "__kernel_get_tbfreq"
 
 #if defined(__PPC64__) || defined(__powerpc64__)
diff --git a/sysdeps/unix/sysv/linux/x86/gettimeofday.c b/sysdeps/unix/sysv/linux/x86/gettimeofday.c
deleted file mode 100644
index 3ceab633e5..0000000000
--- a/sysdeps/unix/sysv/linux/x86/gettimeofday.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* gettimeofday - get the time.  Linux/x86 version.
-   Copyright (C) 2015-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
-   <http://www.gnu.org/licenses/>.  */
-
-#include <sys/time.h>
-
-#ifdef SHARED
-
-# include <dl-vdso.h>
-# include <errno.h>
-# include <sysdep-vdso.h>
-# include <sysdep-vdso.h>
-
-static int
-__gettimeofday_syscall (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-
-# ifndef __gettimeofday_type
-/* The i386 gettimeofday.c includes this file with a defined
-   __gettimeofday_type macro.  For x86_64 we have to define it to __gettimeofday
-   as the internal symbol is the ifunc'ed one.  */
-#  define __gettimeofday_type __gettimeofday
-# endif
-
-# define INIT_ARCH()
-
-/* If the vDSO is not available we fall back to syscall.  */
-libc_ifunc_hidden (__gettimeofday_type, __gettimeofday,
-		   (get_vdso_symbol ("__vdso_gettimeofday")
-		    ?: __gettimeofday_syscall));
-libc_hidden_def (__gettimeofday)
-
-#else
-
-# include <sysdep.h>
-# include <errno.h>
-
-int
-__gettimeofday (struct timeval *tv, struct timezone *tz)
-{
-  return INLINE_SYSCALL (gettimeofday, 2, tv, tz);
-}
-libc_hidden_def (__gettimeofday)
-
-#endif
-weak_alias (__gettimeofday, gettimeofday)
-libc_hidden_weak (gettimeofday)
diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
index c64fbd1e26..4ea9c4fa31 100644
--- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
+++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
@@ -376,6 +376,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 USE_GETTIMEOFDAY_VSYSCALL_IFUNC	1
 # define HAVE_TIME_VSYSCALL		"__vdso_time"
 # define USE_TIME_VSYSCALL_IFUNC	1
 # define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
-- 
2.17.1

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/12] s390: Enable VDSO for static linking
  2019-06-14 15:29 ` [PATCH 03/12] s390: Enable VDSO for static linking Adhemerval Zanella
@ 2019-08-02 12:34   ` Adhemerval Zanella
  2019-08-06 14:08     ` Stefan Liebler
  0 siblings, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2019-08-02 12:34 UTC (permalink / raw)
  To: libc-alpha

Ping.

On 14/06/2019 12:28, Adhemerval Zanella wrote:
> Although s390 explicit does not enable vDSO for binaries without
> (arch/s390/kernel/vdso.c:217), there is no indication in the code
> the rationale for disabling it.  In fact, I rebuilt a kernel with the
> check removed and the vDSO does work for static build for supplied
> symbols.
> 
> Checked on s390x-linux-gnu.
> 
> 	[BZ #19767]
> 	* sysdeps/unix/sysv/linux/s390/init-first.c: Remove #ifdef SHARED.
> 	* sysdeps/unix/sysv/linux/s390/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
> 	(ALWAYS_USE_VSYSCALL): Define.
> 	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
> 	(ALWAYS_USE_VSYSCALL): Likewise.
> ---
>  sysdeps/unix/sysv/linux/s390/init-first.c     | 8 ++------
>  sysdeps/unix/sysv/linux/s390/libc-vdso.h      | 3 ---
>  sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h | 3 +++
>  sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h | 4 ++++
>  4 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/s390/init-first.c b/sysdeps/unix/sysv/linux/s390/init-first.c
> index 71dd43f738..847977c0d9 100644
> --- a/sysdeps/unix/sysv/linux/s390/init-first.c
> +++ b/sysdeps/unix/sysv/linux/s390/init-first.c
> @@ -16,9 +16,8 @@
>     License along with the GNU C Library; if not, see
>     <http://www.gnu.org/licenses/>.  */
>  
> -#ifdef SHARED
> -# include <dl-vdso.h>
> -# include <libc-vdso.h>
> +#include <dl-vdso.h>
> +#include <libc-vdso.h>
>  
>  long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
>     attribute_hidden;
> @@ -54,7 +53,4 @@ _libc_vdso_platform_setup (void)
>    VDSO_SYMBOL (getcpu) = p;
>  }
>  
> -# define VDSO_SETUP _libc_vdso_platform_setup
> -#endif
> -
>  #include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/s390/libc-vdso.h b/sysdeps/unix/sysv/linux/s390/libc-vdso.h
> index 5e2d1e4b3f..cc97601383 100644
> --- a/sysdeps/unix/sysv/linux/s390/libc-vdso.h
> +++ b/sysdeps/unix/sysv/linux/s390/libc-vdso.h
> @@ -20,8 +20,6 @@
>  #ifndef _LIBC_VDSO_H
>  #define _LIBC_VDSO_H
>  
> -#ifdef SHARED
> -
>  #include <sysdep-vdso.h>
>  
>  extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
> @@ -33,6 +31,5 @@ extern long int (*VDSO_SYMBOL(clock_getres)) (clockid_t, struct timespec *);
>  
>  extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
>     attribute_hidden;
> -#endif
>  
>  #endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
> index 640fb52de1..47d1c5cdb2 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
> @@ -19,6 +19,9 @@
>  #ifndef _LINUX_S390_SYSDEP_H
>  #define _LINUX_S390_SYSDEP_H
>  
> +/* Always enable vsyscalls on s390-32.  */
> +#define ALWAYS_USE_VSYSCALL 1
> +
>  #include <sysdeps/s390/s390-32/sysdep.h>
>  #include <sysdeps/unix/sysdep.h>
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
> index 9a9834c750..95829390e2 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
> @@ -20,6 +20,10 @@
>  #ifndef _LINUX_S390_SYSDEP_H
>  #define _LINUX_S390_SYSDEP_H
>  
> +/* Always enable vsyscalls on s390-64.  */
> +#define ALWAYS_USE_VSYSCALL 1
> +
> +
>  #include <sysdeps/s390/s390-64/sysdep.h>
>  #include <sysdeps/unix/sysdep.h>
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/12] riscv: Enable VDSO for static linking
  2019-06-14 15:29 ` [PATCH 02/12] riscv: Enable VDSO for static linking Adhemerval Zanella
@ 2019-08-02 12:34   ` Adhemerval Zanella
  0 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-08-02 12:34 UTC (permalink / raw)
  To: libc-alpha

Ping.

On 14/06/2019 12:28, Adhemerval Zanella wrote:
> Checked on riscv64-linux-gnu-rv64imafdc-lp64d qemu system with
> some static tests.
> 
> 	[BZ #19767]
> 	* sysdeps/unix/sysv/linux/riscv/init-first.c: Remove #ifdef SHARED.
> 	* sysdeps/unix/sysv/linux/riscv/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/riscv/sysdep.h (ALWAYS_USE_VSYSCALL):
> 	Define.
> ---
>  sysdeps/unix/sysv/linux/riscv/init-first.c | 8 +++-----
>  sysdeps/unix/sysv/linux/riscv/libc-vdso.h  | 6 +-----
>  sysdeps/unix/sysv/linux/riscv/sysdep.h     | 3 +++
>  3 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/riscv/init-first.c b/sysdeps/unix/sysv/linux/riscv/init-first.c
> index 8134c79695..98a8ce33ad 100644
> --- a/sysdeps/unix/sysv/linux/riscv/init-first.c
> +++ b/sysdeps/unix/sysv/linux/riscv/init-first.c
> @@ -17,9 +17,8 @@
>     License along with the GNU C Library; if not, see
>     <http://www.gnu.org/licenses/>.  */
>  
> -#ifdef SHARED
> -# include <dl-vdso.h>
> -# include <libc-vdso.h>
> +#include <dl-vdso.h>
> +#include <libc-vdso.h>
>  
>  long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
>      attribute_hidden;
> @@ -52,7 +51,6 @@ _libc_vdso_platform_setup (void)
>    VDSO_SYMBOL (clock_getres) = p;
>  }
>  
> -# define VDSO_SETUP _libc_vdso_platform_setup
> -#endif
> +#define VDSO_SETUP _libc_vdso_platform_setup
>  
>  #include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h b/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
> index b0c46f3cb7..2373292ab9 100644
> --- a/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
> +++ b/sysdeps/unix/sysv/linux/riscv/libc-vdso.h
> @@ -20,9 +20,7 @@
>  #ifndef _LIBC_VDSO_H
>  #define _LIBC_VDSO_H
>  
> -#ifdef SHARED
> -
> -# include <sysdep-vdso.h>
> +#include <sysdep-vdso.h>
>  
>  extern long int (*VDSO_SYMBOL (getcpu)) (unsigned int *, unsigned int *, void *)
>      attribute_hidden;
> @@ -33,6 +31,4 @@ extern long int (*VDSO_SYMBOL (clock_gettime)) (clockid_t, struct timespec *)
>  extern long int (*VDSO_SYMBOL (clock_getres)) (clockid_t, struct timespec *)
>      attribute_hidden;
>  
> -#endif
> -
>  #endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
> index 5470ea3d2a..caf013a9a1 100644
> --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
> @@ -19,6 +19,9 @@
>  #ifndef _LINUX_RISCV_SYSDEP_H
>  #define _LINUX_RISCV_SYSDEP_H 1
>  
> +/* Always enable vsyscalls on riscv */
> +#define ALWAYS_USE_VSYSCALL 1
> +
>  #include <sysdeps/unix/sysv/linux/generic/sysdep.h>
>  #include <tls.h>
>  
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 04/12] sparc: Enable VDSO for static linking
  2019-06-14 15:30 ` [PATCH 04/12] sparc: Enable VDSO for static linking Adhemerval Zanella
@ 2019-08-02 12:34   ` Adhemerval Zanella
  0 siblings, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-08-02 12:34 UTC (permalink / raw)
  To: libc-alpha

Ping.

On 14/06/2019 12:29, Adhemerval Zanella wrote:
> Checked on sparc64-linux-gnu and sparcv9-linux-gnu.
> 
> 	[BZ #19767]
> 	* sysdeps/unix/sysv/linux/sparc/init-first.c: Remove #ifdef SHARED.
> 	* sysdeps/unix/sysv/linux/sparc/libc-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/sparc/sysdep.h (ALWAYS_USE_VSYSCALL):
> 	Define.
> ---
>  sysdeps/unix/sysv/linux/sparc/init-first.c | 8 +++-----
>  sysdeps/unix/sysv/linux/sparc/libc-vdso.h  | 6 +-----
>  sysdeps/unix/sysv/linux/sparc/sysdep.h     | 3 +++
>  3 files changed, 7 insertions(+), 10 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/sparc/init-first.c b/sysdeps/unix/sysv/linux/sparc/init-first.c
> index de83321713..643d6c7c88 100644
> --- a/sysdeps/unix/sysv/linux/sparc/init-first.c
> +++ b/sysdeps/unix/sysv/linux/sparc/init-first.c
> @@ -17,9 +17,8 @@
>     License along with the GNU C Library; if not, see
>     <http://www.gnu.org/licenses/>.  */
>  
> -#ifdef SHARED
> -# include <dl-vdso.h>
> -# include <libc-vdso.h>
> +#include <dl-vdso.h>
> +#include <libc-vdso.h>
>  
>  long int (*VDSO_SYMBOL (gettimeofday)) (struct timeval *, void *)
>      attribute_hidden;
> @@ -40,7 +39,6 @@ _libc_vdso_platform_setup (void)
>    VDSO_SYMBOL (clock_gettime) = p;
>  }
>  
> -# define VDSO_SETUP _libc_vdso_platform_setup
> -#endif
> +#define VDSO_SETUP _libc_vdso_platform_setup
>  
>  #include <csu/init-first.c>
> diff --git a/sysdeps/unix/sysv/linux/sparc/libc-vdso.h b/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
> index 4009b00a28..d20afcdf04 100644
> --- a/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
> +++ b/sysdeps/unix/sysv/linux/sparc/libc-vdso.h
> @@ -20,14 +20,10 @@
>  #ifndef _LIBC_VDSO_H
>  #define _LIBC_VDSO_H
>  
> -#ifdef SHARED
> -
> -# include <sysdep-vdso.h>
> +#include <sysdep-vdso.h>
>  
>  extern long int (*VDSO_SYMBOL(gettimeofday)) (struct timeval *, void *)
>     attribute_hidden;
>  extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *);
>  
> -#endif
> -
>  #endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
> index 981b2a26b7..fc4053c5ce 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
> @@ -19,6 +19,9 @@
>  #ifndef _LINUX_SPARC_SYSDEP_H
>  #define _LINUX_SPARC_SYSDEP_H 1
>  
> +/* Always enable vsyscalls on sparc */
> +#define ALWAYS_USE_VSYSCALL 1
> +
>  #include <sysdeps/unix/sysdep.h>
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>  #include <sysdeps/sparc/sysdep.h>
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/12] linux: Enable vDSO for static linking as default (BZ#19767)
  2019-06-14 15:29 ` [PATCH 05/12] linux: Enable vDSO for static linking as default (BZ#19767) Adhemerval Zanella
  2019-06-17 19:57   ` Tulio Magno Quites Machado Filho
@ 2019-08-02 12:34   ` Adhemerval Zanella
  2019-08-05 11:09     ` Florian Weimer
  1 sibling, 1 reply; 33+ messages in thread
From: Adhemerval Zanella @ 2019-08-02 12:34 UTC (permalink / raw)
  To: libc-alpha

Ping.

On 14/06/2019 12:29, Adhemerval Zanella wrote:
> This patch assumes static vDSO is supported as default, it is now supported
> on all current architectures that support vDSO.  It allows removing both
> ALWAYS_USE_VSYSCALL define, which an architecture requires to explicit define
> and USE_VSYSCALL (which defines vDSO only for shared or if architecture defines
> ALWAYS_USE_VSYSCALL).
> 
> Checked with a build against all affected ABIs.
> 
> 	[BZ #19767]
> 	* sysdeps/unix/sysv/linux/aarch64/sysdep.h (ALWAYS_USE_VSYSCALL):
> 	Remove definition.
> 	* sysdeps/unix/sysv/linux/arm/sysdep.h (ALWAYS_USE_VSYSCALL):
> 	Likewise.
> 	* sysdeps/unix/sysv/linux/i386/sysdep.h (ALWAYS_USE_VSYSCALL):
> 	Likewise.
> 	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h (ALWAYS_USE_VSYSCALL):
> 	Likewise.
> 	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
> 	(ALWAYS_USE_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
> 	(ALWAYS_USE_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
> 	(ALWAYS_USE_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
> 	(ALWAYS_USE_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/riscv/sysdep.h (ALWAYS_USE_VSYSCALL):
> 	Likewise.
> 	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
> 	(ALWAYS_USE_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
> 	(ALWAYS_USE_VSYSCALL): Likewise.
> 	* sysdeps/unix/sysv/linux/sparc/sysdep.h (ALWAYS_USE_VSYSCALL):
> 	Likewise.
> 	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (ALWAYS_USE_VSYSCALL):
> 	Likewise.
> 	* sysdeps/unix/sysv/linux/x86/libc-vdso.h: Remove #if USE_VSYSCALL.
> 	* sysdeps/unix/sysv/linux/sysdep-vdso.h: Likewise.
> 	* sysdeps/unix/sysv/linux/sysdep.h (ALWAYS_USE_VSYSCALL,
> 	USE_VSYSCALL): Remove defitions.
> ---
>  sysdeps/unix/sysv/linux/aarch64/sysdep.h           | 3 ---
>  sysdeps/unix/sysv/linux/arm/sysdep.h               | 3 ---
>  sysdeps/unix/sysv/linux/i386/sysdep.h              | 3 ---
>  sysdeps/unix/sysv/linux/mips/mips32/sysdep.h       | 3 ---
>  sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h   | 3 ---
>  sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h   | 3 ---
>  sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h | 3 ---
>  sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h | 3 ---
>  sysdeps/unix/sysv/linux/riscv/sysdep.h             | 3 ---
>  sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h      | 3 ---
>  sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h      | 4 ----
>  sysdeps/unix/sysv/linux/sparc/sysdep.h             | 3 ---
>  sysdeps/unix/sysv/linux/sysdep-vdso.h              | 2 +-
>  sysdeps/unix/sysv/linux/sysdep.h                   | 7 -------
>  sysdeps/unix/sysv/linux/x86/libc-vdso.h            | 6 +-----
>  sysdeps/unix/sysv/linux/x86_64/sysdep.h            | 3 ---
>  16 files changed, 2 insertions(+), 53 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> index 935c507f8c..a2f4061b58 100644
> --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h
> @@ -19,9 +19,6 @@
>  #ifndef _LINUX_AARCH64_SYSDEP_H
>  #define _LINUX_AARCH64_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on aarch64 */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  #include <sysdeps/unix/sysdep.h>
>  #include <sysdeps/aarch64/sysdep.h>
>  #include <sysdeps/unix/sysv/linux/generic/sysdep.h>
> diff --git a/sysdeps/unix/sysv/linux/arm/sysdep.h b/sysdeps/unix/sysv/linux/arm/sysdep.h
> index 9b4ed8d6a5..6d8d9a47f9 100644
> --- a/sysdeps/unix/sysv/linux/arm/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/arm/sysdep.h
> @@ -20,9 +20,6 @@
>  #ifndef _LINUX_ARM_SYSDEP_H
>  #define _LINUX_ARM_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on arm */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  /* There is some commonality.  */
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>  #include <sysdeps/unix/arm/sysdep.h>
> diff --git a/sysdeps/unix/sysv/linux/i386/sysdep.h b/sysdeps/unix/sysv/linux/i386/sysdep.h
> index 0be10744ff..77154b904a 100644
> --- a/sysdeps/unix/sysv/linux/i386/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/i386/sysdep.h
> @@ -19,9 +19,6 @@
>  #ifndef _LINUX_I386_SYSDEP_H
>  #define _LINUX_I386_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on i386 */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  /* There is some commonality.  */
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>  #include <sysdeps/unix/i386/sysdep.h>
> diff --git a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> index 5a2704e3e8..a310a0acbc 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/mips/mips32/sysdep.h
> @@ -18,9 +18,6 @@
>  #ifndef _LINUX_MIPS_MIPS32_SYSDEP_H
>  #define _LINUX_MIPS_MIPS32_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on mips32.  */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  /* There is some commonality.  */
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>  #include <sysdeps/unix/mips/mips32/sysdep.h>
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
> index a4f3547030..d83e08f96a 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
> @@ -18,9 +18,6 @@
>  #ifndef _LINUX_MIPS_SYSDEP_H
>  #define _LINUX_MIPS_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on n32.  */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  /* There is some commonality.  */
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>  #include <sysdeps/unix/mips/mips64/n32/sysdep.h>
> diff --git a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
> index 5b4d27757d..bcfaf561a1 100644
> --- a/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
> @@ -18,9 +18,6 @@
>  #ifndef _LINUX_MIPS_SYSDEP_H
>  #define _LINUX_MIPS_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on n64.  */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  /* There is some commonality.  */
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>  #include <sysdeps/unix/mips/mips64/n64/sysdep.h>
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
> index bdbab8e41b..62caa265d7 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
> @@ -18,9 +18,6 @@
>  #ifndef _LINUX_POWERPC_SYSDEP_H
>  #define _LINUX_POWERPC_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on powerpc32 */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>  #include <sysdeps/unix/powerpc/sysdep.h>
>  #include <tls.h>
> diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
> index 294517e3f3..4122e5c4a9 100644
> --- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
> @@ -20,9 +20,6 @@
>  #ifndef _LINUX_POWERPC_SYSDEP_H
>  #define _LINUX_POWERPC_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on powerpc64 */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>  #include <sysdeps/unix/powerpc/sysdep.h>
>  #include <tls.h>
> diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
> index caf013a9a1..5470ea3d2a 100644
> --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
> @@ -19,9 +19,6 @@
>  #ifndef _LINUX_RISCV_SYSDEP_H
>  #define _LINUX_RISCV_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on riscv */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  #include <sysdeps/unix/sysv/linux/generic/sysdep.h>
>  #include <tls.h>
>  
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
> index 47d1c5cdb2..640fb52de1 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
> @@ -19,9 +19,6 @@
>  #ifndef _LINUX_S390_SYSDEP_H
>  #define _LINUX_S390_SYSDEP_H
>  
> -/* Always enable vsyscalls on s390-32.  */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  #include <sysdeps/s390/s390-32/sysdep.h>
>  #include <sysdeps/unix/sysdep.h>
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
> diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
> index 95829390e2..9a9834c750 100644
> --- a/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
> @@ -20,10 +20,6 @@
>  #ifndef _LINUX_S390_SYSDEP_H
>  #define _LINUX_S390_SYSDEP_H
>  
> -/* Always enable vsyscalls on s390-64.  */
> -#define ALWAYS_USE_VSYSCALL 1
> -
> -
>  #include <sysdeps/s390/s390-64/sysdep.h>
>  #include <sysdeps/unix/sysdep.h>
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
> diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h
> index fc4053c5ce..981b2a26b7 100644
> --- a/sysdeps/unix/sysv/linux/sparc/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h
> @@ -19,9 +19,6 @@
>  #ifndef _LINUX_SPARC_SYSDEP_H
>  #define _LINUX_SPARC_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on sparc */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  #include <sysdeps/unix/sysdep.h>
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>  #include <sysdeps/sparc/sysdep.h>
> diff --git a/sysdeps/unix/sysv/linux/sysdep-vdso.h b/sysdeps/unix/sysv/linux/sysdep-vdso.h
> index c5a1ae0670..5fec208380 100644
> --- a/sysdeps/unix/sysv/linux/sysdep-vdso.h
> +++ b/sysdeps/unix/sysv/linux/sysdep-vdso.h
> @@ -26,7 +26,7 @@
>       funcptr (args)
>  #endif
>  
> -#if USE_VSYSCALL && defined HAVE_VSYSCALL
> +#ifdef HAVE_VSYSCALL
>  
>  # include <libc-vdso.h>
>  
> diff --git a/sysdeps/unix/sysv/linux/sysdep.h b/sysdeps/unix/sysv/linux/sysdep.h
> index f94cfa2fa9..af1c9a26fe 100644
> --- a/sysdeps/unix/sysv/linux/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/sysdep.h
> @@ -18,13 +18,6 @@
>  #include <bits/wordsize.h>
>  #include <kernel-features.h>
>  
> -/* By default only shared builds use vdso. */
> -#ifndef ALWAYS_USE_VSYSCALL
> -#define ALWAYS_USE_VSYSCALL 0
> -#endif
> -
> -#define USE_VSYSCALL (defined (SHARED) || ALWAYS_USE_VSYSCALL)
> -
>  /* Set error number and return -1.  A target may choose to return the
>     internal function, __syscall_error, which sets errno and returns -1.
>     We use -1l, instead of -1, so that it can be casted to (void *).  */
> diff --git a/sysdeps/unix/sysv/linux/x86/libc-vdso.h b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
> index ea35c71664..c9aa1c8a72 100644
> --- a/sysdeps/unix/sysv/linux/x86/libc-vdso.h
> +++ b/sysdeps/unix/sysv/linux/x86/libc-vdso.h
> @@ -22,9 +22,7 @@
>  #include <time.h>
>  #include <sys/time.h>
>  
> -#if USE_VSYSCALL
> -
> -# include <sysdep-vdso.h>
> +#include <sysdep-vdso.h>
>  
>  extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
>    attribute_hidden;
> @@ -32,6 +30,4 @@ extern long int (*VDSO_SYMBOL(clock_gettime)) (clockid_t, struct timespec *)
>  extern long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *)
>    attribute_hidden;
>  
> -#endif
> -
>  #endif /* _LIBC_VDSO_H */
> diff --git a/sysdeps/unix/sysv/linux/x86_64/sysdep.h b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
> index b88c46b589..0a3ddd37e1 100644
> --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
> @@ -18,9 +18,6 @@
>  #ifndef _LINUX_X86_64_SYSDEP_H
>  #define _LINUX_X86_64_SYSDEP_H 1
>  
> -/* Always enable vsyscalls on x86_64 */
> -#define ALWAYS_USE_VSYSCALL 1
> -
>  /* There is some commonality.  */
>  #include <sysdeps/unix/sysv/linux/sysdep.h>
>  #include <sysdeps/unix/x86_64/sysdep.h>
> 

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/12] linux: Enable vDSO for static linking as default (BZ#19767)
  2019-08-02 12:34   ` Adhemerval Zanella
@ 2019-08-05 11:09     ` Florian Weimer
  0 siblings, 0 replies; 33+ messages in thread
From: Florian Weimer @ 2019-08-05 11:09 UTC (permalink / raw)
  To: Adhemerval Zanella; +Cc: libc-alpha

* Adhemerval Zanella:

> Ping.
>
> On 14/06/2019 12:29, Adhemerval Zanella wrote:
>> This patch assumes static vDSO is supported as default, it is now supported
>> on all current architectures that support vDSO.  It allows removing both
>> ALWAYS_USE_VSYSCALL define, which an architecture requires to explicit define
>> and USE_VSYSCALL (which defines vDSO only for shared or if architecture defines
>> ALWAYS_USE_VSYSCALL).
>> 
>> Checked with a build against all affected ABIs.
>> 
>> 	[BZ #19767]
>> 	* sysdeps/unix/sysv/linux/aarch64/sysdep.h (ALWAYS_USE_VSYSCALL):
>> 	Remove definition.
>> 	* sysdeps/unix/sysv/linux/arm/sysdep.h (ALWAYS_USE_VSYSCALL):
>> 	Likewise.
>> 	* sysdeps/unix/sysv/linux/i386/sysdep.h (ALWAYS_USE_VSYSCALL):
>> 	Likewise.
>> 	* sysdeps/unix/sysv/linux/mips/mips32/sysdep.h (ALWAYS_USE_VSYSCALL):
>> 	Likewise.
>> 	* sysdeps/unix/sysv/linux/mips/mips64/n32/sysdep.h
>> 	(ALWAYS_USE_VSYSCALL): Likewise.
>> 	* sysdeps/unix/sysv/linux/mips/mips64/n64/sysdep.h
>> 	(ALWAYS_USE_VSYSCALL): Likewise.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc32/sysdep.h
>> 	(ALWAYS_USE_VSYSCALL): Likewise.
>> 	* sysdeps/unix/sysv/linux/powerpc/powerpc64/sysdep.h
>> 	(ALWAYS_USE_VSYSCALL): Likewise.
>> 	* sysdeps/unix/sysv/linux/riscv/sysdep.h (ALWAYS_USE_VSYSCALL):
>> 	Likewise.
>> 	* sysdeps/unix/sysv/linux/s390/s390-32/sysdep.h
>> 	(ALWAYS_USE_VSYSCALL): Likewise.
>> 	* sysdeps/unix/sysv/linux/s390/s390-64/sysdep.h
>> 	(ALWAYS_USE_VSYSCALL): Likewise.
>> 	* sysdeps/unix/sysv/linux/sparc/sysdep.h (ALWAYS_USE_VSYSCALL):
>> 	Likewise.
>> 	* sysdeps/unix/sysv/linux/x86_64/sysdep.h (ALWAYS_USE_VSYSCALL):
>> 	Likewise.
>> 	* sysdeps/unix/sysv/linux/x86/libc-vdso.h: Remove #if USE_VSYSCALL.
>> 	* sysdeps/unix/sysv/linux/sysdep-vdso.h: Likewise.
>> 	* sysdeps/unix/sysv/linux/sysdep.h (ALWAYS_USE_VSYSCALL,
>> 	USE_VSYSCALL): Remove defitions.

I think Tulio has already reviewed this patch.  It looks okay to me too.

Thanks,
Florian

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/12] s390: Enable VDSO for static linking
  2019-08-02 12:34   ` Adhemerval Zanella
@ 2019-08-06 14:08     ` Stefan Liebler
  2019-08-06 15:19       ` Adhemerval Zanella
  2019-08-07  6:57       ` Heiko Carstens
  0 siblings, 2 replies; 33+ messages in thread
From: Stefan Liebler @ 2019-08-06 14:08 UTC (permalink / raw)
  To: libc-alpha; +Cc: Heiko Carstens

[-- Attachment #1: Type: text/plain, Size: 1715 bytes --]

On 8/2/19 2:34 PM, Adhemerval Zanella wrote:
> Ping.
> 
> On 14/06/2019 12:28, Adhemerval Zanella wrote:
>> Although s390 explicit does not enable vDSO for binaries without
>> (arch/s390/kernel/vdso.c:217), there is no indication in the code
>> the rationale for disabling it.  In fact, I rebuilt a kernel with the
>> check removed and the vDSO does work for static build for supplied
>> symbols.

Hi Adhemerval,

Sorry, I haven't recognized this patch as it was hidden behind the 
email-thread starting with "[PATCH 01/12] m68k: Remove vDSO support". 
Please cc me if I'm not responding for s390 patches.

I've just had a look into the kernel arch/s390/kernel/vdso.c file
and I'm a little bit confused regarding the line number 217 (see my 
excerpt below).
Just to be sure, have you removed the "if (!uses_interp)" or the "if 
(!vdso_enabled)"?

/*
  * This is called from binfmt_elf, we create the special vma for the
  * vDSO and insert it into the mm struct tree
  */
int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
{
	struct mm_struct *mm = current->mm;
	struct vm_area_struct *vma;
	unsigned long vdso_pages;
	unsigned long vdso_base;
	int rc;

217:	if (!vdso_enabled)
		return 0;
	/*
	 * Only map the vdso for dynamically linked elf binaries.
	 */
222:	if (!uses_interp)
		return 0;


As far as I know, vdso was disabled for statically linked binaries as 
glibc had not supported it and thus nothing "useless" was mapped 
(especially on 31bit).
I've also cc'ed Heiko. Perhaps he can also enable it on s390 for 
statically linked binaries.

Nevertheless this patch breaks s390. I've just committed the attached 
fix which adds the removed VDSO_SETUP macro definition.

Bye.
Stefan

[-- Attachment #2: 20190806_1425_vdso_fix.patch --]
[-- Type: text/x-patch, Size: 980 bytes --]

commit cf6ac72fdd2026e91c0672ccf0eefd2e58920bdc
Author: Stefan Liebler <stli@linux.ibm.com>
Date:   Tue Aug 6 14:15:09 2019 +0200

    s390: Fix Enable VDSO for static linking
    
    The commit 5e855c8954014bca7b0d6f07312ec09553695ffd
    "s390: Enable VDSO for static linking" removed the definition of VDSO_SETUP
    which leads to not setup the vdso symbols.
    Instead it jumps to false addresses.
    
    This patch just re adds the removed VDSO_SETUP macro definition.
    
    ChangeLog:
    
            * sysdeps/unix/sysv/linux/s390/init-first.c (VDSO_SETUP): New define.

diff --git a/sysdeps/unix/sysv/linux/s390/init-first.c b/sysdeps/unix/sysv/linux/s390/init-first.c
index 8c54d13935..a1ad9458e3 100644
--- a/sysdeps/unix/sysv/linux/s390/init-first.c
+++ b/sysdeps/unix/sysv/linux/s390/init-first.c
@@ -53,4 +53,6 @@ _libc_vdso_platform_setup (void)
   VDSO_SYMBOL (getcpu) = p;
 }
 
+#define VDSO_SETUP _libc_vdso_platform_setup
+
 #include <csu/init-first.c>

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/12] s390: Enable VDSO for static linking
  2019-08-06 14:08     ` Stefan Liebler
@ 2019-08-06 15:19       ` Adhemerval Zanella
  2019-08-07  6:57       ` Heiko Carstens
  1 sibling, 0 replies; 33+ messages in thread
From: Adhemerval Zanella @ 2019-08-06 15:19 UTC (permalink / raw)
  To: libc-alpha



On 06/08/2019 11:08, Stefan Liebler wrote:
> On 8/2/19 2:34 PM, Adhemerval Zanella wrote:
>> Ping.
>>
>> On 14/06/2019 12:28, Adhemerval Zanella wrote:
>>> Although s390 explicit does not enable vDSO for binaries without
>>> (arch/s390/kernel/vdso.c:217), there is no indication in the code
>>> the rationale for disabling it.  In fact, I rebuilt a kernel with the
>>> check removed and the vDSO does work for static build for supplied
>>> symbols.
> 
> Hi Adhemerval,
> 
> Sorry, I haven't recognized this patch as it was hidden behind the email-thread starting with "[PATCH 01/12] m68k: Remove vDSO support". Please cc me if I'm not responding for s390 patches.
> 
> I've just had a look into the kernel arch/s390/kernel/vdso.c file
> and I'm a little bit confused regarding the line number 217 (see my excerpt below).
> Just to be sure, have you removed the "if (!uses_interp)" or the "if (!vdso_enabled)"?
> 
> /*
>  * This is called from binfmt_elf, we create the special vma for the
>  * vDSO and insert it into the mm struct tree
>  */
> int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
> {
>     struct mm_struct *mm = current->mm;
>     struct vm_area_struct *vma;
>     unsigned long vdso_pages;
>     unsigned long vdso_base;
>     int rc;
> 
> 217:    if (!vdso_enabled)
>         return 0;
>     /*
>      * Only map the vdso for dynamically linked elf binaries.
>      */
> 222:    if (!uses_interp)
>         return 0;

In fact it was the !uses_interp that I commented out to enable the vDSO page on
the system emulated environment I used.

> 
> 
> As far as I know, vdso was disabled for statically linked binaries as glibc had not supported it and thus nothing "useless" was mapped (especially on 31bit).
> I've also cc'ed Heiko. Perhaps he can also enable it on s390 for statically linked binaries.

Yeah, I noted that s390 is an outlier here where all the other architectures do
map the vDSO even for statically linked binaries. Thanks for checking on it.

> 
> Nevertheless this patch breaks s390. I've just committed the attached fix which adds the removed VDSO_SETUP macro definition.

Sigh, this line was removed with a cherry-pick, sorry about that.

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 03/12] s390: Enable VDSO for static linking
  2019-08-06 14:08     ` Stefan Liebler
  2019-08-06 15:19       ` Adhemerval Zanella
@ 2019-08-07  6:57       ` Heiko Carstens
  1 sibling, 0 replies; 33+ messages in thread
From: Heiko Carstens @ 2019-08-07  6:57 UTC (permalink / raw)
  To: Stefan Liebler; +Cc: libc-alpha

On Tue, Aug 06, 2019 at 04:08:02PM +0200, Stefan Liebler wrote:
> int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
> {
> 	struct mm_struct *mm = current->mm;
> 	struct vm_area_struct *vma;
> 	unsigned long vdso_pages;
> 	unsigned long vdso_base;
> 	int rc;
> 
> 217:	if (!vdso_enabled)
> 		return 0;
> 	/*
> 	 * Only map the vdso for dynamically linked elf binaries.
> 	 */
> 222:	if (!uses_interp)
> 		return 0;
> 
> 
> As far as I know, vdso was disabled for statically linked binaries as glibc
> had not supported it and thus nothing "useless" was mapped (especially on
> 31bit).
> I've also cc'ed Heiko. Perhaps he can also enable it on s390 for statically
> linked binaries.

That was introduced in the kernel with

commit fc5243d98ac2575ad14a974b3c097e9ba874c03d
Author: Martin Schwidefsky <schwidefsky@de.ibm.com>
Date:   Thu Dec 25 13:38:35 2008 +0100

    [S390] arch_setup_additional_pages arguments

    arch_setup_additional_pages currently gets two arguments, the binary
    format descripton and an indication if the process uses an executable
    stack or not. The second argument is not used by anybody, it could
    be removed without replacement.

    What actually does make sense is to pass an indication if the process
    uses the elf interpreter or not. The glibc code will not use anything
    from the vdso if the process does not use the dynamic linker, so for
    statically linked binaries the architecture backend can choose not
    to map the vdso.

    Acked-by: Ingo Molnar <mingo@elte.hu>
    Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

And as it looks like only s390 ever made use of this optimization,
which now isn't an optimization anymore. So this can simply be
removed.

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2019-08-07  6:57 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-14 15:29 [PATCH 01/12] m68k: Remove vDSO support Adhemerval Zanella
2019-06-14 15:29 ` [PATCH 07/12] Refactor vDSO initialization code Adhemerval Zanella
2019-06-14 15:29 ` [PATCH 12/12] linux: Consolidate gettimeofday implementation Adhemerval Zanella
2019-07-08 20:47   ` Adhemerval Zanella
2019-06-14 15:29 ` [PATCH 09/12] mips: Consolidate INTERNAL_VSYSCALL_CALL Adhemerval Zanella
2019-06-14 15:29 ` [PATCH 02/12] riscv: Enable VDSO for static linking Adhemerval Zanella
2019-08-02 12:34   ` Adhemerval Zanella
2019-06-14 15:29 ` [PATCH 05/12] linux: Enable vDSO for static linking as default (BZ#19767) Adhemerval Zanella
2019-06-17 19:57   ` Tulio Magno Quites Machado Filho
2019-08-02 12:34   ` Adhemerval Zanella
2019-08-05 11:09     ` Florian Weimer
2019-06-14 15:29 ` [PATCH 08/12] powerpc: Refactor vsyscall internal macros Adhemerval Zanella
2019-06-17 21:49   ` Tulio Magno Quites Machado Filho
2019-06-18 17:31     ` Adhemerval Zanella
2019-06-28 22:01       ` Tulio Magno Quites Machado Filho
2019-06-14 15:29 ` [PATCH 03/12] s390: Enable VDSO for static linking Adhemerval Zanella
2019-08-02 12:34   ` Adhemerval Zanella
2019-08-06 14:08     ` Stefan Liebler
2019-08-06 15:19       ` Adhemerval Zanella
2019-08-07  6:57       ` Heiko Carstens
2019-06-14 15:29 ` [PATCH 11/12] linux: Consolidate time implementation Adhemerval Zanella
2019-06-25 18:24   ` Florian Weimer
2019-06-25 19:47     ` Adhemerval Zanella
2019-06-26 13:03       ` Florian Weimer
2019-06-28 22:45   ` Tulio Magno Quites Machado Filho
2019-07-01 21:00     ` Adhemerval Zanella
2019-07-08 20:47   ` Adhemerval Zanella
2019-06-14 15:29 ` [PATCH 10/12] sparc64: Use linux generic " Adhemerval Zanella
2019-06-14 15:29 ` [PATCH 06/12] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Adhemerval Zanella
2019-06-17 20:26   ` Tulio Magno Quites Machado Filho
2019-06-14 15:30 ` [PATCH 04/12] sparc: Enable VDSO for static linking Adhemerval Zanella
2019-08-02 12:34   ` Adhemerval Zanella
2019-06-14 16:12 ` [PATCH 01/12] m68k: Remove vDSO support Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).