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 Netto X-Patchwork-Id: 181144 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp6241332ile; Tue, 10 Dec 2019 10:32:41 -0800 (PST) X-Google-Smtp-Source: APXvYqxsU+5Wz5uG1RDGtgzwQh+SRpmCxOn72fNutylu+Ejcwc7AQVQ8DhTKP88v4c4cZL6rkrAD X-Received: by 2002:aca:758c:: with SMTP id q134mr197910oic.33.1576002761396; Tue, 10 Dec 2019 10:32:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576002761; cv=none; d=google.com; s=arc-20160816; b=D6k/3gtxj5mN1wmiwUlulkC8GlZ30ws/cbbmsxbfeyVpUG1z8LJ4LprbZv9GFzBnWO yh+pgVD6fuXMoXXlU/Y56GsUb+is0HzkfxZ9af4v1upDoaJO5ZB9V/jvzSAXm49oW314 ebW9PV09xTuaMax3HBmQoQdRXlRZlQ2vnrrKZarXhHnNFDGVDYh7bobJ7mprk/PWJZxT ke6MfZrXUe7Wcuiiqd00u2qYkp8z0cfBztA7SaYuc63RStClOJNabazWVD9/XSlhiysa zl2rJIwH4pgHJS8aLPLxRFj7dSUtkkWFMAIslqR6awTP4q8YHHqFOt4iboVgm/0MAfvF rSvg== 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=G00okY5kT1CHVjY7jVSxw7mduRPANkNVsbtrUcq7sr4=; b=k4RBCXyKOlJTG4g+Lp9et2bFHdXYn/i1TO5Dz1RCzxIAejfTsi+4fUXARKlojXUzuV LZsP8DrL6ZTXrBvzapUZpapQ2bmwOcNXt5wVtKHjtY80j3Rg3Krb7Ku+1rIiXprSbk5E UfsTyspY5d/6T0VJpEX19Hq2GutIcAQlEmj94RzVSv0Dl6i97LLCOUFxEPSTk7138lJ9 J8fAUSdECw3yQtRWr6RWcFHN7SVePGU1dJY3v5MSP5MfitVB/7hv9PVSSUCKGg8gWwoZ MDuHeTMPjqwIfniA3szpa4CyglLeQhf1NtScLmcXWoeu6r7AgcPmwOBvhVYquiSavQwl wN7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=hCYUPwn8; dkim=pass header.i=@linaro.org header.s=google header.b="P7xCp/eg"; spf=pass (google.com: domain of libc-alpha-return-107895-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107895-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 i124si2275353oif.214.2019.12.10.10.32.41 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Dec 2019 10:32:41 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-107895-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=hCYUPwn8; dkim=pass header.i=@linaro.org header.s=google header.b="P7xCp/eg"; spf=pass (google.com: domain of libc-alpha-return-107895-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-107895-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=mZLZt/8aGd2ofk1yoVOcmzKOhNQge9IMwkLRGNN59u7GrGIR9kjQI KmyUXy8HxUeGfLENx1nXQybuYtARehBvCeDjdIXXcP2OeG4UWuzefUbRS+mv+dR7 nWvv+qXLuWDW+0dCPLv/MXCJrCr6b1oeO5eUuxu0HVJwQiUvX86Yj0= 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=hCYUPwn8OW+6XB7GV0MdviUL3a6y WjExvpfLe+tvNxbYIQE2vuR1cimmx7s0yezm9jUj7hQpeQAHyYRdOuWvpj3PDT0Y Qhku5/7QSheKDe4r69QWRLBGIrhfhQ7Fo4/cX9XRA414ehdxWj5vi9FppUp1c1sz M06usKV6RTrWY9c= 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== Return-Path: 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(-) -- 2.17.1 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. */