From patchwork Tue Jun 21 05:06:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 70511 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1831088qgy; Mon, 20 Jun 2016 22:10:22 -0700 (PDT) X-Received: by 10.66.84.164 with SMTP id a4mr25689275paz.90.1466485822090; Mon, 20 Jun 2016 22:10:22 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id u5si17825208paz.118.2016.06.20.22.10.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 20 Jun 2016 22:10:22 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-70821-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; spf=pass (google.com: domain of libc-alpha-return-70821-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=libc-alpha-return-70821-patch=linaro.org@sourceware.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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type; q=dns; s=default; b=XysWN 6US9KCKCcUd1RutPfr/TQ4P+yTYGtEQhR5PM0eujvPHbVNyzhdLX9wHiKlu8qDCi xEMoDwEmDNwBx/5kuU+kPpDEohSC6xT9BROls6Ha1NSJpDslxQPdWLNu85fwz7et 9mIxn4kobtfrXvJZ5dUjwIYezGNtji9KxER6go= 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:cc:subject:date:message-id:in-reply-to :references:mime-version:content-type; s=default; bh=k1uV7PGzKxx gzMbfCoLPK6sHYzY=; b=saDKSVSdFv81/Rth24GQK54+iXUOeWjbkD6HkgxSHYv /kjAI5IOBXuoineAi9io2mwcSsIieBKzc6qZgy4zG6gBSsM/yNl32Uj9QeLX5D+y SOqF7VCtC0Bgxy9Cl/JCJWwQJHa8tGPqHrFKYW2N7qvGTRPTwusW6ArMVsPk7omY = Received: (qmail 112382 invoked by alias); 21 Jun 2016 05:09:57 -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 112254 invoked by uid 89); 21 Jun 2016 05:09:56 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=advatage X-HELO: na01-by2-obe.outbound.protection.outlook.com Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; From: Yury Norov To: , CC: , , , , , , , , , Andrew Pinski , Yury Norov Subject: [PATCH 11/27] [AARCH64] Syscalls for ILP32 are passed always via 64bit values. Date: Tue, 21 Jun 2016 08:06:55 +0300 Message-ID: <1466485631-3532-13-git-send-email-ynorov@caviumnetworks.com> In-Reply-To: <1466485631-3532-1-git-send-email-ynorov@caviumnetworks.com> References: <1466485631-3532-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-ClientProxiedBy: HE1PR03CA0034.eurprd03.prod.outlook.com (10.163.170.172) To CY1PR07MB2248.namprd07.prod.outlook.com (10.164.112.150) X-MS-Office365-Filtering-Correlation-Id: 17acf66a-8ec3-439c-db7b-08d399924688 X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2248; 2:Z0iPNootnf0QeoNSwKilQjtMBtjEQbOwBCpb6jyE6I2mJdeU0cmqSsXy4SzR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H5FVdeU5RgwqBb6iBq2cAc8AOWzPq/iafo3JBGc/p3tSeBPXiJ0keLJxMI9XeqgzQWf57YsVU9KIcs2Q== X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2248; 20:E3dftCqJUU2hU01nVMPnP2kGCk2TpZvAtT/yceWqFDeM2vhlfGN6+47VlpeGwdQEksSzcplRSaDzwffM7fzmtBfre2muSUJpb83/cM2bw0ZMm4BVmr0I87oNFde3Xu09a/uu2SxAkoXjHs8e0JXrxrUKPKm9Lx8+qW4lowbnso2NpqMM9jxzmLVUPBrq8hiTARcYDGs/Jw2IFERx9FCP79KkO8Qrxac2R0sCDoWq/7KFFP8h8YH2sFAbz9MEuCPbOUc6Ly0HLuXjwfjLr2G+sS3RkIdTZd/hlT94l2dh7l5fVpWEuhoLFqluZ+e9EIYolYewCn5G0VK8i+h8ETnXqdfsnS9AO/1+mnOW71pjptnMbVbSk+whgHwIZOdKQL15RdthGZHE1iGKrN0iLA8KKlt/urMFLNqZsF5+XO6pi8vusF3unGDUbmIQcAIsWSsKPbyH0S7t8jYQbh7jE1XWGu0YVmzZhoST9nszGiBdT7ogTUdauKC/Omf20LklcnjoDk9l9VRL6gKY5W64b+l6Y3+xgu169VDhIrkfZj7l9PryVV/QicocO1+ycttKjl18VhmiAipQ16wO45A+g7wuBtrpBTJX7Gj7U1VUeDqZreQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001); SRVR:CY1PR07MB2248; BCL:0; PCL:0; RULEID:; SRVR:CY1PR07MB2248; X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2248; 4:UUh7St6Ii83l1SWenrTmFrXBBysIQuvkSkbx2uRpzBdKMp+mzYALqjrHopmvM0Bw5GG7heBH5Yp1LTMwLAe52Bdj5aRnL1c+L5v47/Ht5RaVSYKstHev7wKKeJJHr/TuSQKZiQJfhXWVP9NkPk9EQNRe+XmJQKT0sbpH9SNfbQCgjA2N1Qetg01wikNoJHTEPh+dxjlj41opm1yM2gFL+bqODE0hKwTl68qf6bAK8SHEPy0vPelHeRWfx31hg8NgMwwOyf8IrZF0ZcK8FlfQg92dFlDBLzYXKZXwWSgCYfk40Alwdc3YFAIkaA2rwIe9Bxrg91Um2C0+4dDpRlRGkGpPUsWbR19o8usBvNFG/TixUB5i/3Dra7qOhn5qkvJD X-Forefront-PRVS: 098076C36C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(189002)(199003)(66066001)(92566002)(2950100001)(6116002)(575784001)(229853001)(3846002)(101416001)(5003940100001)(50226002)(50466002)(7736002)(76176999)(586003)(76506005)(48376002)(50986999)(8676002)(4001430100002)(189998001)(4326007)(68736007)(19580405001)(106356001)(5001770100001)(105586002)(2906002)(97736004)(19580395003)(47776003)(36756003)(33646002)(81166006)(77096005)(42186005)(7846002)(107886002)(81156014)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR07MB2248; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; CAT:NONE; LANG:en; CAT:NONE; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR07MB2248; 23:B7Ny3xyeLh0KOmvZg1HcadQ3zX4MSons2pxi2cybo?= =?us-ascii?Q?bVUVvjecg6CzKXxakQtIZMnuAU/SHsU6pVyYR5FMSJrQfKLfE+I7aR8j3sKQ?= =?us-ascii?Q?jrsm2oEq5VbLMEf/O7FGLtzpyuGUFOxhX/ute/qu8j05Ks/vcwF/NUoINhNQ?= =?us-ascii?Q?+gMcmyaTr1LVLMJPl6BRx2tSGg9w5ftDqOifWvv2UjHticG0QGtU3mX2414J?= =?us-ascii?Q?+x1ZCJ6o5cLVFme/wHxQf5f0EO7NNfEAMHOmWneSpZYG8S/f3G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WgXrCxP9cC?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR07MB2248; 6:D3bufdOCvJX521BfnuyFMLqNZGRI/1u/SEoeFOM85Xt9a6vMkDHzws5K7wG3kSWGcgS4gB+b4ViaEiQPNreI5pxEvsod5XqomHW0IuNkjl1ZTygxASzxcfyW8S9TrcX36XobJoGq5VHqiEkQ9aI5CjqfMdmRdlq+UubJrzorKk2s8OIgMK/4cmcVUZRXFJegrYdiKLw3wwziAeXgWarGn24zN8uoTPwJYg5P26c4pp02Uy9G0hpd7K6Jp33YMrqqMm3J9Pc3Eegov7TsHxFgjWZ4jv28AIV71NAs6oQ5/VY=; 5:yqxuQihohmouX/+olRNnM5ez1EIlvaC/Rt5tjSvLzrtNi2RMa1QHPaMbz+HjvaH2WeDxUzfJFD3n0GZZWwu97K4sGHCQIUAfIk3NuGOhZ9nB/yU8MXQOZo1AbUpBCUFDie+EbTDSiPq2djG7HYOeZg==; 24:Ef7N1LWPoT/XZR+z6sZOTYeobQWF/VVQc1WRdg01i/a1hoFWdzjD9Ca1NItzN1BBon5Np/z+iAh2tAVo/k1aArGjtCXZ/v1iMEO7IT6TGjY=; 7:MJypHIVbcMU8KqdmiF+oMHSO1nyH7sb+DwJZ/8Zp2caDgQyWYpqcEPr0zFyp9EGwQfddV/HZIauVYaMdXBDCbE4jZsqE59LzqaoqZmRmX9tlOeHwAj/BhuNT08gC5D9IuRHB7pzkH7FW4U8/jgqriMigoEvPNH0jAAcqT6iw4eanxu1S5rxEIk62q3QQt0xoOop6yhx5Z1mkjjGQx7LwZQ== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Jun 2016 05:09:51.1836 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR07MB2248 From: Andrew Pinski This patch adds support for ILP32 syscalls, sign and zero extending where needed. Unlike LP64, pointers are 32bit and need to be zero extended rather than the standard sign extend that the code would do. We take advatage of ssize_t being long rather than int for ILP32, to get this correct. * sysdeps/unix/sysv/linux/aarch64/sysdep.h (INLINE_VSYSCALL): Use long long instead of long. (INTERNAL_VSYSCALL): Likewise. (INLINE_SYSCALL): Likewise. (INTERNAL_SYSCALL_RAW): Likewise. (ARGIFY): New macro. (LOAD_ARGS_0): Use long long instead of long. (LOAD_ARGS_1): Use long long instead of long and use ARGIFY. (LOAD_ARGS_2): Likewise. (LOAD_ARGS_3): Likewise. (LOAD_ARGS_4): Likewise. (LOAD_ARGS_5): Likewise. (LOAD_ARGS_6): Likewise. (LOAD_ARGS_7): Likewise. Signed-off-by: Yury Norov --- sysdeps/unix/sysv/linux/aarch64/sysdep.h | 48 ++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 18 deletions(-) -- 2.7.4 diff --git a/sysdeps/unix/sysv/linux/aarch64/sysdep.h b/sysdeps/unix/sysv/linux/aarch64/sysdep.h index 1ffabc2..42f89c8 100644 --- a/sysdeps/unix/sysv/linux/aarch64/sysdep.h +++ b/sysdeps/unix/sysv/linux/aarch64/sysdep.h @@ -161,11 +161,11 @@ call. */ # undef INLINE_SYSCALL # define INLINE_SYSCALL(name, nr, args...) \ - ({ unsigned long _sys_result = INTERNAL_SYSCALL (name, , nr, args); \ + ({ unsigned long long _sys_result = INTERNAL_SYSCALL (name, , nr, args); \ if (__builtin_expect (INTERNAL_SYSCALL_ERROR_P (_sys_result, ), 0))\ { \ __set_errno (INTERNAL_SYSCALL_ERRNO (_sys_result, )); \ - _sys_result = (unsigned long) -1; \ + _sys_result = (unsigned long long) -1; \ } \ (long) _sys_result; }) @@ -174,10 +174,10 @@ # undef INTERNAL_SYSCALL_RAW # define INTERNAL_SYSCALL_RAW(name, err, nr, args...) \ - ({ long _sys_result; \ + ({ long long _sys_result; \ { \ LOAD_ARGS_##nr (args) \ - register long _x8 asm ("x8") = (name); \ + register long long _x8 asm ("x8") = (name); \ asm volatile ("svc 0 // syscall " # name \ : "=r" (_x0) : "r"(_x8) ASM_ARGS_##nr : "memory"); \ _sys_result = _x0; \ @@ -199,36 +199,48 @@ # undef INTERNAL_SYSCALL_ERRNO # define INTERNAL_SYSCALL_ERRNO(val, err) (-(val)) +/* Convert X to a long long, without losing any bits if it is one + already or warning if it is a 32-bit pointer. This zero extends + 32-bit pointers and sign extends other signed types. Note this only + works because ssize_t is long and short-short is promoted to int. */ +#define ARGIFY(X) \ + ((unsigned long long) \ + __builtin_choose_expr(__builtin_types_compatible_p(__typeof__(X), __typeof__((X) - (X))), \ + (X), \ + __builtin_choose_expr(__builtin_types_compatible_p(int, __typeof__((X) - (X))), \ + (X), \ + (unsigned long)(X)))) + # define LOAD_ARGS_0() \ - register long _x0 asm ("x0"); + register long long _x0 asm ("x0"); # define LOAD_ARGS_1(x0) \ - long _x0tmp = (long) (x0); \ + long long _x0tmp = ARGIFY (x0); \ LOAD_ARGS_0 () \ _x0 = _x0tmp; # define LOAD_ARGS_2(x0, x1) \ - long _x1tmp = (long) (x1); \ + long long _x1tmp = ARGIFY (x1); \ LOAD_ARGS_1 (x0) \ - register long _x1 asm ("x1") = _x1tmp; + register long long _x1 asm ("x1") = _x1tmp; # define LOAD_ARGS_3(x0, x1, x2) \ - long _x2tmp = (long) (x2); \ + long long _x2tmp = ARGIFY (x2); \ LOAD_ARGS_2 (x0, x1) \ - register long _x2 asm ("x2") = _x2tmp; + register long long _x2 asm ("x2") = _x2tmp; # define LOAD_ARGS_4(x0, x1, x2, x3) \ - long _x3tmp = (long) (x3); \ + long long _x3tmp = ARGIFY (x3); \ LOAD_ARGS_3 (x0, x1, x2) \ - register long _x3 asm ("x3") = _x3tmp; + register long long _x3 asm ("x3") = _x3tmp; # define LOAD_ARGS_5(x0, x1, x2, x3, x4) \ - long _x4tmp = (long) (x4); \ + long long _x4tmp = ARGIFY (x4); \ LOAD_ARGS_4 (x0, x1, x2, x3) \ - register long _x4 asm ("x4") = _x4tmp; + register long long _x4 asm ("x4") = _x4tmp; # define LOAD_ARGS_6(x0, x1, x2, x3, x4, x5) \ - long _x5tmp = (long) (x5); \ + long long _x5tmp = ARGIFY (x5); \ LOAD_ARGS_5 (x0, x1, x2, x3, x4) \ - register long _x5 asm ("x5") = _x5tmp; + register long long _x5 asm ("x5") = _x5tmp; # define LOAD_ARGS_7(x0, x1, x2, x3, x4, x5, x6)\ - long _x6tmp = (long) (x6); \ + long long _x6tmp = ARGIFY (x6); \ LOAD_ARGS_6 (x0, x1, x2, x3, x4, x5) \ - register long _x6 asm ("x6") = _x6tmp; + register long long _x6 asm ("x6") = _x6tmp; # define ASM_ARGS_0 # define ASM_ARGS_1 , "r" (_x0)