From patchwork Thu Sep 5 20:56:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 173178 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1237737ilq; Thu, 5 Sep 2019 13:56:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqz238/DorhdUow0idPq0NeVNqwIfgyBrldxkTOLvjZJJIw42D3QUK3k/dzO0+pRZeAsTtQ/ X-Received: by 2002:a65:50c8:: with SMTP id s8mr4932121pgp.339.1567717004722; Thu, 05 Sep 2019 13:56:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567717004; cv=none; d=google.com; s=arc-20160816; b=LFOd+zo/36RkcoVE9AXUspYcyWM5jfB7wYLYZznzzzSz1Afyv5XzXxO8deaOl1aolu SDe19LN0uij1WeM8FgjfLzeCe9/L6n4HMtK/tRNXVAnozZ79eGqd5ECN/Ez1uUeuj1Au 8PniCyG1c0mrjXL7gDVthkXO5GKqWwrsYavcJkEmvg3cg5abmd/XgATM6/FTagpL0wiD tKlzZxi9mKu/jfjZ1fJao6OuxBukNBoZS0FbQRoSASPrTLhFGJHdlzUh4duIuto9pKUV n5aOIG5lWDS/dtE2RPbo3UY8lEPMRBmDv/rVLVHQpMYAEFN2feNy/TnhLLCDuJbIZ34v 4TcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:dkim-signature:delivered-to:sender :list-help:list-post:list-archive:list-subscribe:list-unsubscribe :list-id:precedence:mailing-list:dkim-signature:domainkey-signature; bh=8uQvuZYeByzIBKvmR1ODMtf8YKFI8Ns4Sq2oLvKwtEI=; b=A4eQChR249CIyY/AQl4st2f7WOMpRSInvTb/itt5uNtquyadRXj0FCUAT7eDz2myLf 2QUSCVaTp4qvGkesQvxFBCs7ZWVaH66fI+rfYDqB4HmoJpf3r9cQwEGF6SKBrxrLVWjW YxWd4gwgSjtRtumjPvmdIRMLv3xwk9P6AlTS4two3GWoq7f1/wRcLBf+ZsmO+DoYn05q fV5H3Yk4p7dlSfF49l/Lsys+4j7ejxiJlmukn+KQUoCiz73BDDifVm9wAk6PfD5nAK4L a11wafUOBndjGOzSBR3DMGVHdvjx2e8/TMziX0FOMDwFgewXx/mRqISXZcQiQge+xPkV k0YQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="OKg8/X20"; dkim=pass header.i=@linaro.org header.s=google header.b=PV5l0yWt; spf=pass (google.com: domain of libc-alpha-return-105063-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105063-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id n16si3516835pfq.233.2019.09.05.13.56.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Sep 2019 13:56:44 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105063-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="OKg8/X20"; dkim=pass header.i=@linaro.org header.s=google header.b=PV5l0yWt; spf=pass (google.com: domain of libc-alpha-return-105063-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105063-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; q=dns; s= default; b=IUI4PfV31FdbTlID8qy/zjDGp04zYmEn/qsx+MNeu4a7ro7/7z4RV m/HpH8S5m3GjHdWJFAME8mFOB0lmCfiiQIeAz3ebd2cGz1p7rsQ9uX9G4M83s3a3 WqDPq+W5RI73vcZdtiHzB84bOXyGKgR0t5UG72JksZQlI5PUUSoO0M= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id; s=default; bh=oRZJBGn6yZx6+gkyIl+/PRahUbY=; b=OKg8/X20HzR1cGONP8mJpO6iMlaM w/EE/TD8EY5JLYAwLJl2VbybZ8WjNVvTH02ROmZsrbSKCRRjaAm1hIMhhfp3zJ5w a+23SrXygviEvfmGZFDe1kk9NLRWODHmvc3NkvWq22blBkloar6omxbpG/r5qb5m 4Ta/bAFPrejmacs= Received: (qmail 116523 invoked by alias); 5 Sep 2019 20:56:32 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116513 invoked by uid 89); 5 Sep 2019 20:56:32 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*MI:4646, HX-Spam-Relays-External:209.85.222.194, H*RU:209.85.222.194 X-HELO: mail-qk1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=8uQvuZYeByzIBKvmR1ODMtf8YKFI8Ns4Sq2oLvKwtEI=; b=PV5l0yWtz0I7bk/LIiV1INFQ3yuVAm3u4uOzSoSogu22VwkrA/525F/uzmXUihLe/w gnRllBn47AsvATrp/7gX/ysI2LZXnUbDvdzlgpDOtJD66/Kik7NEk1NoIAljK+3C3W8q 1nQRkmM/9Y+DYHmT3Pd7vLQt9NEE19gARmafAdUGmLWRym2P2Db/VDyWTC1XL/hQuBqT d0ofEk3pp3uGKP7m6hW+3Tzwm3hh7MC0ozn7OF62kOGf0yRXc8HNhismViCAYvsVyd8p CyEOcW9TzhUrK2R5ZDhvz7ie/6F/AcqkXLMpdubzmNyNwA6sYG8mnZ5qBff8j5vMVTu+ NzNQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 1/8] Remove PREPARE_VERSION and PREPARE_VERSION_KNOW Date: Thu, 5 Sep 2019 17:56:13 -0300 Message-Id: <20190905205620.4646-1-adhemerval.zanella@linaro.org> Changes from previous version: - Remove trailing whitespaces. -- This patch removes the PREPARE_VERSION and PREPARE_VERSION_KNOW macro and uses a static inline function instead, get_vdso_symbol. Each architecture that supports vDSO must define the Linux version and its 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 | 27 ++++--------- 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 | 38 ++++--------------- 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 | 7 ++-- 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 | 5 +-- 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, 168 insertions(+), 158 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 -- 2.17.1 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 '; \\ 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 9180b50bf7..9499a11fda 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 + #ifdef SHARED -# define __gettimeofday __redirect___gettimeofday -# include -# undef __gettimeofday -# define HAVE_VSYSCALL # include # include @@ -38,25 +36,14 @@ __gettimeofday_vsyscall (struct timeval *tv, struct timezone *tz) return INLINE_VSYSCALL (gettimeofday, 2, tv, tz); } -/* PREPARE_VERSION_KNOWN 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_KNOWN (linux_version, LINUX_2_6_39); \ - void *vdso_gettimeofday = \ - _dl_vdso_vsym ("__kernel_gettimeofday", &linux_version); - -libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday, - vdso_gettimeofday ?: (void *) __gettimeofday_vsyscall) - -__hidden_ver1 (__gettimeofday_vsyscall, __GI___gettimeofday, - __gettimeofday_vsyscall); +# define INIT_ARCH() +libc_ifunc_hidden (__gettimeofday, __gettimeofday, + (get_vdso_symbol ("__vdso_gettimeofday") + ?: __gettimeofday_vsyscall)) +libc_hidden_def (__gettimeofday) #else -# include # include 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 80f7ed91ef..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_KNOWN (linux_version, LINUX_2_6_39); -#else - PREPARE_VERSION_KNOWN (linux_version, LINUX_4_9); -#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 d83afe130e..bab3779615 100644 --- a/sysdeps/unix/sysv/linux/dl-vdso.h +++ b/sysdeps/unix/sysv/linux/dl-vdso.h @@ -22,40 +22,18 @@ #include #include #include - -/* Create version number record for lookup. */ -static inline struct r_found_version -prepare_version_base (const char *name, ElfW(Word) hash) -{ - assert (hash == _dl_elf_hash (name)); - return (struct r_found_version) { name, hash, 1, NULL }; -} -#define prepare_version(vname) \ - prepare_version_base (VDSO_NAME_##vname, VDSO_HASH_##vname) - -/* 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) \ - struct r_found_version var = prepare_version (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_2_6_39 "LINUX_2.6.39" -#define VDSO_HASH_LINUX_2_6_39 123718537 -#define VDSO_NAME_LINUX_4 "LINUX_4" -#define VDSO_HASH_LINUX_4 14921332 -#define VDSO_NAME_LINUX_4_9 "LINUX_4.9" -#define VDSO_HASH_LINUX_4_9 61765625 -#define VDSO_NAME_LINUX_4_15 "LINUX_4.15" -#define VDSO_HASH_LINUX_4_15 182943605 +#include /* 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 #include #include @@ -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 #include #include @@ -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 #include #include @@ -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 + . */ + +#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 463b678ad9..c59d5ddc10 100644 --- a/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c +++ b/sysdeps/unix/sysv/linux/powerpc/gettimeofday.c @@ -57,10 +57,9 @@ __gettimeofday_syscall (struct timeval *tv, struct timezone *tz) return INLINE_SYSCALL (gettimeofday, 2, tv, tz); } -# define INIT_ARCH() \ - PREPARE_VERSION_KNOWN (linux2615, LINUX_2_6_15); \ - 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, vdso_gettimeofday diff --git a/sysdeps/unix/sysv/linux/powerpc/init-first.c b/sysdeps/unix/sysv/linux/powerpc/init-first.c index 831f910788..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_KNOWN (linux2615, LINUX_2_6_15); - - 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 #include #include #include @@ -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 #include #include #include @@ -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 + . */ + +#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 cb3e8b9a73..38477bce8b 100644 --- a/sysdeps/unix/sysv/linux/powerpc/time.c +++ b/sysdeps/unix/sysv/linux/powerpc/time.c @@ -66,9 +66,8 @@ time_syscall (time_t *t) return result; } -# define INIT_ARCH() \ - PREPARE_VERSION_KNOWN (linux2615, LINUX_2_6_15); \ - void *vdso_time = _dl_vdso_vsym ("__kernel_time", &linux2615); +# define INIT_ARCH() \ + 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 a1ad9458e3..3e36270eac 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_KNOWN (linux2629, LINUX_2_6_29); - - 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 #include +#include #include #include /* For RTLD_PRIVATE_ERRNO. */ #include @@ -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 #include +#include #include #include /* For RTLD_PRIVATE_ERRNO. */ #include @@ -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 + . */ + +#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 # include +# include +# include 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 #include +#include 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 85333e5ff3..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_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 = __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 From patchwork Thu Sep 5 20:56:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 173183 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1238492ilq; Thu, 5 Sep 2019 13:57:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyaS0X7F5bTZUQjtnnJJv049sFYUJRKs4kyFJxK59yv4QJW1plAicE202qfNFYuM6y+Wb3S X-Received: by 2002:a17:90a:a115:: with SMTP id s21mr5411352pjp.1.1567717052551; Thu, 05 Sep 2019 13:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567717052; cv=none; d=google.com; s=arc-20160816; b=Eg3qZmtZsJAoLTrzYHy/xnHS2gRUk/DeUl2Uhp+M3mf7RVSd5NC0u6FNo7jPh4AD+a k64BABZ9bW1jZhkc3pTMDLsPJDqE9n7fCjQLMAo5Z7SSOlbDzR77R48DZcMYvWJR/bvC 8BC5zULj9CtYlujys5ZcAr5yMJcnXtPxuJYhHea3xZLSl6hcaGAp4p+v1ZWggYjkqcxV dQOnSY1P1SRPiVi4Bl0QRiAWWojClpFP9kFxltoupQ/NIuNCgjRUGaQhLTspV+4pD8dQ mwG1G7fwrphnwIrSuqoMO8snCifDGAKn1KShAaURsZvkVxc+dsUKZjKALqZ3YUA7aZAm 23yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=m4V/odoMWHFq7AFTBvlA+pwuM7PHBUKe+qpE3nEttAE=; b=rwKJRfwajqV4L37TNoXUVJeV+LaO5UU1H59wcfNZcwmH79VX25NKMjHw9BgCeXyYvu mudwDFOJ2zsUOpwgOlUCRzf0SCbcb2Ak6vVtRBmYkGk3i0FU1i2tBwgUdJHIpF+/ejj/ sFGi9hqMNXF1DVjzQZiQdYannZ0ikKEs7vYBgg1XqyqJ7zUbPMyvkpYFaDjfJN6/WgAR bQ8MumPl242xcY0S9699tgW4k23KTudO7ptKeJ8BP6zYJlw0BRvUK9W9heYn3ZLBhV3Y iGQfxg+0X03DFF1NivMNNsLa8zvdO+6jYwR8YwnTywr1Let2UCEtfgkbMPlaeW1HDjc2 tY6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="R7leVDr/"; dkim=pass header.i=@linaro.org header.s=google header.b=aYz+eXes; spf=pass (google.com: domain of libc-alpha-return-105068-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105068-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id h1si2773651pgp.250.2019.09.05.13.57.32 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Sep 2019 13:57:32 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105068-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="R7leVDr/"; dkim=pass header.i=@linaro.org header.s=google header.b=aYz+eXes; spf=pass (google.com: domain of libc-alpha-return-105068-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105068-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=OJV/DihlHXWy/XA6SEc63zYCBBtZM5X RL7zLUhiA/tCa7Ve1ob/gmXegKn/R7NjDKQhUSmaJ9mZa1qPDptVZbxwww8Sh5Dv rkbee3e5b6ncLhdbw1P1XvAf2aF9tt//UcpmckYm8B+/Nk2bEOLdRbB+fjsDeu1a F+xU5gggBK3c= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=oK1elsM6XmR4K7BTA2xEoPWXfRs=; b=R7leV Dr/efRz1SnDkUbKjxopa/g/ISxUh0Xv70PEPtdHroELc7hsvpWKHSFWA9lWH+aDq AebhpUu/UjiZSy/+7O5FZeTKpDiKOj69VR5iN51Lkwv/i6jjcSEjcHRcsVcMQdnH Wjmzts/rxaoTwRUrH9ayV2t7mjUgwHHFcckwpU= Received: (qmail 117142 invoked by alias); 5 Sep 2019 20:56:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 117085 invoked by uid 89); 5 Sep 2019 20:56:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=consolidate, SA_SIGINFO, 1925, sa_siginfo X-HELO: mail-qk1-f196.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=m4V/odoMWHFq7AFTBvlA+pwuM7PHBUKe+qpE3nEttAE=; b=aYz+eXeseRvbojYSwBCrbMGZHWzuhKTA5Yrwh/MMbKy5M5jv4YlXVLsUZEetRlCnif OJrqlYbKkFgnNXPl9zhlL/iA34X7W1M+gHC6MGZ8Vl7DIT98ikG4OmeUYgTTGVwKsOOl CA3tW8SDWEljMOUd/keEhsJP09gQf9T6kHFqbgijx7kTggupYYsYtRfee1Xgyd3x2JYp Sg01sUlJNeOKZXz3EZ3BNh7ZHIyDL9ifUz0aLPyDN+UV7tBPfUao5tLnbVmpsfuvPgJx +oerdV9mV/SJl6jNk6su/P1Zyao0LZCCk0Q5Lb9DAyvBbPswC9Fn9svaYLTzf2P2ZsLI MhHQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 2/8] Refactor vDSO initialization code Date: Thu, 5 Sep 2019 17:56:14 -0300 Message-Id: <20190905205620.4646-2-adhemerval.zanella@linaro.org> In-Reply-To: <20190905205620.4646-1-adhemerval.zanella@linaro.org> References: <20190905205620.4646-1-adhemerval.zanella@linaro.org> 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. 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-gnu, 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 | 56 ------------- 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(+), 644 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 -- 2.17.1 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 - . */ - -#include -#include - -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 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 - . */ - -#include -#include -#include - -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 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 - . */ - -#ifndef _LIBC_VDSO_H -#define _LIBC_VDSO_H - -#include - -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 #include #include -#include /* 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 - . */ - -#include -#include -#include -#include - -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 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..d90ca820be --- /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 + . */ + +#include +#include + +/* 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 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 -#include +#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 - . */ - -#include -#include - -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 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 - . */ - -#ifndef _LIBC_VDSO_H -#define _LIBC_VDSO_H - -#include - -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 #include -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 +#include 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 @@ . */ -#ifndef _LIBC_VDSO_H -#define _LIBC_VDSO_H +#ifndef _LIBC_POWERPC_VDSO_H +#define _LIBC_POWERPC_VDSO_H #include #include +#include_next -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 - . */ - -#include -#include - -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 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 - . */ - -#ifndef _LIBC_VDSO_H -#define _LIBC_VDSO_H - -#include - -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 3e36270eac..0000000000 --- a/sysdeps/unix/sysv/linux/s390/init-first.c +++ /dev/null @@ -1,56 +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 - . */ - -#include -#include - -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; -} - -#define VDSO_SETUP _libc_vdso_platform_setup - -#include 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 - . */ - - -#ifndef _LIBC_VDSO_H -#define _LIBC_VDSO_H - -#include - -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 - . */ - -#include -#include - -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 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 - . */ - -#ifndef _LIBC_VDSO_H -#define _LIBC_VDSO_H - -#include - -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 #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 - . */ - -#ifndef _LIBC_VDSO_H -#define _LIBC_VDSO_H - -#include -#include - -#include - -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 - . */ - -#include -#include -#include -#include - -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 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 From patchwork Thu Sep 5 20:56:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 173180 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1238068ilq; Thu, 5 Sep 2019 13:57:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyRC2doosXN4HwT6h0OkFwACJoI46GzTTKxbo+b8PbuS6EfTwhR4Kf1cypWEUt8pXLDd7dx X-Received: by 2002:a17:902:7792:: with SMTP id o18mr5346928pll.73.1567717025172; Thu, 05 Sep 2019 13:57:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567717025; cv=none; d=google.com; s=arc-20160816; b=sD4S5JPS37IzwucZRGmyYOXNDRmvmHF0urKSy1bThGN8QZmcXS9CjlmGuFA8BQR2r2 FSsWEegJrIELOgtAYoJqsyZ4o26jXN6QI12+vypHx9b+dEXususbet7cvi7Nn4WTBdVZ +2urVhbOHAIsOEHIOFlKSiiCDUaDAfyW0FMSL9iEn8LaRSx8hzYTTB3FJg/7U/E7g+Jx TwVMVWe8hGLWGuaZyP2QKbj5BgQhO0Wu0lcuQpszZY64GItVCoXh1vyFJ8UPTOGm2bfc jgUgR9rNWP7ldEGB0NiuD7aWhVOeWotwauv3mY+hLZaHbW6JglXi+zfL++c0neC/n9Xz sujQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=uF6VWzgOgPXbytf1jDxQtnk29kzBnBa+AO2W3HtkS2U=; b=jVDQPSAMCBnMVwQLrghbySvhfsD1Z8JvOs4LJN52XKOlhCsSEV08WTmosq26imeDnm nuEU9LJ/TnLZrF9HYGm/Rdha5v27oT3Q81C4YhMEDVtOXWKJuVA0Kn65BW1Wth58QSKU BtxgDpqrPq3sfOLMNmd4nd2GV61pgkhTO7dWeTMoQv0tFyckH3FEewEfykONeruBo9Sm 5hWx46H85AzauZx6ss09Em469o7ub5ju02HscS8buzuraO8HDpdszybNJ/vxco0tn6bc Uj2xtANY5O6BgyjnRWCQ9FvetyPbF/KhNGe/46JgxFpV/WpmnvAOpynyzUfEVsx5ruwJ phsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=pHTHJb4s; dkim=pass header.i=@linaro.org header.s=google header.b=dc8kHJ2S; spf=pass (google.com: domain of libc-alpha-return-105065-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105065-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u13si2716981pgf.382.2019.09.05.13.57.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Sep 2019 13:57:05 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105065-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=pHTHJb4s; dkim=pass header.i=@linaro.org header.s=google header.b=dc8kHJ2S; spf=pass (google.com: domain of libc-alpha-return-105065-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105065-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=YmveBerkPfLvgN3UGEDaKLqWv+6Iyfz p2ahT1g+Xp53dmc7FEuItGFW4NzqTtv8774mvrgjZSNuEH1INaLCDLjiUm0tfnPD ZtAtem03sMqWK5efqkPNF2xz+oH/Ayd+ErT3IypHSnSl7+AV5CrvxsZpmGkwZIsD x2ksZEfcmwfM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=nceBQ6hVKyP3HuZ9ZuQ8maw/wH4=; b=pHTHJ b4sZS4w31xuI4VW+E7mABQo+7+4WJHKcIfaDEbo9RwIn3soa8oDF3sbWsgO6j2lt Nfwv5d8T1yWzeEiVcLQ+Rj0uIStXFIIMCrNsBz8mbc2Ak9t0ZWqDi3NYCzTYyL21 VUJUs8jeS8Y9Hek3gyYV13voGfWMt5BmrGFrRI= Received: (qmail 116697 invoked by alias); 5 Sep 2019 20:56:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116618 invoked by uid 89); 5 Sep 2019 20:56:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f182.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=uF6VWzgOgPXbytf1jDxQtnk29kzBnBa+AO2W3HtkS2U=; b=dc8kHJ2SRJagq5tVshhY/RHR72OMPlLa0PPHL0DpSK/p4xzaquRNZXls/ZxbU6vuR8 6uKKriJi9nzoP+7hB17neBkO7VEqvBtTQfNDJOhTQTKS3Njk4Q8EqgNqqMrr4ATK0lNH t8Iz77KVcFEe7MhLSSNfvNyK6eCduskWo9EdQTt83dwaH+UIXFdqdnQ+x7mYOoBCgUVl XWK7meltjhJcvQ4heX4HQ8xngcsY2eKLZky7/2NTKh60KTeggdH/oiJSkvRnovlGOVaE RjPzSALr7Tdi/mEVZy+/KnIVxI2ZGyKu0ACLbT9pC57fcT2QpLrcDYkI1SJSPE5BMiqu RHkg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 3/8] Enable vDSO on interposed malloc linked statically Date: Thu, 5 Sep 2019 17:56:15 -0300 Message-Id: <20190905205620.4646-3-adhemerval.zanella@linaro.org> In-Reply-To: <20190905205620.4646-1-adhemerval.zanella@linaro.org> References: <20190905205620.4646-1-adhemerval.zanella@linaro.org> For statically linked binaries, _dl_non_dynamic_init (csu/init-first.c:74) calls malloc before the vDSO is properly initialized (it will fully usable only after VDSO_SETUP call). The bug is triggered for the cases where an interposed malloc calls clock_gettime or any other implementation that may call a vDSO symbol. It is because PTR_DEMANDLE at {INLINE,INTERNAL}_VSYSCALL is called with uninitialized __vdso_* pointer value, which should be done by PTR_MANGLE (zero-initialized value in this case is invalid). The patch fixes by adding an extra hook before _dl_non_dynamic_init which setup the initial __vdso_* pointer symbol to an mangled NULL value. For NULL mangled values {INLINE,INTERNAL}_VSYSCALL issues the syscall directly in fallback code path. Once the __vdso_* is setup the vsyscall branches to vDSO. Checked on x86_64-linux-gnu. [BZ #24967] * sysdeps/unix/sysv/linux/init-first.c (libc_vdso_mangled_symbol): New symbol. (__libc_vdso_platform_setup): Add an option to call it to initialize the hooks to null values. (VDSO_PRE_SETUP): Define. * csu/init-first.c (_init): Add a pre-hook to initialize the vDSO internal pointer. * malloc/tst-interpose-aux.c (allocation_header): Add ts member. (malloc_internal): Call clock_gettime. --- csu/init-first.c | 8 ++++++ malloc/tst-interpose-aux.c | 5 ++++ sysdeps/unix/sysv/linux/init-first.c | 37 +++++++++++++++++++--------- 3 files changed, 39 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/csu/init-first.c b/csu/init-first.c index 10762b61f5..d984419554 100644 --- a/csu/init-first.c +++ b/csu/init-first.c @@ -69,6 +69,14 @@ _init (int argc, char **argv, char **envp) __environ = envp; #ifndef SHARED + /* Initialize the vDSO internal pointers to mangled zero value. It makes + the {INTERNAL,INLINE}_VSYSCALL macro to fallback to direct syscall + and allows call the symbol that might the vDSO on _dl_non_dynamic_init + (for instance clock_gettime on an interposed malloc). */ +# ifdef VDSO_PRE_SETUP + VDSO_PRE_SETUP (); +# endif + /* First the initialization which normally would be done by the dynamic linker. */ _dl_non_dynamic_init (); diff --git a/malloc/tst-interpose-aux.c b/malloc/tst-interpose-aux.c index bf86224401..de62d436bc 100644 --- a/malloc/tst-interpose-aux.c +++ b/malloc/tst-interpose-aux.c @@ -28,6 +28,7 @@ #include #include #include +#include #if INTERPOSE_THREADS #include @@ -96,6 +97,7 @@ struct __attribute__ ((aligned (__alignof__ (max_align_t)))) allocation_header { size_t allocation_index; size_t allocation_size; + struct timespec ts; }; /* Array of known allocations, to track invalid frees. */ @@ -166,6 +168,9 @@ malloc_internal (size_t size) .allocation_index = index, .allocation_size = allocation_size }; + /* Check if calling a symbol which may use the vDSO does not fail. + The CLOCK_REALTIME should be supported on all systems. */ + clock_gettime (CLOCK_REALTIME, &allocations[index]->ts); return allocations[index] + 1; } diff --git a/sysdeps/unix/sysv/linux/init-first.c b/sysdeps/unix/sysv/linux/init-first.c index d90ca820be..a23e5d9f6e 100644 --- a/sysdeps/unix/sysv/linux/init-first.c +++ b/sysdeps/unix/sysv/linux/init-first.c @@ -44,37 +44,52 @@ long int (*VDSO_SYMBOL(getcpu)) (unsigned *, unsigned *, void *) time_t (*VDSO_SYMBOL(time)) (time_t *) attribute_hidden; #endif +static inline void * +__libc_vdso_mangled_symbol (const char *symbol) +{ + void *vdsop = NULL; + if (symbol != NULL) + vdsop = get_vdso_mangle_symbol (symbol); + else + PTR_MANGLE (vdsop); + return vdsop; +} + static inline void -__libc_vdso_platform_setup (void) +__libc_vdso_platform_setup (bool initial) { #ifdef HAVE_CLOCK_GETTIME_VSYSCALL - VDSO_SYMBOL(clock_gettime) - = get_vdso_mangle_symbol (HAVE_CLOCK_GETTIME_VSYSCALL); + VDSO_SYMBOL(clock_gettime) = + __libc_vdso_mangled_symbol (initial ? NULL : HAVE_CLOCK_GETTIME_VSYSCALL); #endif #ifdef HAVE_CLOCK_GETRES_VSYSCALL - VDSO_SYMBOL(clock_getres) - = get_vdso_mangle_symbol (HAVE_CLOCK_GETRES_VSYSCALL); + VDSO_SYMBOL(clock_getres) = + __libc_vdso_mangled_symbol (initial ? NULL : HAVE_CLOCK_GETRES_VSYSCALL); #endif #ifdef HAVE_GETTIMEOFDAY_VSYSCALL - VDSO_SYMBOL(gettimeofday) - = get_vdso_mangle_symbol (HAVE_GETTIMEOFDAY_VSYSCALL); + VDSO_SYMBOL(gettimeofday) = + __libc_vdso_mangled_symbol (initial ? NULL : HAVE_GETTIMEOFDAY_VSYSCALL); #endif #ifdef HAVE_GETCPU_VSYSCALL - VDSO_SYMBOL(getcpu) = get_vdso_mangle_symbol (HAVE_GETCPU_VSYSCALL); + VDSO_SYMBOL(getcpu) = + __libc_vdso_mangled_symbol (initial ? NULL : HAVE_GETCPU_VSYSCALL); #endif #ifdef HAVE_TIME_VSYSCALL - VDSO_SYMBOL(time) = get_vdso_mangle_symbol (HAVE_TIME_VSYSCALL); + VDSO_SYMBOL(time) = + __libc_vdso_mangled_symbol (initial ? NULL : HAVE_TIME_VSYSCALL); #endif #ifdef VDSO_SETUP_ARCH - VDSO_SETUP_ARCH (); + if (!initial) + VDSO_SETUP_ARCH (); #endif } -#define VDSO_SETUP __libc_vdso_platform_setup +#define VDSO_PRE_SETUP() ({ __libc_vdso_platform_setup (true); }) +#define VDSO_SETUP() ({ __libc_vdso_platform_setup (false); }) #include From patchwork Thu Sep 5 20:56:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 173179 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1237915ilq; Thu, 5 Sep 2019 13:56:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7OC6jj2rW1Neuevc9WmBaKU769uqlfgfYqtTOHUboM1Vg5kEeMF1ognEJR0/XCzXPSI2H X-Received: by 2002:a17:902:b18c:: with SMTP id s12mr5697589plr.257.1567717016136; Thu, 05 Sep 2019 13:56:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567717016; cv=none; d=google.com; s=arc-20160816; b=C2yqfOoMZc1CMyjOcaEAze4Amy5l/dQdIpYIEvu/ndQ3F2bm/k7faEKQFYoMnbFEM5 4WgXoSlwQBbNrfBWRfh8+96MkD5TjL5HQqBo/Hs3r4hR/2fp+SRg7/oA2OA5HO72BnaV tkWROh0z+aoRyVQRBNC863l+3ZL5G8MycbzkOo48qmZ3FzxCsHv3lRXuZ83ZyL8eH92z i0rvQ8I4omN8unBx5LhONpCYwOD88Kv8a5b7BrhfJAwim9ViDXaJzt7CVe6Cma6kBC1Y fyg1DRdES3PFqwF/RkyTg+H4xVxxxun4YNz3RfyXDcdabumQm2/R8dzXuEpVkT+Y/bfO ogAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=lKtwSvhpuwDh8vRnSPAaaDI5N0Z1HZNrZLhpf0iPV7w=; b=rwwJ+c30cp/b2qVFa8zJ2C2BVdy3JOtXVY2W9q4mXSxnvDqjOSDkSJs7Y+R/Rbni+j Vv7+j45rkfzNrewdG6xWc8lXxHfhSfej1N0cSktGBZTkx9ZpaaDLQ8bymZfBWk6IbRtQ cq5Z+//h21B8bNpDmY+OfMn/d+CC8zazdCfeTFNvfzurPB3NzHB4U5x+bCO4lqy8fQuI +SzS0KxKSa/oajBuxAJhRT7cXaPBB2nrHEn2vHLn8admhk6JB5MXNuO0u72b0w2By8Ow pZhssWTV9guJLXESFxm2fNgx0+5ZWg1vRMafuflObwMEBruaitj3XmfZSnfS5JKDbplZ OjFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="lXTi2/zq"; dkim=pass header.i=@linaro.org header.s=google header.b=jr6x+4ga; spf=pass (google.com: domain of libc-alpha-return-105064-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105064-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b9si3125700plz.140.2019.09.05.13.56.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Sep 2019 13:56:56 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105064-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="lXTi2/zq"; dkim=pass header.i=@linaro.org header.s=google header.b=jr6x+4ga; spf=pass (google.com: domain of libc-alpha-return-105064-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105064-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=LRoqXueB9z0VukEVtbXt6+a/qsruC7x BpdkRVZBzjNa4XwZTJImrQb+CoAwbLzxLsjrdZMoaQhmYmQ9rGgrJnKHJhWnN7XU N/KuCv4g+vnuA2CMDPai0cB2vlwH91w2RdAS0EyrPG546aplEZ9eMiUVOg2n/yiC k8QLvrTwk0x4= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=GS14GPDkZkTkOM6it7Jp3TXtUWw=; b=lXTi2 /zqgWnQ/fIK1xO8Un3SZkyCoNGZmYqR3v2gwvpIsOfnRr3tcFs1x4s3/2zlJY61B S/4BboXdJw02IHXeHVU8Qp14iLRx/e0dco2hMc4i1UnfN0NH6cEQqXebOjSsP8IN hRKbQBwm3VAnmiGbGz0YszcKKlqYrejIAN0RGI= Received: (qmail 116679 invoked by alias); 5 Sep 2019 20:56:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116616 invoked by uid 89); 5 Sep 2019 20:56:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.9 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=HX-Spam-Relays-External:209.85.160.195, H*RU:209.85.160.195, HX-Received:60a, simplifies X-HELO: mail-qt1-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=lKtwSvhpuwDh8vRnSPAaaDI5N0Z1HZNrZLhpf0iPV7w=; b=jr6x+4gaQj+FRHx2Ni2vSg3EV3q8lSRa3K28MnS50JP0D7bLf+edeAbkWisB4+p1DX uGauFUqIlFgX6dfuFhtzrCyRoZsnO+s6+S0QzjdXr56Nr8mbEqCHhbPqR4ATuqmRnKm3 2drP4JqfKV36NKJqyPdF0BFbv5jna+VRgmFhbJj+lyW4YrjdkU/YzuvsuDNBhqFtFX3d jVAhWM++F6p8qItcWb7MeJ98qIKCX/CYRLg3k1UWVfGCDkkpM81za73ZvETiR8Oug/v9 Kxzkro/DYttwf5IDfvSsxyM1mvS23+zxLoKDCcwykJQMuAaDe+YWHT/k/Ti/M+TBl8Rm umnA== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 4/8] powerpc: Simplify vsyscall internal macros Date: Thu, 5 Sep 2019 17:56:16 -0300 Message-Id: <20190905205620.4646-4-adhemerval.zanella@linaro.org> In-Reply-To: <20190905205620.4646-1-adhemerval.zanella@linaro.org> References: <20190905205620.4646-1-adhemerval.zanella@linaro.org> Changes from previous version: - Fixed the issue with the removal of the CR0.SO check on INTERNAL_VSYSCALL_CALL. -- 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(-) -- 2.17.1 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 c245e97526..61ff6e2b2a 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 #include -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 c59d5ddc10..e046594d40 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. */ libc_ifunc_hidden (__redirect___gettimeofday, __gettimeofday, 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 #include -#include_next - -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 /* 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 + +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 38477bce8b..f0537a2307 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, From patchwork Thu Sep 5 20:56:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 173181 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1238216ilq; Thu, 5 Sep 2019 13:57:13 -0700 (PDT) X-Google-Smtp-Source: APXvYqyu5MfZRn2yAHozyN1bht12gPZsdMRYK3JgpGf87TDeJ6HKGQHn1ElW0fWHtJDbA+ODTXt7 X-Received: by 2002:a62:2ec7:: with SMTP id u190mr6495703pfu.121.1567717033458; Thu, 05 Sep 2019 13:57:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567717033; cv=none; d=google.com; s=arc-20160816; b=wxx+EK8MFb9O4K4Lncv1L8QHaSLBpUfaMiUJP5O8g3pQUqgBZCq0WEdh6g4Hg/vfio 8Y4VCe0Ug2HKKxRDVZuv/Qh4IWWP7kU+MkPDWQJt6psC/sd7DHaXbCsK7fZ468xE8KtZ wyAcwcPXcs5hrV+XoIUg62jOzZRF9YBMqoKLtr6spGaqi9Yjo0l+hZ2vmOQqqolk2wS8 eKXiJbAgoo69M5tByieX+EQ/PaQlGnR5G9oay3vuHk+UVmvdlUzOWcIrvJOADs5PPgAf zcWNLGgPXKYIO7zu5m+Y2LUQ/KzrGtxUxgN8Uqlpj1e/hGiHodU7h0SOXmgx6v79cvnG 05xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=gwUlLK9DTxZpgKw8a8M/qTuEBhoxxCH3anBUMULq41c=; b=SrP4yBV4cv5+nnwTr4u2uGJONCVAtjDLEGPIOWYcPhO7XDUMG7+V0e9yusHJCcQi4n gIHNktKWeyrvlAHNLA1tBzuyCeek3MCzu1ho9+Jxx6D+tJipXqxuVkUO5iEyvFyU4nqE ru1XYC45k5oSV4KPr37fX0LbRoKe6KqLN/NPGhl+ON5mAEj1mneFJFbshTlHWiPDTiIx EBypK/keYy/y+Rm6zP2iAgXEA2rH3zDaatjLQ8nigZvWMqy/nA9zxuOGXpuLJxSqwDJh x71KiIaD4D+KGPWnLtBbyJ9/k7yFgzaqIXrzqGhp8rh/ZckrFD8W2p3lhqoMB3QcdrAd TFMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=d+ATXUeE; dkim=pass header.i=@linaro.org header.s=google header.b=cr++hD3x; spf=pass (google.com: domain of libc-alpha-return-105066-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105066-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id h8si2738917pgc.402.2019.09.05.13.57.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Sep 2019 13:57:13 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105066-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=d+ATXUeE; dkim=pass header.i=@linaro.org header.s=google header.b=cr++hD3x; spf=pass (google.com: domain of libc-alpha-return-105066-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105066-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=GxslJCkk5NWGQzDZaRJUbB01jga+mec 3nY8P6DNg+jhCrqLX3QuJ6BILngOsDLIQhECEIdRtv3abOLy4lt3Q4wxISN83jjW /2poQtfx0eBN9Z7u4yNzfRCf03CGh7Gjt8f6u3RtJJ0bEM417blttnHvJk+jzBg7 uhqlE1pZ2SUM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=pQspx06S0kWLVMl73gnYpOIwKe4=; b=d+ATX UeEytks25YqjglOc7HBlMrj7mDeggJS8Kx4spumxgVT3HW14JhN0Ho90Is7zRLEY KbPB+sHWa/AL4Ne+gQzN00HCEmHTRV7POCBQpqEpg6G2h96hMCG0RLO6KeHRAlER RlAE+WtmkH7VSvqjDQgiAliqAI8VbGb2jqVSc8= Received: (qmail 116801 invoked by alias); 5 Sep 2019 20:56:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116690 invoked by uid 89); 5 Sep 2019 20:56:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=consolidate X-HELO: mail-qt1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=gwUlLK9DTxZpgKw8a8M/qTuEBhoxxCH3anBUMULq41c=; b=cr++hD3xymsBhGS3WaFeyLJuBdM23u5Xd57OXHlkDYIO5LPBKLrjv03NUUWtmEeag7 K4Ij+KfHlczjVr4mgE9Yc6gdq0S+U4Q3/ZqaFys1wGEhUtDfA6k7gV92kSjQN+8c5asL 0qCLDtSRIR7HAgJMPm/fUpgZy6dov6ezI0RCqfaYdRLsC3dMKdDsI5YY3k6jGom/K9qH KxaEdcAam2mBvh9N4tDBOu4jcqZt4MLtxy0e0s/oiB6UTGzyc8rsDx9FWpyElWd3f0gE 1GFyjD8Rw9vbU9w1FeMg2LwswuEm3i0o+jf8gryzgKbmZN8pMvWaLqDBO2I+lFTcnmy/ tvOg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 5/8] mips: Consolidate INTERNAL_VSYSCALL_CALL Date: Thu, 5 Sep 2019 17:56:17 -0300 Message-Id: <20190905205620.4646-5-adhemerval.zanella@linaro.org> In-Reply-To: <20190905205620.4646-1-adhemerval.zanella@linaro.org> References: <20190905205620.4646-1-adhemerval.zanella@linaro.org> 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(-) -- 2.17.1 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__ */ From patchwork Thu Sep 5 20:56:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 173182 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1238340ilq; Thu, 5 Sep 2019 13:57:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqy3Cx5A1dOTqAMSVs++NkI+lv8JN4HyD9xwBnexBIgJuid679AFzroZOgxVRvH0Psqhj5Uz X-Received: by 2002:a62:e21a:: with SMTP id a26mr6369449pfi.156.1567717041629; Thu, 05 Sep 2019 13:57:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567717041; cv=none; d=google.com; s=arc-20160816; b=y7Hrsv+gH4kyZb/cl07THw7s5IGjC+2Xc8J2XnnND5M2bE6zNGz8iUShrr85a+GaCS AMr/eRw+40O07MB1IsETCVvpaNbyALWrlfs/ZbsoiClB3vgNZ2JGF98ZhBC+dyUbGpX7 nYFLOa72MybHqLY4vgJft3U/vnv/12xoz0OIE7ClfB4lpePxTq9lqooIEpo4FvVl8BR6 wAICDmpHJqjIUq1jSM2SC0F0M+hVW0/geszwcmtX0RqHdt8RFLY8inufYHd7njVkOQAb bpsg5QYg5exPi3Dyo+XJlTpN2QiXEkCPYsjPbHU+gHlW2U67lo0+WoFbQ2YRGH4CwGz7 4HWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=a2hhNon9R39tQEg3zKHZ8tICMNEpxzwjxLO9GgnyuHc=; b=mIjxauyfN3lvrh8cYofRh6nwKOhRqwVI8Pe/dhfQH5MqeekCFLkof0Nw0H042bmtPF FGLh1JdzDeJzabyNNV2H/s5rgqFw4jn0x+FMneRr6lBLzHyT4AXH3Q7whKupPaVn6h7E VL4R6fYWbJECKJYG22ClZoUKrHyaMHPye1KaPf2yOdzlp7p8xcC0G5poWCeDuK/XyVL2 4udgiKXj/eE3mFCzW/eDbVmYFOMs86r3pQ87YeEkKZjvOJ5LfghiSV8Pwes2KdvA0F7i cwV7V6jcGp0eW/pDgN7SwiYmLaWQvAELDnWetLw1IInjsLPDfL+2SsBei/0XtqfVZEdT 10Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=RFM++RMS; dkim=pass header.i=@linaro.org header.s=google header.b=AW7yKBkI; spf=pass (google.com: domain of libc-alpha-return-105067-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105067-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z19si3278014pfa.19.2019.09.05.13.57.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Sep 2019 13:57:21 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105067-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=RFM++RMS; dkim=pass header.i=@linaro.org header.s=google header.b=AW7yKBkI; spf=pass (google.com: domain of libc-alpha-return-105067-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105067-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=vKM+0aHdi4AGqfPERSuFRsbasnUNmEw QAm3Srp4jZhu9F1UZTTrWlJsECJSL/J6sIH8HFbe4gIvwkRYBdH3IRrSIgZyRdtP FHAqt5ZIPDPk8bXt7w716ihS710M7JEsme1AutwzhBWVFvWDvyPP8Z4a5D1937vn RG4cko5jit2s= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=sib1OYOaMtWG8J+/DLpEq6OsYLE=; b=RFM++ RMS46jZ4twWb9fTiQUVhMkErh3wqhGU1UKdZwJXV6iNhB3VG6vOpTo9yN8ijAaoN DSyFiw4xROzzsq71/3hWBIU1unbPUscfaHw2j6OWV+3wN9gNRocRzBscJYQORZDj a/tgqvJmoTYBeJCekiQHtApwzzuf1/1XPvrd3E= Received: (qmail 116978 invoked by alias); 5 Sep 2019 20:56:35 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 116867 invoked by uid 89); 5 Sep 2019 20:56:34 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=a2hhNon9R39tQEg3zKHZ8tICMNEpxzwjxLO9GgnyuHc=; b=AW7yKBkILYogkDa0k/JMr7AknjEAozKgBIU1XZ8sR4mUbIX7BXl8VQBdbcyPai8s9K XDkoCFniddevbT3qET6+zvIcqg8p8+JOg1MiyJFE0AVsVXilIb97lURpNi3WMzVtYcC7 uPzbIVN4CYJTlNsCfFKYhy1Z+TVn9W21En3mFFBBrdl1Qo9bCPVyeERkMUI/G/pDFP6G xnvIDirBFr3Hl2np9UfbRUqj0K7dGVjjwi97gj2jD1viW7/7wKwJSbp0sMQiUhKV+uqg 07pgdnjYPs6cQI1u6UaYi0N7SMpXCnf96qNZLoQ0V5BmgntMKK2sxaehvS2knbvCAbiV MVqQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 6/8] sparc64: Use linux generic time implementation Date: Thu, 5 Sep 2019 17:56:18 -0300 Message-Id: <20190905205620.4646-6-adhemerval.zanella@linaro.org> In-Reply-To: <20190905205620.4646-1-adhemerval.zanella@linaro.org> References: <20190905205620.4646-1-adhemerval.zanella@linaro.org> 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 -- 2.17.1 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 From patchwork Thu Sep 5 20:56:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 173184 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1238647ilq; Thu, 5 Sep 2019 13:57:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyBm+8eW12AGb/lHF63TfSpmSMEojDnsfnnnjrD8g6wcseZA47a/qMfRbY9XWFkw/GR39/U X-Received: by 2002:a17:902:9b86:: with SMTP id y6mr5628701plp.217.1567717064583; Thu, 05 Sep 2019 13:57:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567717064; cv=none; d=google.com; s=arc-20160816; b=hnTtNTUL7gx/gya0RHKSASn2f/OLv/+nvFF736pkQE2XFlD1YVYBxwvSmm+rseWjOF GRU3fmmm+u02m93GygrNfbennuG9Xl0/YZO8/S7DvUDSYzsJGhWKzzirn257xnllbaYm yZWs8zywpKFara7HsiUf13HPBwzIZyYlyMN8Zk1DR+gc7sX6141ggAHN+WlT4hnCCqoQ nSk/pSCkdJF/JwBFCwtjgMmr25t65gAwskwhrAcUadG0aiQ4OMcM1GKx2768RWrfDUMV hnxOBfAs01AkXEBmKPiZn1elNEpPjincEZA1XU0ztPqStlxFE+inPCGzRHjFeLtnTIs+ k0Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=3IOo+BI80Erhf+jc53R3uhJBUadI14E1Pzz1NLp8/W8=; b=sp7TKEgSlOl4S72UdH7M4mxv6Bxa6h+tyeT0xlP9P4I1H57or+G1CDnbsvGuBk28RL N/pVfi534vJHwmhZGVzwBOPwkqe4ymJrGYrZN2lfFG+J11haoqODeFW0stPZfaEMOoPp fAjEUQHyAhPGJjY3bPbj7WgFf38vrAAyLcla4ubBfZyxvqrnDWQVxFBsfok9M1EFLK74 3uUapKs6eSkCoh5wUKa0gSgLOKIT6zVJZLivMTN4OyxDI/Q9Z3Jk+PbRGvgqyqPPd320 FKnvlx2QVnlyzbdYcK+5PpWCre60yKXMgWFZJWHDHQWmgmaaQgUmNyH/xkK35TJ12at2 XwMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="u/xp/PD3"; dkim=pass header.i=@linaro.org header.s=google header.b=Z1IDfjiH; spf=pass (google.com: domain of libc-alpha-return-105069-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105069-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id w6si2717106pge.395.2019.09.05.13.57.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Sep 2019 13:57:44 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105069-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b="u/xp/PD3"; dkim=pass header.i=@linaro.org header.s=google header.b=Z1IDfjiH; spf=pass (google.com: domain of libc-alpha-return-105069-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105069-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=dTO1tdnep/YcVo1A0eCP27s6uRI5sTU G3LCI2byIwVPWKQY9HLFHlI6D6FeBIs/EYZwN1BdwmymCvRVw36cZz0giEANWNmS M1hBdqV0iR8XiXSzae3FUKlBIEX/2+6XRNMHBENhvsA+mVjS3r5OSeWSd7Xxysi7 oTNw83T481b0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=uP+DErUe9aAoSvdNrl7u4Q66VTQ=; b=u/xp/ PD315QX6AwM5YGOTIC13zCU+ezJU08GlIgZSnbotgJ6ZxiznNsT4VKEEwomUOtei ICYUZ7MV51r/Dv4sDjHqodO08wbw8D45oPGRrGrboib8k+JzUChoA7bgLIJg8J6k he1DdPCQgtVL7JOFsiGERFUWLUBvpBsD/KZJwg= Received: (qmail 117476 invoked by alias); 5 Sep 2019 20:56:39 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 117411 invoked by uid 89); 5 Sep 2019 20:56:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS, T_FILL_THIS_FORM_SHORT autolearn=ham version=3.3.1 spammy= X-HELO: mail-qt1-f194.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=3IOo+BI80Erhf+jc53R3uhJBUadI14E1Pzz1NLp8/W8=; b=Z1IDfjiHgKdMsZWSO0xNw0e2IU5b07VghOXdXCBQLNgUMjIwIEsUIDRaPAbzvshat9 OeDrQaRA/9hKb+kN/5ZW1uIV01FefVzzt384HXAlSL/yN6QGNIOLR7h+BoZjSJrYWlKg rzWItHIRbWaW+P3bycj29++m2uvotAsnCXcmA9BUGkjgUW4ShgjF9Y854mC+S0MDd0kk gLscUuFW+oAVu7FRbjxGCtqPrfn2ia13GI9uf6Ao37LwmzDXgxEY9t6l3Kbf3IvpAGt5 PlZIj+6q0plRH2mpNuR+WvMNg4Whl+XaLQiUrasdGrwRoid8yUjEnZxnj6CRWMVGWVgW ErJw== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 7/8] linux: Consolidate time implementation Date: Thu, 5 Sep 2019 17:56:19 -0300 Message-Id: <20190905205620.4646-7-adhemerval.zanella@linaro.org> In-Reply-To: <20190905205620.4646-1-adhemerval.zanella@linaro.org> References: <20190905205620.4646-1-adhemerval.zanella@linaro.org> Changes from previous version: - Improve comment about hidden_def_redir. - Update due powerpc64 fixes. -- 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 -- 2.17.1 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 - . */ - -#ifdef SHARED -# define time __redirect_time -#endif - -#include - -#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 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 - . */ - -#ifdef SHARED -# ifndef __powerpc64__ -# define time __redirect_time -# else -# define __redirect_time time -# endif - -# include -# include -# include -# include -# include - -# 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 - -#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 . */ -#include +/* 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 +#undef time +#include #include +#ifdef HAVE_TIME_VSYSCALL +# define HAVE_VSYSCALL +#endif +#include +#include -#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 +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 - . */ - -#include - -#ifdef SHARED - -#include -#include -#include - -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 - -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 From patchwork Thu Sep 5 20:56:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 173185 Delivered-To: patch@linaro.org Received: by 2002:a05:6e02:ce:0:0:0:0 with SMTP id r14csp1238820ilq; Thu, 5 Sep 2019 13:57:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqzewyE2xaTiDCLXfU2xADcDCxBHnFSFwTT49+HgKBwS5ya/S6VGo7iUpXPB4NZ1la2iO9n3 X-Received: by 2002:a63:2b84:: with SMTP id r126mr5113352pgr.308.1567717075167; Thu, 05 Sep 2019 13:57:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567717075; cv=none; d=google.com; s=arc-20160816; b=q8q67m1fhh3ubWOVm3qWSlfWZDj8vI76vB789piM8Z9ayVsHaGoyqae3TSzugGW27P JLxNe5gaax8AQEx0PtJgNhO8GHM2Qx3yrogeVvE9sTlrcTVPHeLIHhz1WJMkdoeLOKSs lgZpP4O5CKYlGTh04mJMaiJgCjFnD7pY2Pk2K0pd4yvg1P+hOoHYhiU/IgXcYd/b4wGM 5Z54S9XZl+WAPX88oLzQxd6QRZieUPq+cigYn6n030Vysm2TvT5HFKsK+YgLwjfL+kuC jF/9SQkPZoKyRVaG0fu5XlkObVwFv+aeGfK3UgL8I6XwHwO54ri9ubWRnY1xwAf9x0Xw UHlQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:to:from :dkim-signature:delivered-to:sender:list-help:list-post:list-archive :list-subscribe:list-unsubscribe:list-id:precedence:mailing-list :dkim-signature:domainkey-signature; bh=MWQuXfMf3IWTXs8matr+lGt67d/nvAusyTdZyVJFT8o=; b=LLz1l4eYs1PBYISaqkhSrVpreEcE5Oyp6316nEzwiOx6ROkZ16so4mxv1bkznVmyX1 j/Vgk8sPeYX1CPSpgvCFPh/XnKCzm3ZaSljHv49Kz6pa+pspF5cphvPd0HztRaXGiNmM Z5ktqXtp6vxiDOvG9VO63QMYowVDzhZXR+aIss2hZ6BreYJ4jd7LEQD+4hbKEGv/7Xp1 uBJHOPhLUy3McvHMRY2kfe9HvUq9eXHTTkvoCoPgkmZ2zDtZcIDBTiX7sZKcypbCgw4j 9+UL9ePApyzL9KLnuDK/8XOGT2b9Tdl3U74MUb1JhNeweKsXf/2VT2IKX9gXXGJLxq7R dgrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=yVPTgnsz; dkim=pass header.i=@linaro.org header.s=google header.b=a5J40TiB; spf=pass (google.com: domain of libc-alpha-return-105070-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105070-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id b9si3127826plz.140.2019.09.05.13.57.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Sep 2019 13:57:55 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105070-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=yVPTgnsz; dkim=pass header.i=@linaro.org header.s=google header.b=a5J40TiB; spf=pass (google.com: domain of libc-alpha-return-105070-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105070-patch=linaro.org@sourceware.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=JLm3Ov+jXxnw/EZ+wGP4h4Khq0RaeHx wtskJsl2hIAeQkMKxc9UCY2YWvqUPrHkvWc0miLFo9mT8Tvo/TCC08q/rjvDYTuC T+eA8VCGdWoqfVxruK7Mh4Vg1c1fxJjYEUDNQRgboehoZKbkUCubf963pE/bIFhE LUGwbt9fO8r8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:in-reply-to :references; s=default; bh=EJCqriYsbr/8oST/OE+TWeB5Cno=; b=yVPTg nsz+BLM62JVZ6rZgVvcddro2/kGeraXt+HXkN2B8NTqfkIjtQDMXvURHNoHINjV+ p5scERt5Sp0BC1xowY+86uoEulJY6ZHaIs7jgt6fUjt4ACbQK9CN78hPRf+Dyqof izqRX1jQ+TL8f2kx6VxzQKuqYjBHQ2ZZ+JL5RQ= Received: (qmail 117720 invoked by alias); 5 Sep 2019 20:56:41 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 117651 invoked by uid 89); 5 Sep 2019 20:56:41 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=H*RU:209.85.160.196, HX-Spam-Relays-External:209.85.160.196 X-HELO: mail-qt1-f196.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=MWQuXfMf3IWTXs8matr+lGt67d/nvAusyTdZyVJFT8o=; b=a5J40TiB79uImJIioqez3S1jVGtx6bjCVrUX2V+eLiEbBlbdJp6heIBK5wh2VTEQsj 41iVOUHoqwi4ZivFUolHJJ4KoCdSadPlNh/zH57wK4fN7YWQ84IYF+46alqKZw6D34N+ idAhzYVaj7DalDQnDq1gBRBU0aRKWoF6nLh0ycDTiJnV8ybosNPaulYqIpNn17KgP61G QKwCNbAFPeqov1Q9NmXH/6Suz0vcqTU/zWiUMMIzdypFh+xkPgxRPdGmF6+qag2t6FCu odrMjBkyFHoN1xiOgxYa3Z5VqWrISn5SxflzypcKYSBGiSV754lq9ATPWqNUFgZudL+d F5oQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v2 8/8] linux: Consolidate gettimeofday implementation Date: Thu, 5 Sep 2019 17:56:20 -0300 Message-Id: <20190905205620.4646-8-adhemerval.zanella@linaro.org> In-Reply-To: <20190905205620.4646-1-adhemerval.zanella@linaro.org> References: <20190905205620.4646-1-adhemerval.zanella@linaro.org> Changes from previous version: - Update due powerpc64 fixes. -- 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 -- 2.17.1 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 - . */ - -/* 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 - -#ifdef SHARED - -# include -# include - -/* Used as a fallback in the ifunc resolver if VDSO is not available - and for libc.so internal __gettimeofday calls. */ - -static int -__gettimeofday_vsyscall (struct timeval *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 -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 . */ -#include -#include +/* 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 #undef __gettimeofday +#include #ifdef HAVE_GETTIMEOFDAY_VSYSCALL # define HAVE_VSYSCALL #endif #include +#include + +/* 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 - . */ - -#ifdef SHARED -# define __gettimeofday __redirect___gettimeofday -#endif - -#include - -#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 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 - . */ - -#if defined SHARED && !defined __powerpc64__ -# define __gettimeofday __redirect___gettimeofday -#else -# define __redirect___gettimeofday __gettimeofday -#endif - -#include - -#ifdef SHARED - -# include -# include -# include - -# 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 -# include - -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 - . */ - -#include - -#ifdef SHARED - -# include -# include -# include -# include - -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 -# include - -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"