From patchwork Mon Feb 10 19:20:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 183260 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4418359ile; Mon, 10 Feb 2020 11:22:57 -0800 (PST) X-Google-Smtp-Source: APXvYqxCvogTu2WDc+andJawpoeLu/NHkORL3FoyBtLm32VAuwa6GJNlOSnrKoWCw6yTNNhjkpVj X-Received: by 2002:a9d:3bc4:: with SMTP id k62mr2304154otc.186.1581362577743; Mon, 10 Feb 2020 11:22:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581362577; cv=none; d=google.com; s=arc-20160816; b=j1AwrjP9of0xsuqBJGQqPb0Nhdkqg6YsawbiQqJgSNlmHx2SrmSThO9YEqOXjh1MMh fGufOqtsUFjI7cNbOtHCjEwIIA04dkAKdSRJMIoX8rTquNcfQpUdPuCmSVCU61TFSVCq VUZ0uTaifr7otba9StfqNXVeTHGPjyt7Hbs9mvdxImFRahBPgAFPKbEj8GK6xcI4PHJ3 rKjdhFdShpAG8uLS6Xq1RAgi/6rqlLNSPCaG3mWfrDhvtuTtgMfBCMQMn+WAFbhNbcWf t2bPu36IxshXkkWTiXib7d+/hY8q8SV61dEVONRyrNyAVyYCIcPmhUH7KYhFiqzW8OLI 1xBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to: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=yHRlOLuz+g7J/taK0JyoH+VC7TAga3tawV/6ybHcTjQ=; b=E3YT0J4ccfWNofn023sf+6jfCSe9Fmu41/izQ/5+CX6FF28wF6Ubc92xQlvkuH/rr/ qwm4DZj1v25ya4EWdCON4kLN6Ug9fKEGXkaytIwzCRxk+lVkRZZP3SOTXmTio/yS29Kz WkdZl9UwgdjgIqlkqlWP/mTEuhJqzGsF1y+ZlFQQLvUJTF6leC2VpWp5mh8ydloVJ9BY WATU6Xp8eBjIJ3TlwM9F2JRE8sFYBgzyo22qYidPg57MOyaEZI7OSN9xkKm/3H6F1KUY ZGA8FtRMRLmPOs71IKqpAjguhg7AnJRpV/VpCFFbuz/XAGQ6BNBTwSTQ8VdFBiPtJtEw H77A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=ZFJQvzww; dkim=pass header.i=@linaro.org header.s=google header.b=OQnWjv2F; spf=pass (google.com: domain of libc-alpha-return-109396-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-109396-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 n11si612488otq.112.2020.02.10.11.22.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Feb 2020 11:22:57 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-109396-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=ZFJQvzww; dkim=pass header.i=@linaro.org header.s=google header.b=OQnWjv2F; spf=pass (google.com: domain of libc-alpha-return-109396-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-109396-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:in-reply-to :references; q=dns; s=default; b=oLKiFfvkUsbRamJJwkPmsUoadwBwaDb D2M3uYG+tmgwmBhUINQZKiLErgdd0MofHA3OxUdzlexWYIAgrPyguM/S1nu1pZ5W ZQ7DCWsGX7Egn3H6QmZUY8L9UhM5JG0AWvUPAcNobiBn22esANTJf44SXL8TOSjx AdCqPdhPpMws= 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:in-reply-to :references; s=default; bh=a4JErfIbudXU2j7f6bPQdjmGeZU=; b=ZFJQv zwwIzFKhfGRwu2eXVCEUEaUadztQXJ1h7Icw+JMxPNttQxXyDXT1GTFmArjccCYv mVSRMGah/N9dwiJJhPBlWLaE2REGiVD2rTNj4jHC1ylfORZ3GSvOW+TTfILy1BHS rb3gj3kL5oP4EFJ5tcBwczBtI3psp0TKMdOJY0= Received: (qmail 100955 invoked by alias); 10 Feb 2020 19:21:01 -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 100885 invoked by uid 89); 10 Feb 2020 19:21:01 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-qk1-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:in-reply-to:references; bh=yHRlOLuz+g7J/taK0JyoH+VC7TAga3tawV/6ybHcTjQ=; b=OQnWjv2FtjDUdghv09L5Gynq5vJBYlr7APcE0RBRl2OKGNKxjg/Rp+KGkx9CkumnDe RSQ5Bixe8UtwsyZbcGmESTEZ/KAkSP9mCh+vcCKfyn8kvuwFfoKP+QOb2IyfSDv2TDgz BMT7Eep5Lnutgva6Ki9vhh/+RUedPMTrJWCbyIvvREETMENSZ353MoG700hHxke3dIXt qQHU2RRPPk3avFpdUha6fEYwOWXy1USRzKmLc+7mJBM+bIweEKYiUEBM+fwptVd5qtVS +MxaA8K+gbQQNegmaAVICxiSei9FFawm7/SPnte8pE6QWoafAQfagFfu+9iJVqQ4J+Ed Bxow== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 12/15] sparc: Avoid clobbering register parameters in syscall Date: Mon, 10 Feb 2020 16:20:35 -0300 Message-Id: <20200210192038.23588-12-adhemerval.zanella@linaro.org> In-Reply-To: <20200210192038.23588-1-adhemerval.zanella@linaro.org> References: <20200210192038.23588-1-adhemerval.zanella@linaro.org> The sparc INTERNAL_SYSCALL macro might clobber the register parameter if the argument itself might clobber any register (a function call for instance). This patch fixes it by using temporary variables for the expressions between the register assignments (as indicated by GCC documentation, 6.47.5.2 Specifying Registers for Local Variables). It is similar to the fix done for MIPS (BZ#25523). Checked on sparc64-linux-gnu and sparcv9-linux-gnu. --- sysdeps/unix/sysv/linux/sparc/sysdep.h | 78 +++++++++++++++++--------- 1 file changed, 52 insertions(+), 26 deletions(-) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h index 67efa6f029..e2a12349a1 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h @@ -87,8 +87,9 @@ #define internal_syscall1(string,err,name,arg1) \ ({ \ + long _arg1 = (long) (arg1); \ register long __err __asm__("g1") = (name); \ - register long __o0 __asm__ ("o0") = (long)(arg1); \ + register long __o0 __asm__ ("o0") = _arg1; \ __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ "0" (__err), "1" (__o0) : \ __SYSCALL_CLOBBERS); \ @@ -97,9 +98,11 @@ #define internal_syscall2(string,err,name,arg1,arg2) \ ({ \ + long _arg1 = (long) (arg1); \ + long _arg2 = (long) (arg2); \ register long __err __asm__("g1") = (name); \ - register long __o0 __asm__ ("o0") = (long)(arg1); \ - register long __o1 __asm__ ("o1") = (long)(arg2); \ + register long __o0 __asm__ ("o0") = _arg1; \ + register long __o1 __asm__ ("o1") = _arg2; \ __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ "0" (__err), "1" (__o0), "r" (__o1) : \ __SYSCALL_CLOBBERS); \ @@ -108,10 +111,13 @@ #define internal_syscall3(string,err,name,arg1,arg2,arg3) \ ({ \ + long _arg1 = (long) (arg1); \ + long _arg2 = (long) (arg2); \ + long _arg3 = (long) (arg3); \ register long __err __asm__("g1") = (name); \ - register long __o0 __asm__ ("o0") = (long)(arg1); \ - register long __o1 __asm__ ("o1") = (long)(arg2); \ - register long __o2 __asm__ ("o2") = (long)(arg3); \ + register long __o0 __asm__ ("o0") = _arg1; \ + register long __o1 __asm__ ("o1") = _arg2; \ + register long __o2 __asm__ ("o2") = _arg3; \ __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ "0" (__err), "1" (__o0), "r" (__o1), \ "r" (__o2) : \ @@ -121,11 +127,15 @@ #define internal_syscall4(string,err,name,arg1,arg2,arg3,arg4) \ ({ \ + long _arg1 = (long) (arg1); \ + long _arg2 = (long) (arg2); \ + long _arg3 = (long) (arg3); \ + long _arg4 = (long) (arg4); \ register long __err __asm__("g1") = (name); \ - register long __o0 __asm__ ("o0") = (long)(arg1); \ - register long __o1 __asm__ ("o1") = (long)(arg2); \ - register long __o2 __asm__ ("o2") = (long)(arg3); \ - register long __o3 __asm__ ("o3") = (long)(arg4); \ + register long __o0 __asm__ ("o0") = _arg1; \ + register long __o1 __asm__ ("o1") = _arg2; \ + register long __o2 __asm__ ("o2") = _arg3; \ + register long __o3 __asm__ ("o3") = _arg4; \ __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ "0" (__err), "1" (__o0), "r" (__o1), \ "r" (__o2), "r" (__o3) : \ @@ -135,12 +145,17 @@ #define internal_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5) \ ({ \ + long _arg1 = (long) (arg1); \ + long _arg2 = (long) (arg2); \ + long _arg3 = (long) (arg3); \ + long _arg4 = (long) (arg4); \ + long _arg5 = (long) (arg5); \ register long __err __asm__("g1") = (name); \ - register long __o0 __asm__ ("o0") = (long)(arg1); \ - register long __o1 __asm__ ("o1") = (long)(arg2); \ - register long __o2 __asm__ ("o2") = (long)(arg3); \ - register long __o3 __asm__ ("o3") = (long)(arg4); \ - register long __o4 __asm__ ("o4") = (long)(arg5); \ + register long __o0 __asm__ ("o0") = _arg1; \ + register long __o1 __asm__ ("o1") = _arg2; \ + register long __o2 __asm__ ("o2") = _arg3; \ + register long __o3 __asm__ ("o3") = _arg4; \ + register long __o4 __asm__ ("o4") = _arg5; \ __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ "0" (__err), "1" (__o0), "r" (__o1), \ "r" (__o2), "r" (__o3), "r" (__o4) : \ @@ -150,13 +165,19 @@ #define internal_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6)\ ({ \ + long _arg1 = (long) (arg1); \ + long _arg2 = (long) (arg2); \ + long _arg3 = (long) (arg3); \ + long _arg4 = (long) (arg4); \ + long _arg5 = (long) (arg5); \ + long _arg6 = (long) (arg6); \ register long __err __asm__("g1") = (name); \ - register long __o0 __asm__ ("o0") = (long)(arg1); \ - register long __o1 __asm__ ("o1") = (long)(arg2); \ - register long __o2 __asm__ ("o2") = (long)(arg3); \ - register long __o3 __asm__ ("o3") = (long)(arg4); \ - register long __o4 __asm__ ("o4") = (long)(arg5); \ - register long __o5 __asm__ ("o5") = (long)(arg6); \ + register long __o0 __asm__ ("o0") = _arg1; \ + register long __o1 __asm__ ("o1") = _arg2; \ + register long __o2 __asm__ ("o2") = _arg3; \ + register long __o3 __asm__ ("o3") = _arg4; \ + register long __o4 __asm__ ("o4") = _arg5; \ + register long __o5 __asm__ ("o5") = _arg6; \ __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ "0" (__err), "1" (__o0), "r" (__o1), \ "r" (__o2), "r" (__o3), "r" (__o4), \ @@ -167,11 +188,16 @@ #define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5) \ ({ \ - register long __o0 __asm__ ("o0") = (long)(arg1); \ - register long __o1 __asm__ ("o1") = (long)(arg2); \ - register long __o2 __asm__ ("o2") = (long)(arg3); \ - register long __o3 __asm__ ("o3") = (long)(arg4); \ - register long __o4 __asm__ ("o4") = (long)(arg5); \ + long _arg1 = (long) (arg1); \ + long _arg2 = (long) (arg2); \ + long _arg3 = (long) (arg3); \ + long _arg4 = (long) (arg4); \ + long _arg5 = (long) (arg5); \ + register long __o0 __asm__ ("o0") = _arg1; \ + register long __o1 __asm__ ("o1") = _arg2; \ + register long __o2 __asm__ ("o2") = _arg3; \ + register long __o3 __asm__ ("o3") = _arg4; \ + register long __o4 __asm__ ("o4") = _arg5; \ register long __g1 __asm__ ("g1") = __NR_clone; \ __asm __volatile (__SYSCALL_STRING : \ "=r" (__g1), "=r" (__o0), "=r" (__o1) : \