From patchwork Mon Dec 11 19:06:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 121450 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3169757qgn; Mon, 11 Dec 2017 11:10:23 -0800 (PST) X-Google-Smtp-Source: ACJfBotySwrheanW9xZ8kOK5PJS2MSb3pxaHdTiASqdeX99yQu/BCXdpfi7oVbpZ3PKNdbIctZYL X-Received: by 10.84.246.140 with SMTP id m12mr1324823pll.74.1513019423545; Mon, 11 Dec 2017 11:10:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513019423; cv=none; d=google.com; s=arc-20160816; b=StFPiGx5/ZolxZQMqIbO01da0mA9uaxH1ngSm++EK5/hnDrKcECJiApftsw/dbySqC rqmYK1SuA7mwLlHrhjrU4fMmby5F3so3jrJWhTJCIM6oXPq/wVpgKu9bX27Mp0qjtKD+ mDxXeDrukfixsKFaNfTqRUzEYPffwdX+e1EE/KTEb3F5sum78VVD6SB3e2r4bSQIBNZw XlaHuR70GK1IxFAj4SL9Pc4WREZwgOymdtEN2ek/Af4meAHti4L/Ru6SygazhkU9PWKV 0w1arQvnzNO2UHiw/a6bh/Mkq3f8SfgofVxEGhwi44sJ7/Z6iEtfUCVJU0GGiB7xLmta RVUA== 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:delivered-to :sender:list-help:list-post:list-archive:list-subscribe :list-unsubscribe:list-id:precedence:mailing-list:dkim-signature :domainkey-signature:arc-authentication-results; bh=5fazUPsSgIOWb37B7JQqreRsk9dmR3gz0IzIGgly+c0=; b=qrCxwOUontjgdtgl6Ytln++/inN+c+y4cK1oVZYjGIR2+DVre5n9JMkM+tlAxRPbh6 0Upy9SQUXPvCU+p+lcU4oVUPv6fLD9tiWV+l/ORbJ7+gNhdpL2nrkIykHH/J/dCKWEQ/ t86GqggMJe0LSDo5fevPUaDJtffxOIHOHQJa4XWFlMKmI9rvRGUjqde/D+h9B5aOuZQs M3jk+CUBLnMdvaNQVzdNpckl4f/HY+0OzRDtZTg0v1A1b0BoS293UiQjKkPnTqYR7If7 Q7PkJj41hYdgHuesE1TrN0Z60for6S9RHOYAqo5Axq/7gg9ipo9x/uuJMFJSolQvmEvC ApYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=GUdHS37Y; spf=pass (google.com: domain of libc-alpha-return-88027-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-88027-patch=linaro.org@sourceware.org; dmarc=fail (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 d12si3744771plr.775.2017.12.11.11.10.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Dec 2017 11:10:23 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-88027-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=GUdHS37Y; spf=pass (google.com: domain of libc-alpha-return-88027-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-88027-patch=linaro.org@sourceware.org; dmarc=fail (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=GxIPOWmw/GVsoDiY6yk6Jfsi5SqPNMY 3VQx2FEoW6VT2ibB7oxwMdaxu7ZNoE2QwcTmmA4tXhgCOVR1QiRpKHBvkDN8cOVT E4gmP3a/OoRsK8TMGRRlcfeypwL5KWlBRcGveWRNa78EUZUO6jMCAmV2Nmeac3wH miEe0/KpY0oM= 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=GG8GNuhn1eBGnVR14TI4+2BNEKk=; b=GUdHS 37Y3mTWw2TkHaWZ6G/5stIFiPtZTbO1CmSf87nLOSddHC+/D9kjfasZn0Mokestu soJiLsueI6AVhEInHSF3ih2XNPX0a+0XuA0AQ5fseb/yVLP0VMSJk9sdYhH/Qekg bm9nBEsqLtRYVU4KOOljeoOxBvVidHjiVqsqQ8= Received: (qmail 42414 invoked by alias); 11 Dec 2017 19:07:33 -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 42383 invoked by uid 89); 11 Dec 2017 19:07:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.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.2 spammy= X-HELO: mail-qt0-f196.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=5fazUPsSgIOWb37B7JQqreRsk9dmR3gz0IzIGgly+c0=; b=UiHFA7zhUE6k2HY+xOyBhtwW9AvZAeA1INDujXOSalmwr1zaZVmAbLyAiRn32n5GB6 FSdl2p5E/lP4YL3mgvk3DESpyXLilBURjA/ZwX7Q9MZ63rQ+jHUah0zDNRRjnYbKg8Jh PTOffE2TH0VTbKTxAnF7syHNDvghMFmkUP5NV+S3Y6YVD9QIZrFMA2iXbeOoS79CXdbU wuJgbHFmp8One1djWXO23B2lxUX5/6g8t/X9KZFVqAKrJFaJaeSJXLdoDLMVvQQIr84S dMZX8dur8kcgV2XLNVaeHE6sVirbPZFU4uuyyZmNPpxY1AS2KFM3u1Axf96/eXSAOBAQ TmJQ== X-Gm-Message-State: AKGB3mJsuxPYpDj94mK1niRyverL+A6uyMzOwB1dK7sTYXZiMrqfhSNB rP4bCLzRkBa2f23jPMNplJ1+NcqyMn0= X-Received: by 10.55.4.136 with SMTP id 130mr1924892qke.203.1513019249723; Mon, 11 Dec 2017 11:07:29 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 13/19] nptl: microblaze: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 11 Dec 2017 17:06:57 -0200 Message-Id: <1513019223-7603-14-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1513019223-7603-1-git-send-email-adhemerval.zanella@linaro.org> References: <1513019223-7603-1-git-send-email-adhemerval.zanella@linaro.org> This patch adds the microblaze modifications required for the BZ#12683. It basically adds the required ucontext_get_pc function. Microblaze requires an arch specific assembly implementation because the archicture INTERNAL_SYSCALL_NCS implementation adds a nop after the brki instruction because the instruction expect a delay branch slot. I based this implementation on generated assembly using GCC 6.1. Checked against a build and make check run-built-tests=no for microblaze-linux-gnu. * sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S: New file. * sysdeps/unix/sysv/linux/microblaze/sigcontextinfo.h (ucontext_get_pc): New function. Signed-off-by: Adhemerval Zanella --- ChangeLog | 4 ++ .../unix/sysv/linux/microblaze/sigcontextinfo.h | 13 +++++ .../unix/sysv/linux/microblaze/syscall_cancel.S | 62 ++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100644 sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/microblaze/sigcontextinfo.h b/sysdeps/unix/sysv/linux/microblaze/sigcontextinfo.h index 145b3cb..1708937 100644 --- a/sysdeps/unix/sysv/linux/microblaze/sigcontextinfo.h +++ b/sysdeps/unix/sysv/linux/microblaze/sigcontextinfo.h @@ -16,6 +16,11 @@ License along with the GNU C Library; if not, see . */ +#ifndef _SIGCONTEXTINFO_H +#define _SIGCONTEXTINFO_H + +#include + #define SIGCONTEXT int _code, ucontext_t * #define SIGCONTEXT_EXTRA_ARGS _code, #define GET_PC(ctx) ((void *) (ctx)->uc_mcontext.regs.pc) @@ -23,3 +28,11 @@ #define GET_STACK(ctx) ((void *) (ctx)->uc_mcontext.regs.sp) #define CALL_SIGHANDLER(handler, signo, ctx) \ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx)) + +static inline uintptr_t +ucontext_get_pc (const ucontext_t *uc) +{ + return uc->uc_mcontext.regs.pc; +} + +#endif /* _SIGCONTEXTINFO_H */ diff --git a/sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S b/sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S new file mode 100644 index 0000000..d892362 --- /dev/null +++ b/sysdeps/unix/sysv/linux/microblaze/syscall_cancel.S @@ -0,0 +1,62 @@ +/* Cancellable syscall wrapper. Linux/microblaze version. + Copyright (C) 2017 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, + long int nr, + long int arg1, + long int arg2, + long int arg3, + long int arg4, + long int arg5, + long int arg6) */ + +ENTRY (__syscall_cancel_arch) + + .globl __syscall_cancel_arch_start +__syscall_cancel_arch_start: + + lwi r3,r5,0 + andi r3,r3,4 #and1 + bneid r3,1f + addk r12,r6,r0 + + addk r5,r7,r0 + addk r6,r8,r0 + addk r7,r9,r0 + addk r8,r10,r0 + lwi r9,r1,56 + lwi r10,r1,60 + brki r14,8 + + .globl __syscall_cancel_arch_end +__syscall_cancel_arch_end: + + nop + lwi r15,r1,0 + rtsd r15,8 + addik r1,r1,28 + +1: + brlid r15, __syscall_do_cancel + nop + +END (__syscall_cancel_arch) +libc_hidden_def (__syscall_cancel_arch) +