From patchwork Mon Feb 10 19:20:32 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: 183257 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4417861ile; Mon, 10 Feb 2020 11:22:24 -0800 (PST) X-Google-Smtp-Source: APXvYqyJUi1iD28O7cWl+2BN31ZouHyqxxopn1AhmpFYWTgwI4xOyi+xQ2i3V+hQ9CS6b3rpajxr X-Received: by 2002:a05:6830:1042:: with SMTP id b2mr2209963otp.306.1581362544587; Mon, 10 Feb 2020 11:22:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581362544; cv=none; d=google.com; s=arc-20160816; b=hYisyHsAy55MQb/8Ui62rEYtqnVzSf15Q1zQ8QSJTQcdepvjTg1RqsNspHv/uwIrKp K0Qz54s85Y4Bb5/RQ0KuL1KQJhBykFaP0tI+wSV8iIzw/VgkvHJ026OKiwCAApudRFyS y2kHgIcqJeY50mV7MaEjxLohRWgCM/22QhrWRQbawe3+msaHR9gpncRWmlpYS6g1Q0fi oNFP1ZmxObA8sam6bazliLSrUQ+1A0KUp5QTHQvMVFftjk0faz1r3Qs4s5/ebvZk2q33 C9v0Iu7f0bWb98boImAA/rJSSj6369i3LnpW4CkicI8DEkvx3AC8CL1wxmqF9VE7g79b lxSA== 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=OxPe/gvmXUwBAz0kyif56UJkvk1vjT9jldofje5Hor8=; b=b+nvzHuD9PgrAlD5FcTd/vRIibMI909j97n/zGUkCS72YqU9B2cvEEXAzZ7Zq+4lnV /8skOOmtLuhHDFhr5ytTBX+dMiG8c1qgS5zd8zXN6yF0FvTT9aFS49DYNQ0OtPfL54Cf AM9JTWFPSdPiwMS5rGemrW0RdLnRgy+caam2mx2ngrLdrSl4T8aQnPa6rkOe5H5V2mwL qt0jxV3vKfriCLe5UFVPwJnCIqRQsA3waRKzEAw2U3M35KuCAVGz/ubrffgN/RoJvjDo t3c5QkeQdn5M9AhlXyClWcMTZ0XY78hPFALlOkG4SyHvHIzM4/16tvwc9Y4KCwMMQnDY RTXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=kHs8Z3pY; dkim=pass header.i=@linaro.org header.s=google header.b=Zw9LQuF+; spf=pass (google.com: domain of libc-alpha-return-109394-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-109394-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 l10si631891oth.243.2020.02.10.11.22.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Feb 2020 11:22:24 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-109394-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=kHs8Z3pY; dkim=pass header.i=@linaro.org header.s=google header.b=Zw9LQuF+; spf=pass (google.com: domain of libc-alpha-return-109394-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-109394-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=S5PTwLnPUXzr+eGXmyJDkhaSTDzdTCB AcN2eO69iM3tIZw5nSrmOO5mBkaL7LbIW7gus2Gzc3vqY6Rp3N6brzc8Qr8Oj9wo O+4yqloXwa7CQAmG9DW0VwSsbXDNOZ5QvPObyCFkKCAC06IdK49GrfMUlfla2tij /qYIGPUn/zQ4= 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=tDJrY8owYzwtY1MOTc7RnnEbL8A=; b=kHs8Z 3pYHkQsl6KWLZ28XyTX4Q/9mTLvsk8pEaxK0qUTWA7Nl87IbX7P8oCIXuYGo9hm3 tSD6AcbPjR8JmUhz+A2ANtGH+GsdBGyABr6OoKicSpLYzdvF2YDXeFmVMhNorM+R sfmJMqEXfJv+vEgImI/zZMzlqZruhKQfqPPQ2M= Received: (qmail 100564 invoked by alias); 10 Feb 2020 19:20:59 -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 100489 invoked by uid 89); 10 Feb 2020 19:20:58 -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=2199 X-HELO: mail-qk1-f196.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=OxPe/gvmXUwBAz0kyif56UJkvk1vjT9jldofje5Hor8=; b=Zw9LQuF+QNG/zECrOa0O5BWSjABjGdGZcsql2bs7bc5hFL+nXIGh8X++A2XaA7hgcI ynJuV5ebbswH2Ry0IrED5esnh+X2VBU0sVxorJRHUdQYKaq6I1LChROzEDgqnE9hmd5a lgWIjtODqF9bnqUshJ0t++6pUFok9v+MyMvPCMCQbdM5HHPQ2Dh8k/PQUE82DRAfrNU0 GQIkc4KIVUqnqa0rFErcR+1mVLLbP44PwJCgfeK+NMQTGR0xiCZU9bzIneL5vFklYWAL bK2c/FRPciYXbgtje1kV0ZaxvdaD9I68W6xq7mz0TjZ9lcZL7Wl6gouKchNLyE2Cx6wK OVwg== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 09/15] microblaze: Avoid clobbering register parameters in syscall Date: Mon, 10 Feb 2020 16:20:32 -0300 Message-Id: <20200210192038.23588-9-adhemerval.zanella@linaro.org> In-Reply-To: <20200210192038.23588-1-adhemerval.zanella@linaro.org> References: <20200210192038.23588-1-adhemerval.zanella@linaro.org> The microblaze 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 with microblaze-linux-gnu and microblazeel-linux-gnu build. --- sysdeps/unix/sysv/linux/microblaze/sysdep.h | 63 ++++++++++++++------- 1 file changed, 42 insertions(+), 21 deletions(-) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/microblaze/sysdep.h b/sysdeps/unix/sysv/linux/microblaze/sysdep.h index ed873d9dd4..b4a6ee89f1 100644 --- a/sysdeps/unix/sysv/linux/microblaze/sysdep.h +++ b/sysdeps/unix/sysv/linux/microblaze/sysdep.h @@ -219,9 +219,10 @@ SYSCALL_ERROR_LABEL_DCL: \ # define inline_syscall1(name,arg1) \ ({ \ + long __arg1 = (long) (arg1); \ register long __ret __asm__("r3"); \ register long __r12 __asm__("r12") = name; \ - register long __r5 __asm__("r5") = (long)(arg1); \ + register long __r5 __asm__("r5") = __arg1; \ __asm__ __volatile__( "brki r14,8; nop;" \ : "=r"(__ret) \ : "r"(__r5), "r"(__r12) \ @@ -230,10 +231,12 @@ SYSCALL_ERROR_LABEL_DCL: \ # define inline_syscall2(name,arg1,arg2) \ ({ \ + long __arg1 = (long) (arg1); \ + long __arg2 = (long) (arg2); \ register long __ret __asm__("r3"); \ register long __r12 __asm__("r12") = name; \ - register long __r5 __asm__("r5") = (long)(arg1); \ - register long __r6 __asm__("r6") = (long)(arg2); \ + register long __r5 __asm__("r5") = __arg1; \ + register long __r6 __asm__("r6") = __arg2; \ __asm__ __volatile__( "brki r14,8; nop;" \ : "=r"(__ret) \ : "r"(__r5), "r"(__r6), "r"(__r12) \ @@ -243,11 +246,14 @@ SYSCALL_ERROR_LABEL_DCL: \ # define inline_syscall3(name,arg1,arg2,arg3) \ ({ \ + long __arg1 = (long) (arg1); \ + long __arg2 = (long) (arg2); \ + long __arg3 = (long) (arg3); \ register long __ret __asm__("r3"); \ register long __r12 __asm__("r12") = name; \ - register long __r5 __asm__("r5") = (long)(arg1); \ - register long __r6 __asm__("r6") = (long)(arg2); \ - register long __r7 __asm__("r7") = (long)(arg3); \ + register long __r5 __asm__("r5") = __arg1; \ + register long __r6 __asm__("r6") = __arg2; \ + register long __r7 __asm__("r7") = __arg3; \ __asm__ __volatile__( "brki r14,8; nop;" \ : "=r"(__ret) \ : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r12) \ @@ -257,12 +263,16 @@ SYSCALL_ERROR_LABEL_DCL: \ # define inline_syscall4(name,arg1,arg2,arg3,arg4) \ ({ \ + long __arg1 = (long) (arg1); \ + long __arg2 = (long) (arg2); \ + long __arg3 = (long) (arg3); \ + long __arg4 = (long) (arg4); \ register long __ret __asm__("r3"); \ register long __r12 __asm__("r12") = name; \ - register long __r5 __asm__("r5") = (long)(arg1); \ - register long __r6 __asm__("r6") = (long)(arg2); \ - register long __r7 __asm__("r7") = (long)(arg3); \ - register long __r8 __asm__("r8") = (long)(arg4); \ + register long __r5 __asm__("r5") = __arg1; \ + register long __r6 __asm__("r6") = __arg2; \ + register long __r7 __asm__("r7") = __arg3; \ + register long __r8 __asm__("r8") = __arg4; \ __asm__ __volatile__( "brki r14,8; nop;" \ : "=r"(__ret) \ : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r12) \ @@ -272,13 +282,18 @@ SYSCALL_ERROR_LABEL_DCL: \ # define inline_syscall5(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 __ret __asm__("r3"); \ register long __r12 __asm__("r12") = name; \ - register long __r5 __asm__("r5") = (long)(arg1); \ - register long __r6 __asm__("r6") = (long)(arg2); \ - register long __r7 __asm__("r7") = (long)(arg3); \ - register long __r8 __asm__("r8") = (long)(arg4); \ - register long __r9 __asm__("r9") = (long)(arg5); \ + register long __r5 __asm__("r5") = __arg1; \ + register long __r6 __asm__("r6") = __arg2; \ + register long __r7 __asm__("r7") = __arg3; \ + register long __r8 __asm__("r8") = __arg4; \ + register long __r9 __asm__("r9") = __arg5; \ __asm__ __volatile__( "brki r14,8; nop;" \ : "=r"(__ret) \ : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r9), "r"(__r12) \ @@ -288,14 +303,20 @@ SYSCALL_ERROR_LABEL_DCL: \ # define inline_syscall6(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 __ret __asm__("r3"); \ register long __r12 __asm__("r12") = name; \ - register long __r5 __asm__("r5") = (long)(arg1); \ - register long __r6 __asm__("r6") = (long)(arg2); \ - register long __r7 __asm__("r7") = (long)(arg3); \ - register long __r8 __asm__("r8") = (long)(arg4); \ - register long __r9 __asm__("r9") = (long)(arg5); \ - register long __r10 __asm__("r10") = (long)(arg6); \ + register long __r5 __asm__("r5") = __arg1; \ + register long __r6 __asm__("r6") = __arg2; \ + register long __r7 __asm__("r7") = __arg3; \ + register long __r8 __asm__("r8") = __arg4; \ + register long __r9 __asm__("r9") = __arg5; \ + register long __r10 __asm__("r10") = __arg6; \ __asm__ __volatile__( "brki r14,8; nop;" \ : "=r"(__ret) \ : "r"(__r5), "r"(__r6), "r"(__r7), "r"(__r8),"r"(__r9), "r"(__r10), \