From patchwork Mon Oct 14 20:56:45 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: 176346 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp5012713ill; Mon, 14 Oct 2019 13:59:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7Pur/7UjQY2Eoku7lZ7f1+iAh4eaHqbqOHvRjqmUJTqDyrqaBRH9ttYm5VDd1yripiC4l X-Received: by 2002:a05:6402:b17:: with SMTP id bm23mr29727676edb.6.1571086750659; Mon, 14 Oct 2019 13:59:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571086750; cv=none; d=google.com; s=arc-20160816; b=HtmHLCAeDJ/yBBJxBWuzGYoIiqtCka41gKDur4tanTyIFEW8/H8t2bIIRb3/5FjWns zwAh26zYYx6SrjQMCBvfvzf9t+0qQSCjnNTd9lsqNpohh4kkp0X+hkwF4bKKiXpo6tpH EQzQRk7N6wMfkPfcdTnJOB2HbSfj3xl/h1g9wc6C5ZfTzN1SXzyd/6C6RB63HIF1XiJ/ +7Nvz118RHZ9QOkD7M5SGLRBqSk0ETE6N+hDPW9cObkICoBWGwpRC4KqnCK3rJLRVM7h a6NAJe+CHim4fNwaNxrxn8++z6b+9XKDcGurKyvF879QK1oprScaFj70FQoteXBmA/Zq TJfQ== 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=L48C2S2cuH3wIpZN+1UP2+S+B1Xql7b/cQD2SyE3JK0=; b=M+mROM6agu102efyFSs8t3R2VbQxqNsl9T520ccvjtXVXuHwTmrl9ydktGXrVZq8VU 2EzJrwR9PmRgmNu4Q3wPQekIGhfohSiZGJOKVhqK2AehJ8OPOWorhfzrBHeTStfWvir7 Q5RUlwFx+gpuBqptTa2tfLCwui3tIA+HzHfMEKxk9BwAMGcEciniJbfbBE80JpyTFf7V oNdkx2Urb6IDP8r7PBj7kcMrayapvrqYE0+iFaH75548N3C2qiY4A9DW+WF/0ghlw/CK 93LwWdmnjdIVa3hPeE66YB/AALmIrcDwSNie5x+8v9WVyxvSyl0ViGidF/ES8KwTHUwo yIwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=Du7aaz20; dkim=pass header.i=@linaro.org header.s=google header.b="X4+f/XVK"; spf=pass (google.com: domain of libc-alpha-return-105937-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105937-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 ca9si12241572edb.79.2019.10.14.13.59.09 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 14 Oct 2019 13:59:10 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-105937-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=Du7aaz20; dkim=pass header.i=@linaro.org header.s=google header.b="X4+f/XVK"; spf=pass (google.com: domain of libc-alpha-return-105937-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-105937-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=S3loXNZh8ys4bn0NA8WUg+d5WjvGEhE BBJe2GyHZ0n6tbC87WJcRQ9qilmVUg7pnIic+WOXJLzDZLT4sE4D5VLspRmO2cyw RzttvrgrYkTOlRIkCJxkbUekscxGG1Jc/lYk/ymMsU3yRRTcr7vxVo44fzyT4gsE Af4p8LC0ePRc= 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=yuaDoSlaZ4g6u0rPGEIL9PtYHw8=; b=Du7aa z20rwsC9eUvBckbPsCHx0z3zvXQDg5OepWV9XkFVTPaRlgQaAzPefpjEvriJh3sr pAzsFB3+/HGekWAK+W+oEtHonMZrdHFQ5u3YB9dw77G7+yU4b60cRvUQO3Ry4zmd OqakNQlITwkMCR/8LQGVpYERpzO+jt/q4nOOTI= Received: (qmail 115169 invoked by alias); 14 Oct 2019 20:57:25 -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 114986 invoked by uid 89); 14 Oct 2019 20:57:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.3 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-f177.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=L48C2S2cuH3wIpZN+1UP2+S+B1Xql7b/cQD2SyE3JK0=; b=X4+f/XVKLcWTph1unW2Tk2Ggknaj6NXdsUjivcstuHsJ/bljbG/jNp/DIEJn1JehbA ki6i0OdVNKtmxzNTnq3ktlS8M0YMyr2Ar9vrU8VM2+1YEB/czePsbJHzQ/yhbxRB2k8+ sxBJhwbEuWbcbleB11kjAJkYpy1PrygyTzRQ2E8frKF/RFlJvZYClNTeUFmcA+LnxujH Hu9TNzQ241cGMio4QBlshK7mmV8GMEfNUAqSPrq/x88rhxNGQPZZR5ZyXNAcSbT+IHE4 DuFOp8OV6pYU3wAiALuEEj9zR2I0reocqhk7JM00e2P1EsRkpTFw1NLhLid/MrOQf1KC Qa7w== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 10/21] nptl: powerpc: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 14 Oct 2019 17:56:45 -0300 Message-Id: <20191014205656.29834-11-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 powerpc modifications required for the BZ#12683 fix by adding the arch-specific cancellation syscall bridge. Checked on powerpc64le-linux-gnu, powerpc64-linux-gnu and powerpc-linux-gnu. --- sysdeps/powerpc/powerpc32/sysdep.h | 3 + sysdeps/powerpc/powerpc64/sysdep.h | 19 ++++++ .../unix/sysv/linux/powerpc/syscall_cancel.S | 67 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S -- 2.17.1 diff --git a/sysdeps/powerpc/powerpc32/sysdep.h b/sysdeps/powerpc/powerpc32/sysdep.h index c21ea87f5a..689a708740 100644 --- a/sysdeps/powerpc/powerpc32/sysdep.h +++ b/sysdeps/powerpc/powerpc32/sysdep.h @@ -101,6 +101,9 @@ GOT_LABEL: ; \ # define JUMPTARGET(name) name #endif +#define TAIL_CALL_NO_RETURN(__func) \ + b __func@local + #if defined SHARED && defined PIC && !defined NO_HIDDEN # undef HIDDEN_JUMPTARGET # define HIDDEN_JUMPTARGET(name) __GI_##name##@local diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h index db273f3346..fb6ede3e87 100644 --- a/sysdeps/powerpc/powerpc64/sysdep.h +++ b/sysdeps/powerpc/powerpc64/sysdep.h @@ -276,6 +276,25 @@ LT_LABELSUFFIX(name,_name_end): ; \ ENTRY (name); \ DO_CALL (SYS_ify (syscall_name)) +#ifdef SHARED +# define TAIL_CALL_NO_RETURN(__func) \ + b JUMPTARGET(__func) +#else +# define TAIL_CALL_NO_RETURN(__func) \ + .ifdef .Local ## __func; \ + b .Local ## __func; \ + .else; \ +.Local ## __func: \ + mflr 0; \ + std 0,FRAME_LR_SAVE(1); \ + stdu 1,-FRAME_MIN_SIZE(1); \ + cfi_adjust_cfa_offset(FRAME_MIN_SIZE); \ + cfi_offset(lr,FRAME_LR_SAVE); \ + bl JUMPTARGET(__func); \ + nop; \ + .endif +#endif + #ifdef SHARED #define TAIL_CALL_SYSCALL_ERROR \ b JUMPTARGET(__syscall_error) diff --git a/sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S b/sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S new file mode 100644 index 0000000000..66d601da2a --- /dev/null +++ b/sysdeps/unix/sysv/linux/powerpc/syscall_cancel.S @@ -0,0 +1,67 @@ +/* Cancellable syscall wrapper. Linux/powerpc 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 [r3] __syscall_cancel_arch (int *cancelhandling [r3], + long int nr [r4], + long int arg1 [r5], + long int arg2 [r6], + long int arg3 [r7], + long int arg4 [r8], + long int arg5 [r9], + long int arg6 [r10]) */ + +ENTRY (__syscall_cancel_arch) + + .globl __syscall_cancel_arch_start + .type __syscall_cancel_arch_start,@function +__syscall_cancel_arch_start: + + /* if (*cancelhandling & CANCELED_BITMASK) + __syscall_do_cancel() */ + lwz r0,0(r3) + andi. r0,r0,0x4 + bne- 1f + + /* Issue a 6 argument syscall, the nr [r4] being the syscall + number. */ + mr r0,r4 + mr r3,r5 + mr r4,r6 + mr r5,r7 + mr r6,r8 + mr r7,r9 + mr r8,r10 + sc + + .globl __syscall_cancel_arch_end + .type __syscall_cancel_arch_end,@function +__syscall_cancel_arch_end: + + bnslr+ + neg r3,r3 + blr + + /* Although the __syscall_do_cancel do not return, we need to stack + being set correctly for unwind. */ +1: + TAIL_CALL_NO_RETURN (__syscall_do_cancel) + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch)