From patchwork Thu Jan 14 17:23:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 8034711 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 4338BBEEE5 for ; Thu, 14 Jan 2016 17:37:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3F9D02044B for ; Thu, 14 Jan 2016 17:37:16 +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 F0B1B20439 for ; Thu, 14 Jan 2016 17:37:14 +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 1aJlo3-0006ay-LM; Thu, 14 Jan 2016 17:35:31 +0000 Received: from mail-by2on0100.outbound.protection.outlook.com ([207.46.100.100] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aJlfX-0005Kx-Fv for linux-arm-kernel@lists.infradead.org; Thu, 14 Jan 2016 17:26:54 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (95.143.213.121) by BY2PR07MB614.namprd07.prod.outlook.com (10.141.222.146) with Microsoft SMTP Server (TLS) id 15.1.361.13; Thu, 14 Jan 2016 17:26:20 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 13/21] arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it Date: Thu, 14 Jan 2016 20:23:10 +0300 Message-ID: <1452792198-10718-14-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452792198-10718-1-git-send-email-ynorov@caviumnetworks.com> References: <1452792198-10718-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: DB5PR02CA0003.eurprd02.prod.outlook.com (25.161.237.13) To BY2PR07MB614.namprd07.prod.outlook.com (10.141.222.146) X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB614; 2:zAaShc/vpbhJin9B2j3jNWtOTCKnYV9/tFuZQ1wmk6gnldrwcLIJWlS5L3bml9Oeci+efByMv3BUrrKVEzeKHRs3TdzXekHJ5VNK9NDQmF7gYFJdVgrcVyfzRG1WPHD83aEk+aOsVLXjIFBuKI04HQ==; 3:5uQ4JPOAdXXMIFT2dVMdVfJ2zXxQki21S29FchVSKsYFf/WMOF33DdKW9UuJ7kdIQc/KGWpYHp56sh/2kk76qK2ALb6I7PoNE3NE5XnAkml4hKrMyTScDKXEwLHmXA/n; 25:31GOMWL2nPGd5EONcEDZgSwYIIZQIrx78iC2dmx/djEOnu3A6ALgwcZeNVb21e1G0rzaJCC9NI/0gD0lcW/4zjGdcmwhJJ5x6uBydlyDw5Eiz05geBs+mDhYbR9QO8NMHx2wGcKa+om6xGZ9bsUMG/rmXe3L05Fkqdl87YyaTsR1qu4B1tsJmq9v5+k2QyLQhj2huM+pnDEU1wD6M3NMPz44AnbR4VQo5axUjCxKYokhamlJ05rjwZiz19/iIkF2 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB614; X-MS-Office365-Filtering-Correlation-Id: b6175cd9-c023-4d35-14c5-08d31d07d1b3 X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB614; 20:fJatbM63xhj12I8DoevdKkdVxk6v55OjS3vjN/0nR50pwXngJtLqFiM5dUb6ya8dgneHZW1DGhYt9K6ELKXPVggBzMvJHtLoSK5YRanKJn7ljcOW0Tzd/ebQwESr8Tk5YTSFC3a8BVTDFjGYcrh30SB3aRnkbQEc7KFxeC5z9iTtcqeq/PHfudR16shFZ+FVG5YXgmRUriE6qFD/qd2Q15o/x2lSkpE9hy/VVAxpfm3pB5igEO1KkHLmRGiljMyYnlcmvDdDCWRHPN7JhjwNajz/XORP8sNTsgMERnxBKIWPFIL0frcQKPSgo5efwvYtpSxbOqB3rtuxraolQqQtcnZNORnbT5KUksNS3YBQKEPh3R7ff9NCh6wjfKezEYeriaFpp9/GTBSzLD0QaWKY8LT954HEQoekQ+09vxLnv6UefexbhBKD6U807+Z59X8qn1/NR+DSCqGugBjP0ZxgDVhUwr8DHd6eWEzpxxYqZfcC3v+JtYXp/46sxp1ENzGLhX/pdDbtKsFsF+zdA8JwLdCjOgNb8ZDqe9e078BhDQqnAAeQyB8XSMYgIz+TmoAXj9A02TnliYaTh1ee2XdNEibKXg1W/wIlFhOrOAKgFxM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(520078)(8121501046)(5005006)(10201501046)(3002001); SRVR:BY2PR07MB614; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB614; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB614; 4:b9Lvh2lS+dzrihgz76QqeGXSO3xzgnyJikenE6sjcnUFT+CiAa2lE74noZUYCMwiZol08iWtvzsNgUqIGD0V2+Ei8uMIOfDWlkvCVPc+dzey6B/S8MTGMsEuoUaLIEyQw5MP8RbRso0aGDApYPSothfyF247CmM7R64Syaf1v4g5buJSLIitvzL8i9hUJQkw3kwtXpgxFUM+Cd/9JHE817dZkMPlV1IuHQe1Wda0NyBjyAQH5Rhx+uTmv8F2VQQAIbEyK8Wv/2pdRx6fn59QLigY35H532W9NhncvUJzzIQERKmXA5qv/hEN05SyyY6TUJAQQYB5Gal4S3CR6lxvDmdyh60OwczKFROGImlghbPtaODlV3ecbr5GmimVNqpg63iZjzVG8npAjUIkgJMwYXjor2z2C37TL73XbcxhwS8= X-Forefront-PRVS: 08213D42D3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(199003)(189002)(92566002)(2201001)(107886002)(50226001)(81156007)(97736004)(15975445007)(4001430100002)(5001960100002)(77096005)(189998001)(47776003)(87976001)(4326007)(5004730100002)(5008740100001)(122386002)(50986999)(76176999)(66066001)(40100003)(33646002)(3846002)(101416001)(2950100001)(6116002)(586003)(1096002)(105586002)(36756003)(2906002)(19580405001)(229853001)(50466002)(5001770100001)(106356001)(42186005)(19580395003)(48376002)(76506005)(5003940100001)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR07MB614; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BY2PR07MB614; 23:Bm4MSRQJnGG4JIDtboxWZ+Jk6cT568av1m0HhTuMdM?= =?us-ascii?Q?JSWIKVPXlHgdMKiWRYNYtiyylVL3BRy3Q0QQWU6vviwFfY2MqL7eU8ZEvydb?= =?us-ascii?Q?LkZSutltLRTSoiItYpTFD5P9r2LBQq3D5WZ32rknPJX9LhzFLgDfUyl7O7rL?= =?us-ascii?Q?MhWdp6Zz0vBFpRQ8nMkufjN+AGDhM36I4GjvFl8S3Zml67KJrU9yvxckPQn6?= =?us-ascii?Q?ruLs33WhgLcyHd94hAgudDCGEqDB92vm8g0N/sKu7wM9VQwLz387z0Cab955?= =?us-ascii?Q?IOJCEjsPVmruW/641phZq4MI4lk4W4WbvRNOdwm94hb/xSHrd8QBeG4jzAU3?= =?us-ascii?Q?aJed2AR7+qM9t1fk/FSQrrooDYGer2aM0BOO/l37kFUS6tUuaaaJCrgnQLGo?= =?us-ascii?Q?4b5XJr+HcrucPEgxRNLh5aVVdEFbysZD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ERF8In7t7dI91OQTusy1/6M6fw2vQNQJjyCNs6GwiaFJ7nmI7f9ugEq6VxTr5F+iuRgGTImjj19QjLKMo1Zw3lJ3oaWt+JErxuuIQwySy++O1/SIERQ==; 24:nFQOyEnzbgasNUREZyDQkijq47uXdGTgM8EIQmzTzStOTB5CgZPmUftHHJxKkcW7xYl8Bm1wOXIZENCRJLDARvMlgmVy/A+JsVEMXsy52bc= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jan 2016 17:26:20.4679 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB614 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160114_092644_202698_2C8B2225 X-CRM114-Status: GOOD ( 14.03 ) 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: pinskia@gmail.com, Prasun.Kapoor@caviumnetworks.com, schwab@suse.de, broonie@kernel.org, heiko.carstens@de.ibm.com, agraf@suse.de, klimov.linux@gmail.com, Andrew Pinski , ynorov@caviumnetworks.com, jan.dakinevich@gmail.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=-4.2 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 | 63 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 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 ad7158c..a35f2f8 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_PERF_EVENTS) += perf_regs.o perf_callchain.o diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 5eb1bb7..f348f58 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -666,9 +666,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 @@ -688,6 +692,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..0659b89 --- /dev/null +++ b/arch/arm64/kernel/sys_ilp32.c @@ -0,0 +1,63 @@ +/* + * 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_3264 +#undef __SC_COMP_3264 + +#define __SYSCALL_COMPAT +#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 +};