From patchwork Mon Oct 14 20:56:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 176353 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5013969ill; Mon, 14 Oct 2019 14:00:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwEfMbMyUgHry9Pa6yXbIbvJQvhHMV9lpt76nnKpdEciA4cstCk+COWNdIE68PIGF+byBZl X-Received: by 2002:a17:906:6882:: with SMTP id n2mr31512153ejr.48.1571086825992; Mon, 14 Oct 2019 14:00:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086825; cv=none; d=google.com; s=arc-20160816; b=pGKGGED+9J3Cod0s1ak+SrsI+SUYiKUeE1qFWW4NfPin4mgIp92Fh0LlYK+62Rh38I 5VH5yiWyDwwD9qw12JOJ3LEiv3pODsuujUVEjoocT77yIHkfVti/jd5PkH8e+9E/bVec V0Bw7T771gTy6UVmK7DzjzglUUzrQiepJ2ODasKQX9FTsPcV4SQeCaxkkZkcGXolV4p1 sf7Fpy8xl+cXEopN5KiXWl3O9cEGMOsAF7x4vw07LCYk5A9kO311fhOBsGPYGoaAIdxt B+kehyQjkDHHuLyryqkodA3Oipy5+vLmbgkept8AFFhnQssoxeEDKGgVm9EM1iYbICzT 0GtQ== 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=Bb3XFwgEFpIZHXL6UhnYqGlJqOnVvYI1EdHMRoQjGFs=; b=r8fuPq8QeWuStwdqNPQLFpMjiaQzke1Sxf2OVRP9sJAE5h3p6Y5C3DHgrdrW5OvpW0 KO8nL96Ts3fD+3BJODH/9z4hvxc1HbMUk8xcQ+Ij2h1cEzNDYOr/REnQ/I0073O+wXT8 Ts5kKXecoVpOAzIGswVcaPSvLUI7X9pwmYSx0YocUIA6j2uRWkAK4SChoKdUhtOeZ6Oz bAcXgA25tBj9Jbl/Wuzi4u6DTpchDol7QBV/7XztkcOnHpe/1VwBInqQmNx6QtrngDE1 6xTV9g4c1eC1sTEN07x99X4y0FqdjsEj01U0ueYgQAp9hLvkgqz/Ewc5XGioYK66uhx1 FePQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=u0v2R1S+; dkim=pass header.i=@linaro.org header.s=google header.b=tU0Vfkdo; spf=pass (google.com: domain of libc-alpha-return-105944-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105944-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 b11si11679385eja.38.2019.10.14.14.00.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 14:00:25 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105944-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=u0v2R1S+; dkim=pass header.i=@linaro.org header.s=google header.b=tU0Vfkdo; spf=pass (google.com: domain of libc-alpha-return-105944-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105944-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=SZYQL0UYxXxnBeKlHeXf5sDHd+sHMkV AujFLVwFDd8JbKb98f8pmDbfTpvKX68LjMlgj3BS1lt9AITesn1ZssO6UWllT79g hoffoixegypMSKbllVZFWmRUctlR4IIrZQgglQqrWv6+IA+Cup8Fafayjum7fSVA SALwuDiYGlfE= 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=HGMDK3EgUOFDiX3clxlpKlm+7LE=; b=u0v2R 1S+yBJT0f6ULZJwmszWrhhhI24TUS1jiw1/Zk5itvqN8yPtqNt86j7UnxBFVlKVl pTEdgNfWxPYuZ0yC/XVbVZaDrimyq+L6wgGK/ulNVEYad9O/z/IzCg8cy902zZqQ izUThDsujGozIuyGIuDlPrKrtqJ4KN8+X9fqL8= Received: (qmail 116801 invoked by alias); 14 Oct 2019 20:57:37 -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 116223 invoked by uid 89); 14 Oct 2019 20:57:33 -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-qk1-f193.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=Bb3XFwgEFpIZHXL6UhnYqGlJqOnVvYI1EdHMRoQjGFs=; b=tU0VfkdoKSFibeDsKcD93aI0u77YfRL0mTT6ZKJZAky8kNj/B/RhbMSCE9Y+rMn44c c65Uew4FvagH76hpvokv8qN/4jXGL81nr7QH1uwxPgef5ozMz3hKJ44fzdh0DVMLD9CA INt2OAC7ec495OEWVRe6ULUAAamVdS/HWwoOMtavJj2e9uMP5VugoYcCVphqFa9E/tmD moOCT8QDy9IedFvQGtvntsMTf3wB4oxYqtnEx15MsIgEtdEjo91bUihROIghXfnLoNFe dUGOlSq7uBEfnTwsAVO31wNPT6MG0NTjuBDsiT6nFV1JlweNi75rbcMTlVchVg1Xt85W rp2g== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 17/21] nptl: riscv: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:52 -0300 Message-Id: <20191014205656.29834-18-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 riscv modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. --- .../unix/sysv/linux/riscv/syscall_cancel.S | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/riscv/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/riscv/syscall_cancel.S b/sysdeps/unix/sysv/linux/riscv/syscall_cancel.S new file mode 100644 index 0000000000..38fd630c6d --- /dev/null +++ b/sysdeps/unix/sysv/linux/riscv/syscall_cancel.S @@ -0,0 +1,68 @@ +/* Cancellable syscall wrapper. Linux/riscv 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 + .option pic +#else + .option nopic +#endif + +ENTRY (__syscall_cancel_arch) + mv t1, a7 + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + lw a7, 0(a0) + andi a7, a7, 4 /* if (*ch & CANCELED_BITMASK) */ + bnez a7, 1f + + mv a7,a1 + mv a0,a2 + mv a1,a3 + mv a2,a4 + mv a3,a5 + mv a4,a6 + mv a5,t1 + scall + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + ret + +1: + addi sp, sp, -16 + cfi_def_cfa_offset (16) + sd ra, 8(sp) + cfi_offset (ra, -8) + call __syscall_do_cancel + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch)