From patchwork Tue Dec 10 18:32:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella X-Patchwork-Id: 1207199 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-107895-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="VFmpqYZN"; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="P7xCp/eg"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47XTFK2kXHz9sPK for ; Wed, 11 Dec 2019 05:32:37 +1100 (AEDT) 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; q=dns; s= default; b=AfIFVbdRdXTvksUnwOOI53hAHj2ub26NqwwQbTy+vrcsNX+rzxjzP o9CUzpuAuTNbxpZEaav+2FxSr8kqpwdXlGyVXlpfEt/fPBWMCGZp6JfEn8zwwyNS yTBE+2QoCbJdXNPMCBE6ZrMs9TCzQPklkFL8/tg1S31JDvJhwYRQEc= 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; s=default; bh=Htp7B2KJsq6MRpm/Nq94O77R6NI=; b=VFmpqYZNb5Vl0Svj2BvfpbIxC4j9 Fc92Tgpj8IxSSGQ4ortHmv8GyuC6uGzxWeAKUnadPbpgoEpfm47dpH/WDte+KNc6 Q73f2bC9TMzq+Np6rzg+RaTjS5ht1IKVebFbcDX08WfsZvIL78abhvcfNQnrM1y5 pl+sbnNC3coktwA= Received: (qmail 38862 invoked by alias); 10 Dec 2019 18:32:31 -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 38854 invoked by uid 89); 10 Dec 2019 18:32:30 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=sk:sparc64, __val X-HELO: mail-vk1-f193.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=G00okY5kT1CHVjY7jVSxw7mduRPANkNVsbtrUcq7sr4=; b=P7xCp/egUnjyUZQIQib+iAfYS+FTseZzY3OiW5ucZIQvW1+2pnyi8pmEMLRGx08QvA WtJypaegX/hBD9TM4lqkufyJ35WKKNSp1CRxannZQ3581o4ohW8kk5nlIDpWMiWYTlYA PtHPg2B9brqZ7HL0+VrGNshydpp+R1EMiqcnv98Xt9h85vY/2vmfYZH7tukRk8aZMPnJ rGI3biQ+uZAqKuAx4Haz2tIW0JluesAfxcyGRWiYClKie5Cw4mi6kGR768KjccQMmeJ8 iHT55QTxialOd4SYPo6ifmtwIb71c1auA+EzCutK8OKsfGWTepXWWsXC3ok/Zml4hfgJ 0Ytg== From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH v3 1/7] Fix __libc_signal_block_all on sparc64 Date: Tue, 10 Dec 2019 15:32:15 -0300 Message-Id: <20191210183221.26912-1-adhemerval.zanella@linaro.org> Changes from previous version: - Remove unrelated changes. --- The a2e8aa0d9e shows two regressions on sparc64-linux-gnu: nptl/tst-cancel-self-canceltype nptl/tst-cancel5 This is not from the patch itself, but rather from an invalid __NR_rt_sigprocmask issued by the loader: rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0 rt_sigprocmask(0xffd07c60 /* SIG_??? */, ~[], 0x7feffd07d08, 8) = -1 EINVAL (Invalid argument) Tracking the culprit it really seems a wrong code generation in the INTERNAL_SYSCALL due the automatic sigset_t used on __libc_signal_block_all: return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &SIGALL_SET, set, _NSIG / 8); Where SIGALL_SET is defined as: ((__sigset_t) { .__val = {[0 ... _SIGSET_NWORDS-1 ] = -1 } }) Building the expanded __libc_signal_block_all on sparc64 with recent compiler (gcc 8.3.1 and 9.1.1): #include int _libc_signal_block_all (sigset_t *set) { INTERNAL_SYSCALL_DECL (err); return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &SIGALL_SET, set, _NSIG / 8); } It seems that the first argument (SIG_BLOCK) is not correctly set on 'o0' register: __libc_signal_block_all: save %sp, -304, %sp add %fp, 1919, %o0 mov 128, %o2 sethi %hi(.LC0), %o1 call memcpy, 0 or %o1, %lo(.LC0), %o1 add %fp, 1919, %o1 mov %i0, %o2 mov 8, %o3 mov 103, %g1 ta 0x6d; bcc,pt %xcc, 1f mov 0, %g1 sub %g0, %o0, %o0 mov 1, %g1 1: sra %o0, 0, %i0 return %i7+8 nop Where is I define SIGALL_SET outside INTERNAL_SYSCALL macro, gcc correctly sets the expected kernel argument in correct register: sethi %hi(.LC0), %o1 call memcpy, 0 or %o1, %lo(.LC0), %o1 -> mov 1, %o0 add %fp, 1919, %o1 This patch fixes it by moving both sigset_t that represent all signals sets and the application set to constant data objects. Checked on x86_64-linux-gnu, i686-linux-gnu, and sparc64-linux-gnu. --- sysdeps/unix/sysv/linux/internal-signals.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/sysdeps/unix/sysv/linux/internal-signals.h b/sysdeps/unix/sysv/linux/internal-signals.h index 01d8bf0a4c..a496c7174c 100644 --- a/sysdeps/unix/sysv/linux/internal-signals.h +++ b/sysdeps/unix/sysv/linux/internal-signals.h @@ -22,6 +22,7 @@ #include #include #include +#include #include /* The signal used for asynchronous cancelation. */ @@ -53,15 +54,16 @@ __clear_internal_signals (sigset_t *set) __sigdelset (set, SIGSETXID); } -#define SIGALL_SET \ - ((__sigset_t) { .__val = {[0 ... _SIGSET_NWORDS-1 ] = -1 } }) +static const sigset_t sigall_set = { + .__val = {[0 ... _SIGSET_NWORDS-1 ] = -1 } +}; /* Block all signals, including internal glibc ones. */ static inline int __libc_signal_block_all (sigset_t *set) { INTERNAL_SYSCALL_DECL (err); - return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &SIGALL_SET, + return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &sigall_set, set, _NSIG / 8); } @@ -69,11 +71,11 @@ __libc_signal_block_all (sigset_t *set) static inline int __libc_signal_block_app (sigset_t *set) { - sigset_t allset = SIGALL_SET; + sigset_t allset = sigall_set; __clear_internal_signals (&allset); INTERNAL_SYSCALL_DECL (err); - return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &allset, set, - _NSIG / 8); + return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &allset, + set, _NSIG / 8); } /* Restore current process signal mask. */