From patchwork Thu Dec 5 14:35:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 180891 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp2053815ile; Thu, 5 Dec 2019 06:35:47 -0800 (PST) X-Google-Smtp-Source: APXvYqzMnT+mqwUevRWa6CcQEK2/Xuu56WNr9oS413bIlwqta1TmN+5789OVMRghnLie3SJEzsms X-Received: by 2002:a05:6808:b18:: with SMTP id s24mr7140778oij.31.1575556546225; Thu, 05 Dec 2019 06:35:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575556546; cv=none; d=google.com; s=arc-20160816; b=kMOGTMRsw+F+TTKbTkIjQ9DdpSqE9w1ljmjd6WD2fn9ef4nV2ydgOFGJigY5NTHLqw FnFXAzGXwMRWBzrQQbCWAz5WIvw8krL3LOx1pyWSE1uhFZStZcoVumPs+WI47kzke+DP iOhp2OFByZQCPHlOokXglH5cGlr2QFA65HnJAqRk3CLBYlMPg9Ks/NelzP9YK+fCoDlc DfEnlqY47jShXk9RzN00CehHSNh99cXPhkqHSOPzk2QsiHEQ7evXTP5Kpxo9CGtSE3qy 9/FU2++Ce8MqlOQjTiJwgCOxTQend3aeFSxEn+f7MC65VToT9HqSKuuOpFvV4Q5qf16r Z9SQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:to:from:dkim-signature:delivered-to:sender :list-help:list-post:list-archive:list-subscribe:list-unsubscribe :list-id:precedence:mailing-list:dkim-signature:domainkey-signature; bh=2BRGH39fRepHnRNz2cWupf5L1kFvjAcWTF7jdelXjMU=; b=IbXAicmeLGdYLalZQ+RedrRPFWccdLR1p41epQktzqCBFQLVAiuZW2PSKfj79sWrYz o/ngQr9Muvvq6HMEPzdzu1DBB81C97RQOlPSgObk14QJ4Yj5fOnsDr1yusuUP/yMkb+7 WfUNzsAp2XmStqThQH0eA80jI/lU9a/P9BjC1FFQUwZOyAhRYaKRs3TftH9tQ7onisM9 1jdM2ZJhkEwijrbIVPW0HLTCG7wla8U0eNdLrfwMwLhwBpPlP8UJk5znnbBd2jAM7Hoe PVzjsUbuFNZxc8d9vTIrU/yw8ESYM+Bjg8rCIB47GmJxaZ4jWdR0kIr2qaLdtH3KEWN3 GQHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=YhojYzt8; dkim=pass header.i=@linaro.org header.s=google header.b=pK4fPbO7; spf=pass (google.com: domain of libc-alpha-return-107740-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107740-patch=linaro.org@sourceware.org"; dmarc=pass (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 s14si4703936otq.37.2019.12.05.06.35.46 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Dec 2019 06:35:46 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-107740-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=YhojYzt8; dkim=pass header.i=@linaro.org header.s=google header.b=pK4fPbO7; spf=pass (google.com: domain of libc-alpha-return-107740-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107740-patch=linaro.org@sourceware.org"; dmarc=pass (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; q=dns; s= default; b=j8HCNoJW0YLl6L26Hs2s00B/k0NQ82ODjfN1X+nV7Uf85thX0/V3O lfJ7ewZcrVWitKFRBAMsdrRuo4Ya8yujwTNAxznLcWfEvxlB+6JB/kttPa6bWysT vtEJ8zPQuUMmVGLcSbxDUdV4xbL+N+njVcNj74lQI+dF5Xzs7/Z7TY= 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=Drnl4mgcDZITwW74RB2zyL5FkGQ=; b=YhojYzt8NrXz3eyMTRRK/Ha+U26z oqAFiLmxMq/VF1B7RYxQ8l1FWd9DCVFiZ9EgFbrQFGTauTQIyGaBjgSuQFp4QE9L PyC1fDyM67IQbknzsNA8KRnfo3/uOhSt9CkOoQl2FmdcYX3xOQuH8313OKe8TrLs TSD6CJeDCAmD5hY= Received: (qmail 8690 invoked by alias); 5 Dec 2019 14:35:36 -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 8677 invoked by uid 89); 5 Dec 2019 14:35:35 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-21.4 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:INTERNA, sk:sparc64, communicate X-HELO: mail-ua1-f68.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=2BRGH39fRepHnRNz2cWupf5L1kFvjAcWTF7jdelXjMU=; b=pK4fPbO76/0zDOCpv4plh6S1JnSPV4w5DYhN7unleRy+J2aPx/Bz90fZqBB2vd0zwK 7uNpLoVDBfROv4ImsXD1LZgw5BfLAYfjLpC1T7UHF0NVhZXPrrVmMinQXEoLfsw2kLwU tym67vGlX8VK6mCjJ2pvql3ffMCnEzqFhtsWIOPL48eI9AfjXhwi1+3dITT2Jih9OyyE 7akWGKPNMbaxKbrSjpmYnmQthWhNrlgcg5Ki0T7qdNvSucqbahNWBZA4TQL+l1VQEgQ8 63CTWdt0LC8jjTIzFFLXIkQL8YMylA+SXn638Vp8hXy/Ip48uXNwuyjPqV0N1NLVeP1E OAgQ== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH] Fix __libc_signal_block_all on sparc64 Date: Thu, 5 Dec 2019 11:35:26 -0300 Message-Id: <20191205143526.27478-1-adhemerval.zanella@linaro.org> 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 also changes the return value of __libc_signal_block_all, __libc_signal_block_app, and __libc_signal_restore_set to 'void' since the function should not fail if input argument is NULL. Also, for Linux the return value is not fully correct on some platforms due the missing usage of INTERNAL_SYSCALL_ERROR_P / INTERNAL_SYSCALL_ERRNO macros. Checked on sparc64-linux-gnu. --- sysdeps/generic/internal-signals.h | 12 ++++++------ sysdeps/unix/sysv/linux/internal-signals.h | 19 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/sysdeps/generic/internal-signals.h b/sysdeps/generic/internal-signals.h index a515e3e649..41c24dc4b3 100644 --- a/sysdeps/generic/internal-signals.h +++ b/sysdeps/generic/internal-signals.h @@ -34,28 +34,28 @@ __clear_internal_signals (sigset_t *set) { } -static inline int +static inline void __libc_signal_block_all (sigset_t *set) { sigset_t allset; __sigfillset (&allset); - return __sigprocmask (SIG_BLOCK, &allset, set); + __sigprocmask (SIG_BLOCK, &allset, set); } -static inline int +static inline void __libc_signal_block_app (sigset_t *set) { sigset_t allset; __sigfillset (&allset); __clear_internal_signals (&allset); - return __sigprocmask (SIG_BLOCK, &allset, set); + __sigprocmask (SIG_BLOCK, &allset, set); } /* Restore current process signal mask. */ -static inline int +static inline void __libc_signal_restore_set (const sigset_t *set) { - return __sigprocmask (SIG_SETMASK, set, NULL); + __sigprocmask (SIG_SETMASK, set, NULL); } diff --git a/sysdeps/unix/sysv/linux/internal-signals.h b/sysdeps/unix/sysv/linux/internal-signals.h index 01d8bf0a4c..0a5faf175f 100644 --- a/sysdeps/unix/sysv/linux/internal-signals.h +++ b/sysdeps/unix/sysv/linux/internal-signals.h @@ -57,32 +57,33 @@ __clear_internal_signals (sigset_t *set) ((__sigset_t) { .__val = {[0 ... _SIGSET_NWORDS-1 ] = -1 } }) /* Block all signals, including internal glibc ones. */ -static inline int +static inline void __libc_signal_block_all (sigset_t *set) { + sigset_t allset = SIGALL_SET; INTERNAL_SYSCALL_DECL (err); - return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_BLOCK, &SIGALL_SET, - set, _NSIG / 8); + INTERNAL_SYSCALL_CALL (rt_sigprocmask, err, SIG_BLOCK, &allset, set, + _NSIG / 8); } /* Block all application signals (excluding internal glibc ones). */ -static inline int +static inline void __libc_signal_block_app (sigset_t *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); + INTERNAL_SYSCALL_CALL (rt_sigprocmask, err, SIG_BLOCK, &allset, set, + _NSIG / 8); } /* Restore current process signal mask. */ -static inline int +static inline void __libc_signal_restore_set (const sigset_t *set) { INTERNAL_SYSCALL_DECL (err); - return INTERNAL_SYSCALL (rt_sigprocmask, err, 4, SIG_SETMASK, set, NULL, - _NSIG / 8); + INTERNAL_SYSCALL_CALL (rt_sigprocmask, err, SIG_SETMASK, set, NULL, + _NSIG / 8); } /* Used to communicate with signal handler. */