From patchwork Mon Dec 11 19:06:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 24866 Received: (qmail 41774 invoked by alias); 11 Dec 2017 19:07:28 -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 41730 invoked by uid 89); 11 Dec 2017 19:07:27 -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=s390xlinuxgnu, s390x-linux-gnu, ahi X-HELO: mail-qt0-f173.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=Rqh/D9W65fMFC1DYB2ohJ5K3qjrQCvLICpkdWuaqyOo=; b=ocyaFE3bTVmR52qFW/VOJokwSaxpG4dSW88rsVvB7uTiXhMfI8+mRUeJIz/FnUw7Ie GM0JUNvzk19k29CKSIaK+mBGBVT88FrSUD9ygGNmnyfdgUpPHYh01RSoTM+eSzi/9ng2 9G69jg3oUJqI8q8VCP1lFUKEGkQinWBELcB6RzFqIAvZAoymWAgzPF/jvn8aUbau5CJm ckF/dWn7mybh6cIKdNE94ru+OM4dOS2978V8b7VDC0b3MutBQp0fNEtySeHj5/t7IHJq G/+HDOeTV3w4GRW60sVjOeF+0eL8BTHM+b+Sd6xfqr7Isr1eklHYFwmS5UxWF+Ko7CiH WjgA== X-Gm-Message-State: AKGB3mI1M4nxINtNYVR+7hM1RJYVeplcFs25eKF4JAUrLraij/m4LUt8 Dr5besYya6ftufTAWGKrKDW+EpMfx8U= X-Google-Smtp-Source: ACJfBosFAl7a5I8V0jt4PVDCS8dYX3/jt1edXNwkLksd9/nE5wjRWeJH6GH1sobvfw3avurEs7Q7kw== X-Received: by 10.55.25.22 with SMTP id k22mr1883148qkh.120.1513019244012; Mon, 11 Dec 2017 11:07:24 -0800 (PST) From: Adhemerval Zanella To: libc-alpha@sourceware.org Cc: Adhemerval Zanella Subject: [PATCH 09/19] nptl: s390: Fix Race conditions in pthread cancellation (BZ#12683) Date: Mon, 11 Dec 2017 17:06:53 -0200 Message-Id: <1513019223-7603-10-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> 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. * sysdeps/unix/sysv/linux/s390/sigcontextinfo.h (ucontext_get_pc): New function. --- ChangeLog | 3 +++ sysdeps/unix/sysv/linux/s390/sigcontextinfo.h | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/sysdeps/unix/sysv/linux/s390/sigcontextinfo.h b/sysdeps/unix/sysv/linux/s390/sigcontextinfo.h index 90ead3f..676a8bd 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