From patchwork Sun May 25 19:41:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 352266 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BAE87140091 for ; Mon, 26 May 2014 05:43:48 +1000 (EST) 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:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=LcymdAg6us3vhw39N1YS2XQULWVeqNt 4DNb9Nr6Y6Abc3DYMfhy5ZezlULbNERiRnxsWcZLkWBQskeDKBn54JX1FwRdwYXT /W4kNIuN/qSH4R33BWTn3WgZKj2eY35WGAtMsu7NFIRZmNwmaWwJXxpmsUxICjOY DpBECC2xkBMY= 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:cc:subject:date:message-id:in-reply-to :references; s=default; bh=PB7pD7a4MZSmCtQgvF/uKLsxMhY=; b=yCIa4 0sBFFdGctp1gnBZvm8EJL6Q22MkIWgTQnmfOYSvcLVuvSXah/Wz4DX4io/t9kGdb 9Z5ZYBxcgRcGhC3sWLENTtSgCjifhZ95laeyMe7LO4JrO52ebAV63b1Gh5LkVvHz sRIafkXR50u2TvWrDfJaopaaq7XRlExTPjGYx4= Received: (qmail 3097 invoked by alias); 25 May 2014 19:42:21 -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 2975 invoked by uid 89); 25 May 2014 19:42:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-qg0-f47.google.com X-Received: by 10.140.109.201 with SMTP id l67mr25163606qgf.72.1401046936740; Sun, 25 May 2014 12:42:16 -0700 (PDT) From: Richard Henderson To: libc-alpha@sourceware.org Cc: marcus.shawcroft@gmail.com, Richard Henderson Subject: [PATCH v3 9/9] aarch64: Consolidate NPTL/non versions of vfork Date: Sun, 25 May 2014 12:41:49 -0700 Message-Id: <1401046909-25821-10-git-send-email-rth@twiddle.net> In-Reply-To: <1401046909-25821-1-git-send-email-rth@twiddle.net> References: <1401046909-25821-1-git-send-email-rth@twiddle.net> From: Richard Henderson At the same time, incorporate the 0 -> 0x80000000 mapping of the pid expected by raise.c. --- sysdeps/unix/sysv/linux/aarch64/nptl/pt-vfork.S | 35 ---------------- sysdeps/unix/sysv/linux/aarch64/pt-vfork.c | 54 +++++++++++++++++++++++++ sysdeps/unix/sysv/linux/aarch64/vfork.S | 29 ++++++++----- 3 files changed, 74 insertions(+), 44 deletions(-) delete mode 100644 sysdeps/unix/sysv/linux/aarch64/nptl/pt-vfork.S create mode 100644 sysdeps/unix/sysv/linux/aarch64/pt-vfork.c diff --git a/sysdeps/unix/sysv/linux/aarch64/nptl/pt-vfork.S b/sysdeps/unix/sysv/linux/aarch64/nptl/pt-vfork.S deleted file mode 100644 index 2108347..0000000 --- a/sysdeps/unix/sysv/linux/aarch64/nptl/pt-vfork.S +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (C) 2009-2014 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 - -/* Save the PID value. */ -#define SAVE_PID \ - mrs x2, tpidr_el0; \ - sub x2, x2, #PTHREAD_SIZEOF; \ - ldr w3, [x2, #PTHREAD_PID_OFFSET]; \ - neg w0, w3; \ - str w0, [x2, #PTHREAD_PID_OFFSET] - -/* Restore the old PID value in the parent. */ -#define RESTORE_PID \ - cbz x0, 1f; \ - str w3, [x2, #PTHREAD_PID_OFFSET]; \ -1: - -#include "../vfork.S" diff --git a/sysdeps/unix/sysv/linux/aarch64/pt-vfork.c b/sysdeps/unix/sysv/linux/aarch64/pt-vfork.c new file mode 100644 index 0000000..5dd23bf --- /dev/null +++ b/sysdeps/unix/sysv/linux/aarch64/pt-vfork.c @@ -0,0 +1,54 @@ +/* vfork ABI-compatibility entry points for libpthread. + Copyright (C) 2014 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 + +/* libpthread used to have its own vfork implementation that differed + from libc's only in having a pointless micro-optimization. There + is no longer any use to having a separate copy in libpthread, but + the historical ABI requires it. For static linking, there is no + need to provide anything here--the libc version will be linked in. + For shared library ABI compatibility, there must be __vfork and + vfork symbols in libpthread.so. */ + +#if HAVE_IFUNC +# include +#elif (SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20) \ + || SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20)) + +/* Thankfully, on AArch64 we can rely on the compiler generating + a tail call here. */ + +extern void __libc_vfork (void); + +void +vfork_compat (void) +{ + __libc_vfork (); +} + +# if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20) +compat_symbol (libpthread, vfork_compat, vfork, GLIBC_2_0); +# endif + +# if SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20) +strong_alias (vfork_compat, vfork_compat2) +compat_symbol (libpthread, vfork_compat2, __vfork, GLIBC_2_1_2); +# endif + +#endif diff --git a/sysdeps/unix/sysv/linux/aarch64/vfork.S b/sysdeps/unix/sysv/linux/aarch64/vfork.S index d9f2c70..316cb65 100644 --- a/sysdeps/unix/sysv/linux/aarch64/vfork.S +++ b/sysdeps/unix/sysv/linux/aarch64/vfork.S @@ -28,22 +28,33 @@ ENTRY (__vfork) -#ifdef SAVE_PID - SAVE_PID -#endif + /* Save the TCB-cached PID away in w3, and then negate the TCB + field. But if it's zero, set it to 0x80000000 instead. See + raise.c for the logic that relies on this value. */ + mrs x2, tpidr_el0 + sub x2, x2, #PTHREAD_SIZEOF + ldr w3, [x2, #PTHREAD_PID_OFFSET] + mov w1, #0x80000000 + negs w0, w3 + csel w0, w1, w0, eq + str w0, [x2, #PTHREAD_PID_OFFSET] + mov x0, #0x4111 /* CLONE_VM | CLONE_VFORK | SIGCHLD */ mov x1, sp DO_CALL (clone, 2) -#ifdef RESTORE_PID - RESTORE_PID -#endif + + /* Restore the original value of the TCB cache of the PID, if we're + the parent. But in the child (syscall return value equals zero), + leave things as they are. */ + cbz x0, 1f + str w3, [x2, #PTHREAD_PID_OFFSET] +1: cmn x0, #4095 - b.cs 1f + b.cs .Lsyscall_error RET -1: - b SYSCALL_ERROR PSEUDO_END (__vfork) libc_hidden_def (__vfork) weak_alias (__vfork, vfork) +strong_alias (__vfork, __libc_vfork)