From patchwork Mon Feb 10 19:20:26 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: 183250 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp4416661ile; Mon, 10 Feb 2020 11:21:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzktqDZZIJflce0rsBajCfkR6ODPItHyPf4/RLLAhuXANyJEygWF9Kha5Aapj8K7A7+CVlk X-Received: by 2002:aca:f354:: with SMTP id r81mr383753oih.90.1581362468879; Mon, 10 Feb 2020 11:21:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581362468; cv=none; d=google.com; s=arc-20160816; b=B1LcuEIQuD+kCcDltnFUthVBKnfl8c6HNY9lAEsmWC2M3wL2o3hrcEKGD3sI+0ZNdH WE1334OBrYvAKIL1hLjCMG+4NTnx8V+IFr2wgNf9lTBCQPOnTQnUMkryj82Psoxy/D/t OmvLOMPQjEsFjhdD0+ID2pyLhhuquGSFRTgaW8sGe6DM/1/K3END2xyJlSnU4iJb3yPl hLYftfPWLWZRTJBFwz6i3w57GxZTDs/2TIzKmC5eCzYtxbjsvlU15IBr7frhDb+7mmmg SOJQmp6jEq6T2uyihoOJjpGZqo3qwt3NQl8zoGALA2Qt+/I+n2Rdd9tX0oO1UO6AZurf VvoQ== 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=vBtaGkQvdEdfNfvZZN5eJFVDqdGpx0vyoU9rJahnsDE=; b=d8n2FbvC8IqMwc5l+pzTn1jGrL1DBSgOkByIrjkuqTaVX3aZ+utwM1LMGnZGD3RWWu 3wGqD1SYAivPzYyFBYyOeoD9rNej3jqYHMgh2yy7/F5XdQ9Jcca3d9IxxuuuLfI2VAYx V1BlTnTh6EjE98kLJwYg8ARv8EDUK9+MS8OZpW4EB36fMgK5bfW1HrbhinaVGh9vKNES bf/BNm7Mnz+fud81DCqH5H6f3O0piIoaM7bJtkR/RZcUa2nNgLM3iLJMzU0uCsLz71m/ X0BUZXBaO7dYTNR3IXWFpvfYKtNYkhWfKge+T/lkZABs0cbeU0/RPQ7srJLE5KmGt4Xp mIXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sourceware.org header.s=default header.b=PqDMn5EX; dkim=pass header.i=@linaro.org header.s=google header.b=vi3Cmu5s; spf=pass (google.com: domain of libc-alpha-return-109387-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-109387-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 m4si624733otn.281.2020.02.10.11.21.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Feb 2020 11:21:08 -0800 (PST) Received-SPF: pass (google.com: domain of libc-alpha-return-109387-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=PqDMn5EX; dkim=pass header.i=@linaro.org header.s=google header.b=vi3Cmu5s; spf=pass (google.com: domain of libc-alpha-return-109387-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom="libc-alpha-return-109387-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=sbd1ILQAvYttrmx9PMTbG4m5teYjC53 4ulqX/5AaMPw6tU31nFtH1eiXGs59QeGfMJR1+kPA2ELaN9MQAS1ci3j5dm4AJpe 9MoBmE5fSZ6628nNmDZJmeEN9wW+gl7oP4xcUmY7+cPKxplol+SrWNXeWd9xBPaO vHI3Vb4BgvQM= 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=Oc2kfW4qQ+Xp8rT9ErE9w7De8I4=; b=PqDMn 5EXJ8YTYHB/dw6PiMyc0hjNgpvnG39zqFVBctwrptnsCQ61KxoX7S15CUgs9B0/Q HwPysIgr2Y1aTO14aopyCETwg3UPpUQStN2zCPwh2EXvSWPXxWMO1hmnAQmS6o+F a1F1OQKZYeBaTEwRxdTLnMckSQynZu830IlUEE= Received: (qmail 99247 invoked by alias); 10 Feb 2020 19:20:50 -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 99133 invoked by uid 89); 10 Feb 2020 19:20:49 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-22.0 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=act X-HELO: mail-qk1-f195.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=vBtaGkQvdEdfNfvZZN5eJFVDqdGpx0vyoU9rJahnsDE=; b=vi3Cmu5sUGLl64PpvLIfnBSSXyJpHeEBjsXTR8OTSNwcCwy0YE5S6SboC19IZZNICZ jqYdTq/UIwofNuozIOqrAsiZKgkDjYR/r/XpE9EVv1NocTD25cBVNJE3eqerIRHEzl0j vj0kY7uwMHHU14DoLotxMPk0nxvsQfaGr/GbvFP1rk45i5UQjbMtk7KsJFEO2Nb9yozo +IiTl6sc2qmyleSy6Q4iAS3xxy9pYYBZz2WEyWa7nxONEJK0y41b3hxwrNx7VLVP2s/V 9IjUms/YZ472WKaz2TLMC6toeS00Xq952/Ft+ODsieR70Cxymnml4w/uRoZiCJtt/yw0 JDIw== Return-Path: From: Adhemerval Zanella To: libc-alpha@sourceware.org Subject: [PATCH 03/15] sparc: Use Linux kABI for syscall return Date: Mon, 10 Feb 2020 16:20:26 -0300 Message-Id: <20200210192038.23588-3-adhemerval.zanella@linaro.org> In-Reply-To: <20200210192038.23588-1-adhemerval.zanella@linaro.org> References: <20200210192038.23588-1-adhemerval.zanella@linaro.org> It changes the sparc internal_syscall* macros to a negative value instead the 'g1' register value on 'err' macro argument. The macro INTERNAL_SYSCALL_DECL is no longer required, and the INTERNAL_SYSCALL_ERROR_P follows the other Linux kABIS. The redefinition of INTERNAL_VSYSCALL_CALL is also no longer required. Checked on sparc64-linux-gnu and sparcv9-linux-gnu. It fixes the sporadic issues on sparc32 where clock_nanosleep does not act as cancellation entrypoint. --- sysdeps/unix/sysv/linux/sparc/sysdep.h | 90 ++++++++++++-------------- 1 file changed, 41 insertions(+), 49 deletions(-) -- 2.17.1 diff --git a/sysdeps/unix/sysv/linux/sparc/sysdep.h b/sysdeps/unix/sysv/linux/sparc/sysdep.h index 0c32780d9c..67efa6f029 100644 --- a/sysdeps/unix/sysv/linux/sparc/sysdep.h +++ b/sysdeps/unix/sysv/linux/sparc/sysdep.h @@ -34,13 +34,6 @@ #else /* __ASSEMBLER__ */ -#define INTERNAL_VSYSCALL_CALL(funcptr, err, nr, args...) \ - ({ \ - long _ret = funcptr (args); \ - err = ((unsigned long) (_ret) >= (unsigned long) -4095L); \ - _ret; \ - }) - # define VDSO_NAME "LINUX_2.6" # define VDSO_HASH 61765110 @@ -65,112 +58,111 @@ }) #undef INTERNAL_SYSCALL_DECL -#define INTERNAL_SYSCALL_DECL(err) \ - register long err __asm__("g1"); +#define INTERNAL_SYSCALL_DECL(err) do { } while (0) #undef INTERNAL_SYSCALL #define INTERNAL_SYSCALL(name, err, nr, args...) \ - inline_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args) + internal_syscall##nr(__SYSCALL_STRING, err, __NR_##name, args) #undef INTERNAL_SYSCALL_NCS #define INTERNAL_SYSCALL_NCS(name, err, nr, args...) \ - inline_syscall##nr(__SYSCALL_STRING, err, name, args) + internal_syscall##nr(__SYSCALL_STRING, err, name, args) #undef INTERNAL_SYSCALL_ERROR_P #define INTERNAL_SYSCALL_ERROR_P(val, err) \ - ((void) (val), __builtin_expect((err) != 0, 0)) + ((unsigned long) (val) >= (unsigned long) -4095) #undef INTERNAL_SYSCALL_ERRNO #define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) -#define inline_syscall0(string,err,name,dummy...) \ +#define internal_syscall0(string,err,name,dummy...) \ ({ \ + register long __err __asm__("g1") = (name); \ register long __o0 __asm__ ("o0"); \ - err = name; \ - __asm __volatile (string : "=r" (err), "=r" (__o0) : \ - "0" (err) : \ + __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ + "0" (__err) : \ __SYSCALL_CLOBBERS); \ - __o0; \ + __err == -1 ? -__o0 : __o0; \ }) -#define inline_syscall1(string,err,name,arg1) \ +#define internal_syscall1(string,err,name,arg1) \ ({ \ + register long __err __asm__("g1") = (name); \ register long __o0 __asm__ ("o0") = (long)(arg1); \ - err = name; \ - __asm __volatile (string : "=r" (err), "=r" (__o0) : \ - "0" (err), "1" (__o0) : \ + __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ + "0" (__err), "1" (__o0) : \ __SYSCALL_CLOBBERS); \ - __o0; \ + __err == -1 ? -__o0 : __o0; \ }) -#define inline_syscall2(string,err,name,arg1,arg2) \ +#define internal_syscall2(string,err,name,arg1,arg2) \ ({ \ + register long __err __asm__("g1") = (name); \ register long __o0 __asm__ ("o0") = (long)(arg1); \ register long __o1 __asm__ ("o1") = (long)(arg2); \ - err = name; \ - __asm __volatile (string : "=r" (err), "=r" (__o0) : \ - "0" (err), "1" (__o0), "r" (__o1) : \ + __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ + "0" (__err), "1" (__o0), "r" (__o1) : \ __SYSCALL_CLOBBERS); \ - __o0; \ + __err == -1 ? -__o0 : __o0; \ }) -#define inline_syscall3(string,err,name,arg1,arg2,arg3) \ +#define internal_syscall3(string,err,name,arg1,arg2,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); \ - err = name; \ - __asm __volatile (string : "=r" (err), "=r" (__o0) : \ - "0" (err), "1" (__o0), "r" (__o1), \ + __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ + "0" (__err), "1" (__o0), "r" (__o1), \ "r" (__o2) : \ __SYSCALL_CLOBBERS); \ - __o0; \ + __err == -1 ? -__o0 : __o0; \ }) -#define inline_syscall4(string,err,name,arg1,arg2,arg3,arg4) \ +#define internal_syscall4(string,err,name,arg1,arg2,arg3,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); \ - err = name; \ - __asm __volatile (string : "=r" (err), "=r" (__o0) : \ - "0" (err), "1" (__o0), "r" (__o1), \ + __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ + "0" (__err), "1" (__o0), "r" (__o1), \ "r" (__o2), "r" (__o3) : \ __SYSCALL_CLOBBERS); \ - __o0; \ + __err == -1 ? -__o0 : __o0; \ }) -#define inline_syscall5(string,err,name,arg1,arg2,arg3,arg4,arg5) \ +#define internal_syscall5(string,err,name,arg1,arg2,arg3,arg4,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); \ - err = name; \ - __asm __volatile (string : "=r" (err), "=r" (__o0) : \ - "0" (err), "1" (__o0), "r" (__o1), \ + __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ + "0" (__err), "1" (__o0), "r" (__o1), \ "r" (__o2), "r" (__o3), "r" (__o4) : \ __SYSCALL_CLOBBERS); \ - __o0; \ + __err == -1 ? -__o0 : __o0; \ }) -#define inline_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,arg6) \ +#define internal_syscall6(string,err,name,arg1,arg2,arg3,arg4,arg5,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); \ - err = name; \ - __asm __volatile (string : "=r" (err), "=r" (__o0) : \ - "0" (err), "1" (__o0), "r" (__o1), \ + __asm __volatile (string : "=r" (__err), "=r" (__o0) : \ + "0" (__err), "1" (__o0), "r" (__o1), \ "r" (__o2), "r" (__o3), "r" (__o4), \ "r" (__o5) : \ __SYSCALL_CLOBBERS); \ - __o0; \ + __err == -1 ? -__o0 : __o0; \ }) #define INLINE_CLONE_SYSCALL(arg1,arg2,arg3,arg4,arg5) \ @@ -186,9 +178,9 @@ "0" (__g1), "1" (__o0), "2" (__o1), \ "r" (__o2), "r" (__o3), "r" (__o4) : \ __SYSCALL_CLOBBERS); \ - if (INTERNAL_SYSCALL_ERROR_P (__o0, __g1)) \ + if (__glibc_unlikely (__g1 != 0)) \ { \ - __set_errno (INTERNAL_SYSCALL_ERRNO (__o0, __g1)); \ + __set_errno (__o0); \ __o0 = -1L; \ } \ else \