From patchwork Mon Oct 14 20:56:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 176356 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5014543ill; Mon, 14 Oct 2019 14:00:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxNooQZkatZ9YH30tfqs80ZOeIanke9cdWqW8SPlE+9bvwZKLudbV/hdkGeamZ0p9ZsyjaR X-Received: by 2002:a17:906:6a8e:: with SMTP id p14mr30585214ejr.137.1571086855058; Mon, 14 Oct 2019 14:00:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086855; cv=none; d=google.com; s=arc-20160816; b=fM6S2UUSvj8EARgb/T/uKGopyhHUZ7VkcQfNC568cNRXOhYQDkFYGsYJ5ronLk0+/a nBhF+pSTfPPhDzUcaL+UuKzjRPswnDed4+44aRkFbxwcQZQsi6KOYjjxNC2Xm3G9royl m0HsFuBi7FtmVhTKVxTCpC8DLrbxTIWfAB5O+EkttSt1bAC0+IHD5ZL2ZXflcEW9UYaJ EHpiGeAsO5mjSSvEIJRvkIL97T/AsnoJbVufJIfp/qSTTV8Yc99VqZSXR8rT5EUzFj6A wyBVYd6YqmfkhqfX485xoAdfafFCakg8qPaT3dc669o2zdhm8XEYFIRX9PX60HxL+37/ dfdg== 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=lXdbsQkWWDACSEjAuFKh3QeGElgNCcNc/y8sme5xdGw=; b=wPXeTRnf1HDfO3hppGcurXDQTb/Ptn3xnnZjLLHBZi+/3c+9jINZCjoPJNr9C6R52j JCpATxJRyigYsI+KmT20ottM5BwiVEq6nWQaAByL4fF6hkCUeNmIi10f0I4LPaXVow7l 1QvG7Zz2XGbQA01uUNxW/0cXOOO+B1NxE3XDE68aERQQXrY0jdPNA8/1CfsOWzM5x5kQ pM/AlIeEAn6YYoFuHM5FjQqN76A8TfuWbv3nLiZcMT/ebBEn9UnhyX5Fy3kfoLkFLvb3 1hhT2TFc8tFH3llLoW10s3h/M92vxQUF88WkS+pKu7e6PImrbbIkDMdv6YtUs6VOQ5Te 2xmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=RLF6ZnMq; dkim=pass header.i=@linaro.org header.s=google header.b=CbIO5f6U; spf=pass (google.com: domain of libc-alpha-return-105947-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105947-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 ng7si11915674ejb.91.2019.10.14.14.00.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 14:00:55 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105947-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=RLF6ZnMq; dkim=pass header.i=@linaro.org header.s=google header.b=CbIO5f6U; spf=pass (google.com: domain of libc-alpha-return-105947-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105947-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=Z4mF9NWwydSmmt3rOTThknqhmf+oPNG qxxU/1nN3bIKN/mGZ/Yjular6swsxuWnOyWlKO8s8K5QHli2CwHxn4Cr95qPNE0B q1M0DVxxS0/PrcMAri3mSvHpGnqh+2Sy3Ofu1Nhdxjmuz/Gl/yweAkH2XK+q7LhO IArUk4dK+sW4= 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=x3CgRLqtbCIlWARgE2YflvD6dkc=; b=RLF6Z nMqsBUr/V8tCvqXo5uGK6KV7tdFGayuqFh9kMwLW5nTqt0w6P2hAtO1V7bPzkskz dW6mgHZ1X+ZVWaaHJKrjNjGLs4Mt7zMRQg+yWimLBGnUf1V7uosBt7AN2ixDlijr M832+emfOar/hHGO1DUzCnLBvAyV3fGh0LznUg= Received: (qmail 118282 invoked by alias); 14 Oct 2019 20:57:49 -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 116696 invoked by uid 89); 14 Oct 2019 20:57:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 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= 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=lXdbsQkWWDACSEjAuFKh3QeGElgNCcNc/y8sme5xdGw=; b=CbIO5f6UWyvknVGlSpsLrGyi1QkErt2UTt9Enr4mhWYoqQ3HrvpXzHYzhpCsmq+/2y +62RxmedITWQEIVaHtrK73XSMP9ot/jqa0rkF45E8EpcrFV7JNJ0JrS7BCkebxSl8jtA czdTJzgmRr8waYtZ9uKtOnhtXVQJogLMl92dsdLxqmE+GYuhOcpxbhngmm9sKP1ngOK2 WrVvsBcrzxKG3YlvIhrAtSzTkdZ5Gy4kRg42nnWg/xkVqd8wGtcpDvA1djkmAaCU90qg JXtI3ufUSUd2qqJriW6XAAwKck1WlNaXt8xG2sMeIttpiHHn6U3pXmRZ9B9m/4KWQPBC bVkw== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 20/21] nptl: csky: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:55 -0300 Message-Id: <20191014205656.29834-21-adhemerval.zanella@linaro.org> In-Reply-To: <20191014205656.29834-1-adhemerval.zanella@linaro.org> References: <20191014205656.29834-1-adhemerval.zanella@linaro.org> This patch adds the csky modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. --- sysdeps/unix/sysv/linux/csky/syscall_cancel.S | 116 ++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/csky/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/csky/syscall_cancel.S b/sysdeps/unix/sysv/linux/csky/syscall_cancel.S new file mode 100644 index 0000000000..938f86a569 --- /dev/null +++ b/sysdeps/unix/sysv/linux/csky/syscall_cancel.S @@ -0,0 +1,116 @@ +/* Cancellable syscall wrapper. Linux/csky 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 + +/* long int __syscall_cancel_arch (int *cancelhandling, + __syscall_arg_t nr, + __syscall_arg_t arg1, + __syscall_arg_t arg2, + __syscall_arg_t arg3, + __syscall_arg_t arg4, + __syscall_arg_t arg5, + __syscall_arg_t arg6) */ + +#ifdef SHARED +# define STACK_ADJ 4 +#else +# define STACK_ADJ 0 +#endif + +ENTRY (__syscall_cancel_arch) + subi sp, sp, 16 + STACK_ADJ + cfi_def_cfa_offset (16 + STACK_ADJ) +#ifdef SHARED + st.w gb, (sp, 16) + lrw t1, 1f@GOTPC + cfi_offset (gb, -4) + grs gb, 1f +1: +#endif + st.w lr, (sp, 12) + st.w l3, (sp, 8) + st.w l1, (sp, 4) + st.w l0, (sp, 0) +#ifdef SHARED + addu gb, gb, t1 +#endif + subi sp, sp, 16 + cfi_def_cfa_offset (32 + STACK_ADJ) + cfi_offset (lr, -( 4 + STACK_ADJ)) + cfi_offset (l3, -( 8 + STACK_ADJ)) + cfi_offset (l1, -(12 + STACK_ADJ)) + cfi_offset (l0, -(16 + STACK_ADJ)) + + mov l3, a1 + mov a1, a3 + ld.w a3, (sp, 32 + STACK_ADJ) + st.w a3, (sp, 0) + ld.w a3, (sp, 36 + STACK_ADJ) + st.w a3, (sp, 4) + ld.w a3, (sp, 40 + STACK_ADJ) + st.w a3, (sp, 8) + ld.w a3, (sp, 44 + STACK_ADJ) + st.w a3, (sp, 12) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + ld.w t0, (a0, 0) + andi t0, t0, 4 + jbnez t0, 2f + mov a0, a2 + ld.w a3, (sp, 4) + ld.w a2, (sp, 0) + ld.w l0, (sp, 8) + ld.w l1, (sp, 12) + trap 0 + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + addi sp, sp, 16 + cfi_remember_state + cfi_def_cfa_offset (16 + STACK_ADJ) +#ifdef SHARED + ld.w gb, (sp, 16) + cfi_restore (gb) +#endif + ld.w lr, (sp, 12) + cfi_restore (lr) + ld.w l3, (sp, 8) + cfi_restore (l3) + ld.w l1, (sp, 4) + cfi_restore (l1) + ld.w l0, (sp, 0) + cfi_restore (l0) + addi sp, sp, 16 + cfi_def_cfa_offset (0) + rts + +2: + cfi_restore_state +#ifdef SHARED + lrw a3, __syscall_do_cancel@GOTOFF + addu a3, a3, gb + jsr a3 +#else + jbsr __syscall_do_cancel +#endif +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch)