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 Netto X-Patchwork-Id: 26084 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-Google-Smtp-Source: AG47ELt/dqk+K3TLDttBt5ctzAZ30Z2qSfte17plNpRL7iCTTqJSso7HslTuK8gXL12JhMZ+36J9zw== 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(-) 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