From patchwork Tue Apr 5 22:08:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8756091 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 41A3DC0553 for ; Tue, 5 Apr 2016 22:20:04 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 13345202BE for ; Tue, 5 Apr 2016 22:20:03 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD157201FA for ; Tue, 5 Apr 2016 22:20:01 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1anZIf-0006Nv-0Q; Tue, 05 Apr 2016 22:18:17 +0000 Received: from mail-bl2on0057.outbound.protection.outlook.com ([65.55.169.57] helo=na01-bl2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1anZDf-0008QR-2a for linux-arm-kernel@lists.infradead.org; Tue, 05 Apr 2016 22:13:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:To:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=5oTxiHjWo6nGjRrSDbKkiWth8UoGOXXWBALwunkZjO4=; b=GDDkWkcaeAPSk5D1qb8RBJiKX5NXDLW88uESm91ERoGryMDQNVBNquR9Fa920lTmBBJellLbtsJeyZargAQD75/qkI5eQjsb7jAgOzkmRHaaKUhY8KTMFNQJz1h4qGVDMtHZT7maHo0ZkN24F8hbQ6RcZfarh2eKTi9GqtBhgA0= Authentication-Results: arndb.de; dkim=none (message not signed) header.d=none;arndb.de; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost (95.143.213.121) by BLUPR07MB612.namprd07.prod.outlook.com (10.141.207.27) with Microsoft SMTP Server (TLS) id 15.1.443.12; Tue, 5 Apr 2016 22:12:43 +0000 From: Yury Norov To: , , , Subject: [PATCH 20/25] arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it Date: Wed, 6 Apr 2016 01:08:42 +0300 Message-ID: <1459894127-17698-21-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1459894127-17698-1-git-send-email-ynorov@caviumnetworks.com> References: <1459894127-17698-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM2PR03CA0032.eurprd03.prod.outlook.com (25.160.207.42) To BLUPR07MB612.namprd07.prod.outlook.com (10.141.207.27) X-MS-Office365-Filtering-Correlation-Id: b61edb24-a662-482b-8282-08d35d9f698a X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB612; 2:iNhBb4QcwXY4c1ln4t/td6WKpGVoDcJ7KCsaIHloVl4vZfvC9PH52OI/FZrVLJ8+HzD+8hLgoVcR3kf5tAEdw6PkwYQ/JwYCBwEAOTcwbpskijvZTnWtwpnsJkCt4VVapJE+Q26pZKIWtTY6mYrdoP4nJDyltB48JNi62bnpwPe6PHG1rdOcWvfHotwZQOk0; 3:MGy6sq1nXjZ3T2ramxZ8HZSFFGZu68gNwCnQXhegznyFF62AtK58Bu6EJBdOSeLP4WjjGgPPP9Dw1lN5KMQlZQDylTTEvFgijBSG7C85J0CRMIjrm2GuNK/1QwRp6HbY X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB612; X-Microsoft-Exchange-Diagnostics: 1; BLUPR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9p63Et83QKMrAe14DtL1kOq7RlOCIAThP7weh21dAp8dx+Acx9LxzzuDF1vGOzfSgD/hXTDuzMVU96+OKFkUQsy4b2BY3I2v4GoHyMxCOOmyoc4ohHIorMZQYKSmxYaqXVF6e+3cNgfvQCCQidBJiRZ/8OjR0VPDdbIn54YZ5GOfuEbk6ZZiUem4uccGBm/vXENN67PQJFrfsEj1ci2nQhGLYnLBUuN90iae9bH9aQczrb69bqjDKQMFhxLK0os0MVfJGIe9CNExs6W1xUXlPHBxnCD6v+tOd9ce6g/pvPLtjdbXCfXQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046); SRVR:BLUPR07MB612; BCL:0; PCL:0; RULEID:; SRVR:BLUPR07MB612; X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB612; 4:ERXJQVRag4Xk+AoKjvSdfXfqJ9ASozQVqTachSxTnvfNMXrEuj7P+PgfAhYt/Da/y7OYsaRGe1NrS5hTbIna6vopd7tQOsRUOwrlmr7baeMrNhdOJChjQuYc5rN8u8fDbE7BvGgCeWGnDCNW0XRe/e0XT0YkVLkywGD3bhxhNQIeQJVmlYpSdtwEPEpWZ7nb0Iq119jIyAVstojZWIggq/C2GhdouI4OJaMR0/Gzl2DL9yQA7803DLQ99wsdjOBAE5PBtXUgwttL4FR5GNnE6aq31XyGoaTsxnbJZ7D2yAjL1rxV5u6Ato1KVHN5T2O7u5aL1NjKDiXNJj8WwJDozPsa5EqJpETmSDnX3YWu1vQ2W8qelcfevToqyStaApO2 X-Forefront-PRVS: 0903DD1D85 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(4001430100002)(33646002)(5008740100001)(3846002)(229853001)(92566002)(19580395003)(77096005)(5004730100002)(1096002)(36756003)(2201001)(50466002)(48376002)(50226001)(47776003)(15975445007)(42186005)(66066001)(4326007)(76506005)(76176999)(107886002)(6116002)(50986999)(5003940100001)(586003)(81166005)(19580405001)(2950100001)(5001770100001)(189998001)(2906002)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR07MB612; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR07MB612; 23:kYXxNcif5oMKMYzDNdT6vbJGKwAeWoIZecXEeqTVex?= =?us-ascii?Q?tkf+Ns2usZfFE2a2tZML4ojVbPFlbHnop2lWAGOGQVjN+QXxERmHXMtHVoX7?= =?us-ascii?Q?WTH/15rBsDGwZC8TjnrBazdm4mxkWiuu+yhO93F76cBg5kwvfcbwn2jnXLIJ?= =?us-ascii?Q?zK7HyIP/TQqnnY9EJpBPq1FDnD4Nuyabm3mG6c0dWf7GwLUhyUxK3bPEmWRt?= =?us-ascii?Q?VnZN0H7itzcJCLogYdrJDZYokB5PUXOb05XyNvk1Tm++gBjtl4ecqhf3NOMM?= =?us-ascii?Q?df96SC8aGlohlkrW+xBUlre39IPPCQZLizAf2Wdlw6f2i9il9E8JMGh3nSVO?= =?us-ascii?Q?JfmVnyJrtciI8i5XjRa5sifGtQYeeuXm3y80bG1BjIVW6PuZ2HyBapeXdN/H?= =?us-ascii?Q?xsa7IlTFmgOnEnrsHWzBS0cIRa/8QSzN4eZHvlq35SDO9y+ugtudn1LFq70P?= =?us-ascii?Q?aCW3ghTX/CaC8ycTWzx8PUXidvkaWNzu5hoKsrtbm3TsnlJMBAV+a4cq3tkf?= =?us-ascii?Q?VFaf6Z1Mhfhc8wzwdN/ECwk1D50rQK4wnEuMgfXGm6mr4309+kLE0YYUKAwZ?= =?us-ascii?Q?+r3YYJ69PIocAmRisDQV4psJbAPlams2PR/jjm0MId7WkDA8UpksCzMnveKj?= =?us-ascii?Q?1UbHXrOhfuDJ9aTinJ4FQ4aNj4MR1DXzVUFFbj4JjN/50r5KZdgs/D5ZlHi+?= =?us-ascii?Q?bW4To0EPy/jiZrsWQoRGignfVA3opb2fRz4OJ9VREehdOo8JasfvaL1cOqoh?= =?us-ascii?Q?LTVaMJ3XoABadNiQo0A+mnyAC0DkvhIM58lVCMx1eJX6dniymzXobG7Obkum?= =?us-ascii?Q?p1ySawmonDUPWNWbG+ZrupeYyENhVR1D82Ffkxn3Zd4sZvv3GqBz91qkqsUK?= =?us-ascii?Q?5O51SwBNQuDSp9n/5Ubw+Fj5PLf9byv9E/UhIyKTQMZdOWTTLl57nhMr9sHY?= =?us-ascii?Q?TPcV87BJYTywEZmb3PC6naVM1nCOnnr4d7hmj8EfyKvG1dfGnOJsR7MzNagm?= =?us-ascii?Q?G6le4Jwo3ln+xVAmp09+oj9hmCi7mWXcR3CKjciSwEMA=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB612; 5:bjwRNBpl578VCR8qEq30zDS3hjVP3e7l3xZ8D9C5vv2RsHoo79rwDSF0Gz7LenNYMHUHBVma+musDZkszWpJiB5jaQeKAcdQrmf9wBiLFVlQFGUyEhyEhv62z5lk5ehmznwGkgWpdAiWF8k5SxD7oA==; 24:WK9cEvDSWGwdQk4UpdGecxWb1GyfZ/YRskY0V2XZLHCYbnXFPpCKko9q5nrUh3eUU5hTfzYnkBjHKpgSSkEPvupAcWMbpWQd+5B4Wo8uziA= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2016 22:12:43.7958 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR07MB612 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160405_151308_281492_C681A7AE X-CRM114-Status: GOOD ( 13.27 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, schwab@suse.de, broonie@kernel.org, linux-doc@vger.kernel.org, heiko.carstens@de.ibm.com, agraf@suse.de, klimov.linux@gmail.com, Andrew Pinski , ynorov@caviumnetworks.com, bamvor.zhangjian@huawei.com, Andrew Pinski , schwidefsky@de.ibm.com, Nathan_Lynch@mentor.com, joseph@codesourcery.com, christoph.muellner@theobroma-systems.com Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- arch/arm64/include/asm/unistd.h | 11 ++++++- arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/entry.S | 12 +++++++- arch/arm64/kernel/sys_ilp32.c | 65 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 87 insertions(+), 3 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 2971dea..5ea18ef 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -13,9 +13,18 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +#ifdef CONFIG_COMPAT +#define __ARCH_WANT_COMPAT_STAT64 +#endif + +#ifdef CONFIG_ARM64_ILP32 +#define __ARCH_WANT_COMPAT_SYS_PREADV64 +#define __ARCH_WANT_COMPAT_SYS_PWRITEV64 +#endif + #ifdef CONFIG_AARCH32_EL0 #define __ARCH_WANT_COMPAT_SYS_GETDENTS64 -#define __ARCH_WANT_COMPAT_STAT64 #define __ARCH_WANT_SYS_GETHOSTNAME #define __ARCH_WANT_SYS_PAUSE #define __ARCH_WANT_SYS_GETPGRP diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 9dfdf86..7aa65ea 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -28,7 +28,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.o \ ../../arm/kernel/opcodes.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_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o arm64-obj-$(CONFIG_ARM64_MODULE_PLTS) += module-plts.o diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index cf4d1ae..1f7a145 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -715,9 +715,13 @@ ENDPROC(ret_from_fork) */ .align 6 el0_svc: - adrp stbl, sys_call_table // load syscall table pointer uxtw scno, w8 // syscall number in w8 mov sc_nr, #__NR_syscalls +#ifdef CONFIG_ARM64_ILP32 + ldr x16, [tsk, #TI_FLAGS] + tbnz x16, #TIF_32BIT_AARCH64, el0_ilp32_svc // We are using ILP32 +#endif + adrp stbl, sys_call_table // load syscall table pointer el0_svc_naked: // compat entry point stp x0, scno, [sp, #S_ORIG_X0] // save the original x0 and syscall number enable_dbg_and_irq @@ -737,6 +741,12 @@ ni_sys: b ret_fast_syscall ENDPROC(el0_svc) +#ifdef CONFIG_ARM64_ILP32 +el0_ilp32_svc: + adrp stbl, sys_call_ilp32_table // load syscall table pointer + b el0_svc_naked +#endif + /* * This is the really slow path. We're going to be doing context * switches, and waiting for our parent to respond. diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c new file mode 100644 index 0000000..0996d8e --- /dev/null +++ b/arch/arm64/kernel/sys_ilp32.c @@ -0,0 +1,65 @@ +/* + * AArch64- ILP32 specific system calls implementation + * + * Copyright (C) 2016 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 . + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Using non-compat syscalls where necessary */ +#define compat_sys_fadvise64_64 sys_fadvise64_64 +#define compat_sys_fallocate sys_fallocate +#define compat_sys_ftruncate64 sys_ftruncate +#define compat_sys_lookup_dcookie sys_lookup_dcookie +#define compat_sys_pread64 sys_pread64 +#define compat_sys_pwrite64 sys_pwrite64 +#define compat_sys_readahead sys_readahead +#define compat_sys_shmat sys_shmat +#define compat_sys_sync_file_range sys_sync_file_range +#define compat_sys_truncate64 sys_truncate +#define sys_llseek sys_lseek +#define sys_mmap2 sys_mmap + +#include + +#undef __SYSCALL +#undef __SC_COMP +#undef __SC_WRAP +#undef __SC_3264 +#undef __SC_COMP_3264 + +#define __SYSCALL_COMPAT +#define __SYSCALL(nr, sym) [nr] = sym, +#define __SC_WRAP(nr, sym) [nr] = compat_##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 +};