From patchwork Mon Feb 26 21:03:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 129712 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp4291352edc; Mon, 26 Feb 2018 13:05:50 -0800 (PST) X-Google-Smtp-Source: AH8x226dAtQk+LFCtKzpYHH+B4nCpp2irAJRPyuOGaeWO/TR51L7KhcdI7fv5iF59Y098fQ63QkN X-Received: by 2002:a17:902:9a41:: with SMTP id x1-v6mr11681450plv.256.1519679150490; Mon, 26 Feb 2018 13:05:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519679150; cv=none; d=google.com; s=arc-20160816; b=g6/m22JkxqJhyYCmWpNzKfTx1LMb1MG3B+r1N8IoAfaKD3qMG72VDI8O3O3Zn+rcdg OKhys6cNRmdkAoc2aJ+C85cFCpcqj1STq9LEUAyVQsjoHuZL53W3Odd+eWK8uAZs+CIk a582twEnY8SrOLFHlIRPPf72Gl3IVTJUgw0nhQV4z3f1wGhk3/MdEvyFuxZsLGnypBGc SbtfMcaExAmqbgztCpzt32vqqNy4wFnsUbBICHsavdz29Bp0r96zcN1VLeRBoHtrrBYc lrkuXVZd1jkxS+8sXSDvb0+Bp2cu5jeXyWxsRnBKWP5L0cT7BL/dnn8UfPgpTJ9wbv3X /jLQ== 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:cc: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=Hfqb4riE7MSKiPugo9tCu8rbfM5T4BR4JnxqyvmSmnc=; b=VKtTLSmGIe2dIOsq5NfvRk0AeZxlZ+hh5UdAtiYAEHmPj9VJs75Q3NKwfUaSodbxO4 3CwjsaSzoaCVfyXiZ6k/WAjQGPcTJEF2hud5XDYbNGiqviPVtj7vn6ghl6D6bMO/tBgb ubVoMCAfktybeev+ssNhkIm9a3rMnNpmqeJKROx+8V6nAK46iYqrZ7vn3tse8jITyg8a D9kIMEeFL5MTF+8g2Gav5GgYWHbvZL+3UQYeQhE+aCWCDZPZCVQTds3U3wgYEMOTCwQq 9+Mi0Vg8ToMcTPVn569OUTEpUgZWuGTs+1j+9EgGXJ6YjuspzcbUmOCoogmfo7Q7CcW4 FGwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=xbqQeAzf; spf=pass (google.com: domain of libc-alpha-return-90627-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-90627-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 x5si6007555pgq.437.2018.02.26.13.05.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2018 13:05:50 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-90627-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=xbqQeAzf; spf=pass (google.com: domain of libc-alpha-return-90627-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-90627-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:cc:subject:date:message-id:in-reply-to :references; q=dns; s=default; b=mqBrz5T78Pzu+/NcFrRl1k6TGTl3Dd+ yEgm/q14hH+V9b+Yw+mRO/lkFXLAYCtedb/x5TeZIZkiIA6qRzwTRimAC6IO8WIh DYWOcCm5VPOLmn+lKYcVh3xGGAX1BT8Mw84JcEB/UWG6J4coQcUxJr8l/aZWstE3 FevINcKTZD4E= 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=ffhvcb1vl2mLoEvF+DVdWmTkKqw=; b=xbqQe AzftOCp+CtY8/Fx/Rnz9KwZNQnFbPhDDR8uQH5eZxgMy2VFNaEl2tMPOgmqbxaVG T/7d0+0VignOYf4qASRTYWcxmPBnD8GOysOAxxo1WTm0LK7D49BjA3ZH2+YCmAv5 ATE4bnGLphdh46XegmAJCjCO8Vx+JOvSBjXzd8= Received: (qmail 76450 invoked by alias); 26 Feb 2018 21:04:04 -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 76243 invoked by uid 89); 26 Feb 2018 21:04:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.0 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-f175.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:cc:subject:date:message-id:in-reply-to :references; bh=Hfqb4riE7MSKiPugo9tCu8rbfM5T4BR4JnxqyvmSmnc=; b=MImxgBrshO+LLwzLhrQNXv+QYj0wSZIVkwG4vPSZfbTgb1SS+QMPUku4t+1z8abn72 VwWZZ0+WtMFtTjA3svO1ld3Cu5ppHdue/MSTBlrhStjgBuH92GSLOriiGyocFdxmPkdJ vAQwUftqbmYQpu011yxptVIQdOfcJTpXxXBF661o8RdEOjyLu3qNyhXwmhk5nUGLqsSg 3RCY/riLCX5BQ++gIQohdAoCG2RSYuazgNOhB4Bfe7mU7QBvEAQyqQW/UYEOAt2JdRhC bfpJqBuYmicxFJslhzpviHpMwDJiJrb/fiTsM+tbKg36d3bjS99nXspw9fpgB5WL1M1G wOoQ== X-Gm-Message-State: APf1xPDCUS/1p8uEfbYtvZlUBpds+Ot4IVJXKqHYb/bWUUOKD2Q4cjdx KQkF4zKXd9P4lrHbQuohoxFntMKH7X4= X-Received: by 10.200.43.21 with SMTP id 21mr18868516qtu.98.1519679039193; Mon, 26 Feb 2018 13:03:59 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Adhemerval Zanella Subject: [PATCH v2 10/21] nptl: s390: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 26 Feb 2018 18:03:25 -0300 Message-Id: <1519679016-12241-11-git-send-email-adhemerval.zanella@linaro.org> In-Reply-To: <1519679016-12241-1-git-send-email-adhemerval.zanella@linaro.org> References: <1519679016-12241-1-git-send-email-adhemerval.zanella@linaro.org> From: Adhemerval Zanella This patch adds the s390 modifications required for the BZ#12683 fix. It basically adds the required ucontext_get_pc function. The built cancelable syscall wrapper for s390 using GCC 7.2.1 and default configuration flags shows the wrappers on expected corrected places: --- __GI___syscall_cancel_arch: .LFB39: .cfi_startproc stm %r6,%r15,24(%r15) .cfi_offset 6, -72 .cfi_offset 7, -68 .cfi_offset 8, -64 .cfi_offset 9, -60 .cfi_offset 10, -56 .cfi_offset 11, -52 .cfi_offset 12, -48 .cfi_offset 13, -44 .cfi_offset 14, -40 .cfi_offset 15, -36 ahi %r15,-96 .cfi_def_cfa_offset 192 .global __syscall_cancel_arch_start .type __syscall_cancel_arch_start,@function __syscall_cancel_arch_start: l %r0,0(%r2) tml %r0,4 jne .L5 lr %r1,%r3 lr %r2,%r4 lr %r3,%r5 lr %r4,%r6 l %r5,192(%r15) l %r6,196(%r15) l %r7,200(%r15) svc 0 .global __syscall_cancel_arch_end .type __syscall_cancel_arch_end,@function __syscall_cancel_arch_end: l %r4,152(%r15) lm %r6,%r15,120(%r15) .cfi_remember_state .cfi_restore 15 .cfi_restore 14 .cfi_restore 13 .cfi_restore 12 .cfi_restore 11 .cfi_restore 10 .cfi_restore 9 .cfi_restore 8 .cfi_restore 7 .cfi_restore 6 .cfi_def_cfa_offset 96 br %r4 .L5: .cfi_restore_state brasl %r14,__syscall_do_cancel .cfi_endproc --- The s390x version also shows similar placement: --- __GI___syscall_cancel_arch: .cfi_startproc stmg %r6,%r15,48(%r15) .cfi_offset 6, -112 .cfi_offset 7, -104 .cfi_offset 8, -96 .cfi_offset 9, -88 .cfi_offset 10, -80 .cfi_offset 11, -72 .cfi_offset 12, -64 .cfi_offset 13, -56 .cfi_offset 14, -48 .cfi_offset 15, -40 aghi %r15,-160 .cfi_def_cfa_offset 320 .global __syscall_cancel_arch_start .type __syscall_cancel_arch_start,@function __syscall_cancel_arch_start: l %r0,0(%r2) tmll %r0,4 jne .L5 lgr %r1,%r3 lgr %r2,%r4 lgr %r3,%r5 lgr %r4,%r6 lg %r5,320(%r15) lg %r6,328(%r15) lg %r7,336(%r15) svc 0 .global __syscall_cancel_arch_end .type __syscall_cancel_arch_end,@function __syscall_cancel_arch_end: lg %r4,272(%r15) lmg %r6,%r15,208(%r15) .cfi_remember_state .cfi_restore 15 .cfi_restore 14 .cfi_restore 13 .cfi_restore 12 .cfi_restore 11 .cfi_restore 10 .cfi_restore 9 .cfi_restore 8 .cfi_restore 7 .cfi_restore 6 .cfi_def_cfa_offset 160 br %r4 .L5: .cfi_restore_state brasl %r14,__syscall_do_cancel .cfi_endproc --- Checked with a s390-linux-gnu and s390x-linux-gnu build with run-tests-built=no. [BZ #12683] * sysdeps/unix/sysv/linux/s390/sigcontextinfo.h (ucontext_get_pc): New function. --- ChangeLog | 5 ++++- sysdeps/unix/sysv/linux/s390/sigcontextinfo.h | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/s390/sigcontextinfo.h b/sysdeps/unix/sysv/linux/s390/sigcontextinfo.h index 2533e63..89e6c47 100644 --- a/sysdeps/unix/sysv/linux/s390/sigcontextinfo.h +++ b/sysdeps/unix/sysv/linux/s390/sigcontextinfo.h @@ -16,7 +16,11 @@ License along with the GNU C Library; if not, see . */ +#ifndef _SIGCONTEXTINFO_H +#define _SIGCONTEXTINFO_H + #include +#include #define SIGCONTEXT struct sigcontext * #define SIGCONTEXT_EXTRA_ARGS @@ -25,3 +29,16 @@ #define GET_STACK(ctx) ((void *)((ctx)->sregs->regs.gprs[15])) #define CALL_SIGHANDLER(handler, signo, ctx) \ (handler)((signo), SIGCONTEXT_EXTRA_ARGS (ctx)) + +static inline uintptr_t +ucontext_get_pc (const ucontext_t *uc) +{ +#ifdef __s390x__ + return uc->uc_mcontext.psw.addr; +#else + /* We have 31bit addresses, remove bit 0. */ + return uc->uc_mcontext.psw.addr & 0x7FFFFFFF; +#endif +} + +#endif