From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751422AbdFDMEA (ORCPT ); Sun, 4 Jun 2017 08:04:00 -0400 Received: from mail-cys01nam02on0044.outbound.protection.outlook.com ([104.47.37.44]:9220 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751178AbdFDMDV (ORCPT ); Sun, 4 Jun 2017 08:03:21 -0400 Authentication-Results: arm.com; dkim=none (message not signed) header.d=none;arm.com; dmarc=none action=none header.from=caviumnetworks.com; From: Yury Norov To: Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Arnd Bergmann Cc: Yury Norov , Andrew Pinski , Andrew Pinski , Adam Borowski , Chris Metcalf , Steve Ellcey , Maxim Kuvyrkov , Ramana Radhakrishnan , Florian Weimer , Bamvor Zhangjian , Andreas Schwab , Chris Metcalf , Heiko Carstens , schwidefsky@de.ibm.com, broonie@kernel.org, Joseph Myers , christoph.muellner@theobroma-systems.com, szabolcs.nagy@arm.com, klimov.linux@gmail.com, Nathan_Lynch@mentor.com, agraf@suse.de, Prasun.Kapoor@caviumnetworks.com, geert@linux-m68k.org, philipp.tomsich@theobroma-systems.com, manuel.montezelo@gmail.com, linyongting@huawei.com, davem@davemloft.net, zhouchengming1@huawei.com, Andrew Pinski , Bamvor Jian Zhang Subject: [PATCH 14/20] arm64: ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it Date: Sun, 4 Jun 2017 15:00:03 +0300 Message-Id: <20170604120009.342-15-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170604120009.342-1-ynorov@caviumnetworks.com> References: <20170604120009.342-1-ynorov@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [176.59.55.28] X-ClientProxiedBy: HE1PR09CA0089.eurprd09.prod.outlook.com (10.174.50.161) To BY1PR0701MB1271.namprd07.prod.outlook.com (10.160.108.17) X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY1PR0701MB1271: X-MS-Office365-Filtering-Correlation-Id: e7b311cc-fadc-4bdc-60ce-08d4ab41a6e2 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(201703131423075)(201703031133081);SRVR:BY1PR0701MB1271; X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1271;3:mnjByDfQYWwdxGJ4xLlOaaJs6hh1w0hCrcb5WOniLhMFE/gVfBzbD3pxKvWIQE6tXo9VsBTrhce4aSYMYmkti1XL6Yt6iy6EL0yh1F4PbOvWKE9Q4zSJUuIx7iZClYInXVfbKY4ZJkuDncM6s1Q2edrmWHMJ7RYl6EiaY1h9R91nVlNggtKT0qib6l3oReiOHMYLviEc0wPXpd+TD4xlJMqnnPqMqLEFno7fDRqiIuUcsgZz6DUrm3D4b84QtSA7+e4ehcLAXEWHkCHtiOjuBBdy5Sg6FoK1cPlVEnfjHjvoIF/hT5qdtTlLJDT95LrQsfaIhLXPC4tle6AqF8wAyA==;25:I+ziwEPsGaFGTwuEZ8NdfplNmtOlWGtwfcou90QUQgV+Y6PDMwTk2+dCYF4LAqof/PAwsRjDJbW3b3CytBzDlemfxwWGCcvGGU3idD1f2ilDI7Lle8X8Q1GeFdlhaUc5RBQ8lboPBHhLppRjIlGOETcIF6+WSsjbaUULj9BpCU/6S3noeRh5G6koU/Dj5z86GyHr+/qDh0fPerAp50GRqNNBkPlCoqoHWWtJfAaP1sM1iNYNn6rohhULjzmQs/b2jXIrbN/dXRYDEWjKul7E9ehWFDevlhIMFbUJ9IEr/8VSFiZTDiTF2qyqaRtzReT/G0h80IdVu1gaBtAkmYS8B47W25By2zGI3xpON+SVb0dKuTXO5xWHnl0YaKJxCDm/7Zyj1lOH92xOPLNCKkLCoD3wSV1ExZ92q9s3pCqgI1ck2BFwvBLdGLEqpT+FudL/Mi1a2aL2T9BwonoY8ZZYtP7e9zCgad2CJTv4bgmR684= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1271;31:JyDXcT5JADxLLAc7p3KyR+CLH2b+B6kk1XJHhu9bCTuxsd+sP9tVeUTe94wgeZwV1zuUNbhMy9KfAu4mgI4DEWvTCNZ67IQiy4W46AILkBmnnUAQcEdnv8/P09cxqF12LD7bQV1qsSF79C5B1v2Pg/Ro46cQpWidTSUHjCXZeJ3WfzCZBUkodIqW3IiZsDzD4MllgxMf4U1jIEOe0El6x64dQQuE4bZVOYj7UIB0RC8=;20:kz+oBxGIboZhZ5+b8svGSZ7bnSnOEgkJzo7DQ+xhH8+zAoBQlI68BRRGzSmp+z8+yAYgHHg5KdNUe+9FInTAKAuQaBnCKdxPEwOw54cnGxpcxf0jm2oAm6yPrY/lG+ck3CL9rOsUN+47ad5b3gA3aSAMDG2GOMGGXLTOddSPMyF6Rm44zOdHKLC2BvnPfd4nee4mkDmhHckkhp4cTAdM5BqAVCmzpKy3l1ocOfKOQMV5jtRg5tktgMiUWuVowYFFOkk9sk1iIflfQYutpYk0wd2mgp1xVkbSncaTyShkoTppYnkQxDNA5ITI+XTELedRE1h8bZJykBVC1C82IrU/Em+ltfSHwUxnTIe8IBsDNJrgK1ZeLk/3LfSUOWQFRBqknAVMgn2ez7Tki7qXGkJYHOpSTLr2sKBXOBp29h85bPWmYwnDfE+Qp/vZkuUHiJuBZyYfwRgfMzGs9jK2nbf6zXkVAsFRJ6L8PQVe2vU193AqIHS4hRYcXC8upLe04gK1lZPkvWCQy+Z0N8zLLJKBhKF2xuKLyzt9mHNB99Cui4vHzPdY4dl+0GNVOJElh2TU714qRID8q44Ys2Db3EuKTo97prqOgfzVfFgZPbXVCZ8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(100000703101)(100105400095)(93006095)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123560025)(20161123555025)(20161123562025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:BY1PR0701MB1271;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:BY1PR0701MB1271; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1271;4:lDQpHhXlYGTO1bdHK1ZvboxM827S+h4k7LdxU2pP?= =?us-ascii?Q?kz89lDhy2R6EZVVbkNzKNeaYnooNrWpq86ceZlUCskYAZhp4gEhYjp7bb6lm?= =?us-ascii?Q?VcFT2yGfJU6EjxRYQ0iGUJnll8liWThnO7w9d/jAkjJzx7F5Y7Y3QRPOLTTe?= =?us-ascii?Q?raoG5djAN8FbNyklRBrCUY/HJ+CYCgr17cH8ViBDOl/SrKMKPQL+lUXkkTwQ?= =?us-ascii?Q?rFIPt9xps57Z8iTg86o8xM0k13u2c2i7r8A2N32tEGCtQ88fChmhQGH+L+pI?= =?us-ascii?Q?Sd01Oagd0nEIhH+OiTg9lE0H+/49UAfxt1FStzgmEkRzBzhF6q7SIxJ4qu4U?= =?us-ascii?Q?jS1ICyr1ZcjyTgoYh32SS1rDXQGwRLG/BNWUs8deO444X4g08zEWH5KGDmBm?= =?us-ascii?Q?rKQ+nQ9lmn9h612jwh/9jwNM7Qlukk/2BYqW6bT35W++lSAjLV2SAq3zL5Zb?= =?us-ascii?Q?8HeQ87dromamF4nRgLVmjVjoAxODQN5wguww/CjKc3M36ecfAoLv+4AFbdMN?= =?us-ascii?Q?cJKV1dPySDkPbPqV/gHaM9/218+e2bUh6Z2J9DrUxZe4kTvcyWP2/Dc+5+2G?= =?us-ascii?Q?apzSfFAcFbSSgzdkWAfj+l+2sHb4S4a+6ycLtNPnq+XtyYtx1yzAMoyilZTo?= =?us-ascii?Q?EZ/HCCzNM9RgVqVyorp/znwbMyjafDvGPHfX04Q6AlsKzk3A/Xt5jHnKhcCL?= =?us-ascii?Q?L4BfZ+rIjIH64Wqe7d8joR2H6FpfUtjx4RDhE7iX8uzNdUsqwJvvHoqLoRXD?= =?us-ascii?Q?qhTiEXvP9lZmmkasBJC5AaahKlp7ov08x4Uz79jMCJrvxoQ47C3y4jMVA3+0?= =?us-ascii?Q?3cT+4TQvE9b660RChk7jKDp12THKC5QkMxRPCsAYltoyLtjJBAPrRdWiPVGw?= =?us-ascii?Q?UqtSB7Ibd8IXW4ooTPWTLQi9aOMasTp4Ta778n4aUOKkEVC3CD6L3ZhlykJh?= =?us-ascii?Q?00uVszLNxcgK0mNaIMS6FLq+Sd7Z+UGc5Qsv9XIokqcWKK9m6Y4bS1XnLpBP?= =?us-ascii?Q?PgwsRu0IGh08Ha0KAkPyeF/DnCwBsag6UCPaNmHcrjgdKFx8GwRfSwZ/u74Z?= =?us-ascii?Q?ylpO3y8jpVuxPRAvltKBHKDuodBfPv29kVGeoYNBIDBtMFlWKw+7CPM+s6Fp?= =?us-ascii?Q?QZt09qYJpzYJB2NV/RszFZ70vYX4HYRVC1cMoLIs7FfFd9TlRg3EfLRwfWmn?= =?us-ascii?Q?CSRz1NVLQFAj08muNck5KXmZpIPB9NbA1KKh?= X-Forefront-PRVS: 03283976A6 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(4630300001)(6009001)(6069001)(39410400002)(39400400002)(39850400002)(81166006)(8676002)(76176999)(50226002)(42882006)(2950100002)(48376002)(50466002)(50986999)(33646002)(47776003)(5660300001)(189998001)(305945005)(7406005)(53936002)(7416002)(36756003)(76506005)(66066001)(42186005)(54906002)(5003940100001)(25786009)(2906002)(1076002)(6116002)(3846002)(6306002)(6496005)(72206003)(575784001)(6486002)(38730400002)(478600001)(4326008);DIR:OUT;SFP:1101;SCL:1;SRVR:BY1PR0701MB1271;H:localhost;FPR:;SPF:None;MLV:sfv;LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;BY1PR0701MB1271;23:zAGw3Znr4+vwr5STLJUVamPkfqFyqbAXnBEj563?= =?us-ascii?Q?O2llHnCd6O3dAdftudoWeYCaIZRMjYXSCIVzHOdrX2P0te/eq48LJmRYyY8s?= =?us-ascii?Q?+6ajjfXCcawumDCGxnOKF0fOQ9WwXbQL5ImxUovj6LuA+6kFN0VOMcNBKBpj?= =?us-ascii?Q?1YH0pxy5+a8FMEyV2sWx6YYJ+tcZZzsXS7XiZ57zgJE6uYH9KtqmVD+GUZBd?= =?us-ascii?Q?M74C7A4CFitmdqkMS9JWkj46GdeBw4YAq5ZRNMyiqr9fzY3s61Q6zqgZcyF4?= =?us-ascii?Q?lnNz3s0ucHg3WpixR0Ilp/2Ny2Fp9VoZ263Vp3v3sBI6wwVWmC6mDvATirVN?= =?us-ascii?Q?BtXfnUTtwcGSNX6SgM3Ph653Zlr5RSB2ntYnDnTtE7a1eoJ2YeDEEVL9G0r8?= =?us-ascii?Q?2MgeXBDxQzHocyq1Lk9/F17JCQIhKk3zIzvhMfEU7Ijoei9kXzF8z94U+GZt?= =?us-ascii?Q?YoXpccYGiW93Y6XbllkTl2h2IJoOwDcq0vEoizuWYSUJgZq8wxUe1SLVk2hm?= =?us-ascii?Q?mXGIhfj560tT/cuYuO+dJnDfRdgfUWfgDwscN8ztHdXBrstrlIRwdTgRc8qf?= =?us-ascii?Q?v20kdj6zcHIgND0JwB5Xkac979X1XMxdwH3BpJQ9a//R08Am+2nc46aqIct+?= =?us-ascii?Q?H/+KFVbvQUAxXE/hQtkYOsbjXNfWa2j2qOm6+sYLLy/fE8nEhiabZ4DN3xrL?= =?us-ascii?Q?5ljG0Ax3OFt5rGIBNtGld3OqUjbH/afnn+E5GVWJb0yq99RzqLDfvZX5/Eet?= =?us-ascii?Q?sirl6dnRiaasdE7UY097tzw3z+KWoQtG+MLvWCHifLeIzjm4VqZ0kagAwICR?= =?us-ascii?Q?1+I4es3kHQRIPgBnwNzPlUj/boglcKPiEnXqcja2nwd7eGYFy09ap+cd1lK8?= =?us-ascii?Q?pNr53ZLmftdlrq6bgV8L8xXS0s1XWU4gC8X8U3Dto5uqVLTktEQ+YQQJidZ7?= =?us-ascii?Q?TyRy7qh5xuWVLl6cOlUHnZwqTW72EVKFNAuIF/jxs7a7d2K4upaVzSxG+ZzS?= =?us-ascii?Q?GJE5qXb8QH7TNwUafmOj0JOplP3TH03QqEBH3VBmDemZTt53KRvGVO9V6fgR?= =?us-ascii?Q?xGbX/jEA=3D?= X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1271;6:vz1Fl6r1soKHVTnxqdH/XhC6NJtXKfOQiYIo2aOmcyoVIy3/aG6lIF6NUMATxTMnxGtUDA1OPPbq06N6pmvPIN4D+RufzoK3JM45TcKkv7/pyrTmeKHXh9IBlvqwj5RZX4lMgux8XwO3euiDUsWLzR/goaCXE7A3OQQfdwgFQukCMdp6GRlq5Jp+cb1cszmCuwDVa7VjazLoN8GMX9LG/K9FlqN/+QHjvFmvfJO53VM35zBcgWYq4WRS7kVcu4DuVdrOs1hUHN8lzIVW+95cLllG/ZPl0cpQubgyS6UvAASGm6Djpt0mIkGMslucEcMg0fKniKKQ6/0+6MeBOYJ+/M64L9AjSUFGJmuO+NIytWiS/xwotKftBVDUfdPpUgNSdtSxLSbI4m/LyUNfk5D43Ofuh/KIv1irXVEViYLMoGZESV3BpSgCbokStW9IMXSBkc+uXrfAOcA1W62oMXr3CnVc6QYZlJOPN5Ut8Fbn7vx9KNnup77x71+tBuBuKFC/bzOOKQKIjHHSnRvb64fN/Q== X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1271;5:tfYq0JQmML6AS8mjC1FamBvkrBh0CQH5n4/S1/Rf4Wf3xywmvwTeA7XOjZ90ZN7LvOzOq8jv+hA4CnbeGCkFFliVTDP0ML7v0k1lUwEzIJ/9q4qWfuOMeUE2ixJN/DUJcK8YSr/t7utB9Y4RdLr7HG4H8b+6cT9QxijT2r5/UBxuG9+OPeK6sPuCR0LwDrbLDiFtl9TMEoRt/VCvgmwN38OVeac6GnBPuWjYB75mw3G1RpOHRuSUA40Q+4i6hYLYt7yDKAmT8Xdopx13VnVWtwMOgGHVIuDSIcg/RBiBj10kJRyOGQRlavMc3vfm1wpKnxwf9gUrXoDzUE2NmWp2mSQ2xDMBXAHItBxZOe/jBi1Q9Pjx3k3FiJkO12RYczBCKa0QOOiEt/IiC2CKZmXUgXXNEj/3YvXQ2ln1Qtz+QPRdH24pIZ38ptucPcSK2eAc+v4oFSWYehbAhjxaN3pXXe+KSJQocfQ475IR6MJy1wItmMGIpxXQoTkexjSTfT7t;24:ZSYRL6s0L7k1AnqIYI2NRnsKgZW7j4cNOlqUJE6nf4jDfI2CdeR6wZTCBX+3OVqrgV2Yxbs4DD2x/Zy07lJ9eKY4zmimcMRvL8hNAsprZ10= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BY1PR0701MB1271;7:MpnFGxZevmGxibgK2V53sDjTHhEEb8tpPzMDYB7Oi5OmNKXKtNtxOOtSTdobj1xei8n6ZDgmTGhHs6cu1AMFi8eAVl8KC+ePQWNNTwmKg1TNj1OR1xRwgMLmfyHnsGvxm9v0pbtLxlJMSmkKhgAPUUyYfGtTbn94Vf1f2HUORjDUVcxnwMsg00jj5+aru104wxArnk3EU3gKvNWlJbWcf/U05vi26CCfj3g7J09g92XCS9pcrSrBqXHfxOt4PyloxotRw9vsnaN0We1BACm1/IMksQuU+4T+LIEUtKeJl6Dqzd0gz2fwHl88s6D713CVRuOWdO/XWhAEqIhnWV9oxQ== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jun 2017 12:03:02.1222 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY1PR0701MB1271 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrew Pinski Add a separate syscall-table for ILP32, which dispatches either to native LP64 system call implementation or to compat-syscalls, as appropriate. Signed-off-by: Andrew Pinski Signed-off-by: Yury Norov Signed-off-by: Bamvor Jian Zhang --- arch/arm64/include/asm/unistd.h | 8 ++- arch/arm64/include/uapi/asm/unistd.h | 12 +++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/entry.S | 28 +++++++++- arch/arm64/kernel/sys_ilp32.c | 100 +++++++++++++++++++++++++++++++++++ 5 files changed, 145 insertions(+), 5 deletions(-) create mode 100644 arch/arm64/kernel/sys_ilp32.c diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h index 99d29290c98b..1bf5572cd078 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -13,12 +13,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifdef CONFIG_AARCH32_EL0 + +#ifdef CONFIG_COMPAT #define __ARCH_WANT_COMPAT_STAT64 +#define __ARCH_WANT_SYS_LLSEEK +#endif + +#ifdef CONFIG_AARCH32_EL0 #define __ARCH_WANT_SYS_GETHOSTNAME #define __ARCH_WANT_SYS_PAUSE #define __ARCH_WANT_SYS_GETPGRP -#define __ARCH_WANT_SYS_LLSEEK #define __ARCH_WANT_SYS_NICE #define __ARCH_WANT_SYS_SIGPENDING #define __ARCH_WANT_SYS_SIGPROCMASK diff --git a/arch/arm64/include/uapi/asm/unistd.h b/arch/arm64/include/uapi/asm/unistd.h index 48355a683e25..e7106bb45095 100644 --- a/arch/arm64/include/uapi/asm/unistd.h +++ b/arch/arm64/include/uapi/asm/unistd.h @@ -14,7 +14,19 @@ * along with this program. If not, see . */ +/* + * Use AARCH32 interface for sys_sync_file_range() as it passes 64-bit arguments. + */ +#if defined(__ILP32__) || defined(__SYSCALL_COMPAT) +#define __ARCH_WANT_SYNC_FILE_RANGE2 +#endif + +/* + * AARCH64/ILP32 is introduced after next syscalls were deprecated. + */ +#if !(defined(__ILP32__) || defined(__SYSCALL_COMPAT)) #define __ARCH_WANT_RENAMEAT #define __ARCH_WANT_SET_GET_RLIMIT +#endif #include diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index f6f12e2e5010..7e0c48f858f1 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,7 +29,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.o binfmt_elf32.o -arm64-obj-$(CONFIG_ARM64_ILP32) += binfmt_ilp32.o +arm64-obj-$(CONFIG_ARM64_ILP32) += binfmt_ilp32.o sys_ilp32.o arm64-obj-$(CONFIG_COMPAT) += entry32_common.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 279bc2ab10c3..7d52fe1ec6bd 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -308,6 +308,23 @@ tsk .req x28 // current thread_info .text +#ifdef CONFIG_ARM64_ILP32 +/* + * AARCH64/ILP32. Zero top halves of x0-x7 + * registers as userspace may put garbage there. + */ + .macro delouse_input_regs + mov w0, w0 + mov w1, w1 + mov w2, w2 + mov w3, w3 + mov w4, w4 + mov w5, w5 + mov w6, w6 + mov w7, w7 + .endm +#endif + /* * Exception vectors. */ @@ -577,6 +594,7 @@ el0_svc_compat: * AArch32 syscall handling */ adrp stbl, compat_sys_call_table // load compat syscall table pointer + ldr x16, [tsk, #TSK_TI_FLAGS] uxtw scno, w7 // syscall number in w7 (r7) mov sc_nr, #__NR_compat_syscalls b el0_svc_naked @@ -798,15 +816,21 @@ ENDPROC(ret_from_fork) .align 6 el0_svc: adrp stbl, sys_call_table // load syscall table pointer + ldr x16, [tsk, #TSK_TI_FLAGS] uxtw scno, w8 // syscall number in w8 mov sc_nr, #__NR_syscalls +#ifdef CONFIG_ARM64_ILP32 + tst x16, #_TIF_32BIT_AARCH64 + b.eq el0_svc_naked // We are using LP64 syscall table + adrp stbl, sys_call_ilp32_table // load ilp32 syscall table pointer + delouse_input_regs +#endif el0_svc_naked: // compat entry point stp x0, scno, [sp, #S_ORIG_X0] // save the original x0 and syscall number enable_dbg_and_irq ct_user_exit 1 - ldr x16, [tsk, #TSK_TI_FLAGS] // check for syscall hooks - tst x16, #_TIF_SYSCALL_WORK + tst x16, #_TIF_SYSCALL_WORK // check for syscall hooks b.ne __sys_trace cmp scno, sc_nr // check upper syscall limit b.hs ni_sys diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c new file mode 100644 index 000000000000..d203dec7011b --- /dev/null +++ b/arch/arm64/kernel/sys_ilp32.c @@ -0,0 +1,100 @@ +/* + * AArch64- ILP32 specific system calls implementation + * + * Copyright (C) 2017 Cavium Inc. + * Author: Andrew Pinski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#define __SYSCALL_COMPAT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * AARCH32 requires 4-page alignement for shared memory, + * but AARCH64 - only 1 page. This is the only difference + * between compat and native sys_shmat(). So ILP32 just pick + * AARCH64 version. + */ +#define compat_sys_shmat sys_shmat + +/* + * ILP32 needs special handling for some ptrace requests. + */ +#define sys_ptrace compat_sys_ptrace + +/* + * Using AARCH32 interface for syscalls that take 64-bit + * parameters in registers. + */ +#define compat_sys_fadvise64_64 compat_sys_fadvise64_64_wrapper +#define compat_sys_fallocate compat_sys_fallocate_wrapper +#define compat_sys_ftruncate64 compat_sys_ftruncate64_wrapper +#define compat_sys_pread64 compat_sys_pread64_wrapper +#define compat_sys_pwrite64 compat_sys_pwrite64_wrapper +#define compat_sys_readahead compat_sys_readahead_wrapper +#define compat_sys_sync_file_range2 compat_sys_sync_file_range2_wrapper +#define compat_sys_truncate64 compat_sys_truncate64_wrapper +#define sys_mmap2 compat_sys_mmap2_wrapper + +/* + * Using AARCH32 interface for syscalls that take the size of + * sfruct statfs as an argument, as it's calculated differently + * in kernel and user spaces. + */ +#define compat_sys_fstatfs64 compat_sys_fstatfs64_wrapper +#define compat_sys_statfs64 compat_sys_statfs64_wrapper + +/* + * Using custom wrapper for rt_sigreturn() to handle custom + * struct rt_sigframe. + */ +#define compat_sys_rt_sigreturn ilp32_sys_rt_sigreturn_wrapper + +asmlinkage long compat_sys_fstatfs64_wrapper(void); +asmlinkage long compat_sys_statfs64_wrapper(void); +asmlinkage long compat_sys_fadvise64_64_wrapper(void); +asmlinkage long compat_sys_fallocate_wrapper(void); +asmlinkage long compat_sys_ftruncate64_wrapper(void); +asmlinkage long compat_sys_mmap2_wrapper(void); +asmlinkage long compat_sys_pread64_wrapper(void); +asmlinkage long compat_sys_pwrite64_wrapper(void); +asmlinkage long compat_sys_readahead_wrapper(void); +asmlinkage long compat_sys_sync_file_range2_wrapper(void); +asmlinkage long compat_sys_truncate64_wrapper(void); +asmlinkage long ilp32_sys_rt_sigreturn_wrapper(void); + +#include + +#undef __SYSCALL +#define __SYSCALL(nr, sym) [nr] = sym, + +/* + * The sys_call_ilp32_table array must be 4K aligned to be accessible from + * kernel/entry.S. + */ +void *sys_call_ilp32_table[__NR_syscalls] __aligned(4096) = { + [0 ... __NR_syscalls - 1] = sys_ni_syscall, +#include +}; -- 2.11.0 From mboxrd@z Thu Jan 1 00:00:00 1970 From: ynorov@caviumnetworks.com (Yury Norov) Date: Sun, 4 Jun 2017 15:00:03 +0300 Subject: [PATCH 14/20] arm64: ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it In-Reply-To: <20170604120009.342-1-ynorov@caviumnetworks.com> References: <20170604120009.342-1-ynorov@caviumnetworks.com> Message-ID: <20170604120009.342-15-ynorov@caviumnetworks.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org From: Andrew Pinski Add a separate syscall-table for ILP32, which dispatches either to native LP64 system call implementation or to compat-syscalls, as appropriate. Signed-off-by: Andrew Pinski Signed-off-by: Yury Norov Signed-off-by: Bamvor Jian Zhang --- arch/arm64/include/asm/unistd.h | 8 ++- arch/arm64/include/uapi/asm/unistd.h | 12 +++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/entry.S | 28 +++++++++- arch/arm64/kernel/sys_ilp32.c | 100 +++++++++++++++++++++++++++++++++++ 5 files changed, 145 insertions(+), 5 deletions(-) create mode 100644 arch/arm64/kernel/sys_ilp32.c diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h index 99d29290c98b..1bf5572cd078 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -13,12 +13,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -#ifdef CONFIG_AARCH32_EL0 + +#ifdef CONFIG_COMPAT #define __ARCH_WANT_COMPAT_STAT64 +#define __ARCH_WANT_SYS_LLSEEK +#endif + +#ifdef CONFIG_AARCH32_EL0 #define __ARCH_WANT_SYS_GETHOSTNAME #define __ARCH_WANT_SYS_PAUSE #define __ARCH_WANT_SYS_GETPGRP -#define __ARCH_WANT_SYS_LLSEEK #define __ARCH_WANT_SYS_NICE #define __ARCH_WANT_SYS_SIGPENDING #define __ARCH_WANT_SYS_SIGPROCMASK diff --git a/arch/arm64/include/uapi/asm/unistd.h b/arch/arm64/include/uapi/asm/unistd.h index 48355a683e25..e7106bb45095 100644 --- a/arch/arm64/include/uapi/asm/unistd.h +++ b/arch/arm64/include/uapi/asm/unistd.h @@ -14,7 +14,19 @@ * along with this program. If not, see . */ +/* + * Use AARCH32 interface for sys_sync_file_range() as it passes 64-bit arguments. + */ +#if defined(__ILP32__) || defined(__SYSCALL_COMPAT) +#define __ARCH_WANT_SYNC_FILE_RANGE2 +#endif + +/* + * AARCH64/ILP32 is introduced after next syscalls were deprecated. + */ +#if !(defined(__ILP32__) || defined(__SYSCALL_COMPAT)) #define __ARCH_WANT_RENAMEAT #define __ARCH_WANT_SET_GET_RLIMIT +#endif #include diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index f6f12e2e5010..7e0c48f858f1 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,7 +29,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.o binfmt_elf32.o -arm64-obj-$(CONFIG_ARM64_ILP32) += binfmt_ilp32.o +arm64-obj-$(CONFIG_ARM64_ILP32) += binfmt_ilp32.o sys_ilp32.o arm64-obj-$(CONFIG_COMPAT) += entry32_common.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 279bc2ab10c3..7d52fe1ec6bd 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -308,6 +308,23 @@ tsk .req x28 // current thread_info .text +#ifdef CONFIG_ARM64_ILP32 +/* + * AARCH64/ILP32. Zero top halves of x0-x7 + * registers as userspace may put garbage there. + */ + .macro delouse_input_regs + mov w0, w0 + mov w1, w1 + mov w2, w2 + mov w3, w3 + mov w4, w4 + mov w5, w5 + mov w6, w6 + mov w7, w7 + .endm +#endif + /* * Exception vectors. */ @@ -577,6 +594,7 @@ el0_svc_compat: * AArch32 syscall handling */ adrp stbl, compat_sys_call_table // load compat syscall table pointer + ldr x16, [tsk, #TSK_TI_FLAGS] uxtw scno, w7 // syscall number in w7 (r7) mov sc_nr, #__NR_compat_syscalls b el0_svc_naked @@ -798,15 +816,21 @@ ENDPROC(ret_from_fork) .align 6 el0_svc: adrp stbl, sys_call_table // load syscall table pointer + ldr x16, [tsk, #TSK_TI_FLAGS] uxtw scno, w8 // syscall number in w8 mov sc_nr, #__NR_syscalls +#ifdef CONFIG_ARM64_ILP32 + tst x16, #_TIF_32BIT_AARCH64 + b.eq el0_svc_naked // We are using LP64 syscall table + adrp stbl, sys_call_ilp32_table // load ilp32 syscall table pointer + delouse_input_regs +#endif el0_svc_naked: // compat entry point stp x0, scno, [sp, #S_ORIG_X0] // save the original x0 and syscall number enable_dbg_and_irq ct_user_exit 1 - ldr x16, [tsk, #TSK_TI_FLAGS] // check for syscall hooks - tst x16, #_TIF_SYSCALL_WORK + tst x16, #_TIF_SYSCALL_WORK // check for syscall hooks b.ne __sys_trace cmp scno, sc_nr // check upper syscall limit b.hs ni_sys diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c new file mode 100644 index 000000000000..d203dec7011b --- /dev/null +++ b/arch/arm64/kernel/sys_ilp32.c @@ -0,0 +1,100 @@ +/* + * AArch64- ILP32 specific system calls implementation + * + * Copyright (C) 2017 Cavium Inc. + * Author: Andrew Pinski + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#define __SYSCALL_COMPAT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * AARCH32 requires 4-page alignement for shared memory, + * but AARCH64 - only 1 page. This is the only difference + * between compat and native sys_shmat(). So ILP32 just pick + * AARCH64 version. + */ +#define compat_sys_shmat sys_shmat + +/* + * ILP32 needs special handling for some ptrace requests. + */ +#define sys_ptrace compat_sys_ptrace + +/* + * Using AARCH32 interface for syscalls that take 64-bit + * parameters in registers. + */ +#define compat_sys_fadvise64_64 compat_sys_fadvise64_64_wrapper +#define compat_sys_fallocate compat_sys_fallocate_wrapper +#define compat_sys_ftruncate64 compat_sys_ftruncate64_wrapper +#define compat_sys_pread64 compat_sys_pread64_wrapper +#define compat_sys_pwrite64 compat_sys_pwrite64_wrapper +#define compat_sys_readahead compat_sys_readahead_wrapper +#define compat_sys_sync_file_range2 compat_sys_sync_file_range2_wrapper +#define compat_sys_truncate64 compat_sys_truncate64_wrapper +#define sys_mmap2 compat_sys_mmap2_wrapper + +/* + * Using AARCH32 interface for syscalls that take the size of + * sfruct statfs as an argument, as it's calculated differently + * in kernel and user spaces. + */ +#define compat_sys_fstatfs64 compat_sys_fstatfs64_wrapper +#define compat_sys_statfs64 compat_sys_statfs64_wrapper + +/* + * Using custom wrapper for rt_sigreturn() to handle custom + * struct rt_sigframe. + */ +#define compat_sys_rt_sigreturn ilp32_sys_rt_sigreturn_wrapper + +asmlinkage long compat_sys_fstatfs64_wrapper(void); +asmlinkage long compat_sys_statfs64_wrapper(void); +asmlinkage long compat_sys_fadvise64_64_wrapper(void); +asmlinkage long compat_sys_fallocate_wrapper(void); +asmlinkage long compat_sys_ftruncate64_wrapper(void); +asmlinkage long compat_sys_mmap2_wrapper(void); +asmlinkage long compat_sys_pread64_wrapper(void); +asmlinkage long compat_sys_pwrite64_wrapper(void); +asmlinkage long compat_sys_readahead_wrapper(void); +asmlinkage long compat_sys_sync_file_range2_wrapper(void); +asmlinkage long compat_sys_truncate64_wrapper(void); +asmlinkage long ilp32_sys_rt_sigreturn_wrapper(void); + +#include + +#undef __SYSCALL +#define __SYSCALL(nr, sym) [nr] = sym, + +/* + * The sys_call_ilp32_table array must be 4K aligned to be accessible from + * kernel/entry.S. + */ +void *sys_call_ilp32_table[__NR_syscalls] __aligned(4096) = { + [0 ... __NR_syscalls - 1] = sys_ni_syscall, +#include +}; -- 2.11.0