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: 59754 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp17704lbb; Thu, 14 Jan 2016 09:26:33 -0800 (PST) X-Received: by 10.98.44.195 with SMTP id s186mr7900933pfs.0.1452792393359; Thu, 14 Jan 2016 09:26:33 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p77si10476971pfi.219.2016.01.14.09.26.31; Thu, 14 Jan 2016 09:26:33 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756512AbcANR03 (ORCPT + 29 others); Thu, 14 Jan 2016 12:26:29 -0500 Received: from mail-by2on0095.outbound.protection.outlook.com ([207.46.100.95]:34004 "EHLO na01-by2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754018AbcANR0X (ORCPT ); Thu, 14 Jan 2016 12:26:23 -0500 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: , , , CC: , , , , , , , , , , , , , Andrew Pinski , Andrew Pinski 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+HcrucPEgxRNLh5aVVdEFbysZ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4ERF8In7t7dI91OQTusy1/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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk 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 --- 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 -- 2.5.0 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 +};