From patchwork Tue Nov 17 21:16:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 56876 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp2185041lbb; Tue, 17 Nov 2015 13:21:18 -0800 (PST) X-Received: by 10.66.237.37 with SMTP id uz5mr65348030pac.133.1447795277927; Tue, 17 Nov 2015 13:21:17 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ua10si59803645pab.236.2015.11.17.13.21.17; Tue, 17 Nov 2015 13:21:17 -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 S1755134AbbKQVVL (ORCPT + 28 others); Tue, 17 Nov 2015 16:21:11 -0500 Received: from mail-bn1bon0099.outbound.protection.outlook.com ([157.56.111.99]:47202 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754888AbbKQVVG (ORCPT ); Tue, 17 Nov 2015 16:21:06 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (95.143.213.120) by BY2PR07MB616.namprd07.prod.outlook.com (10.141.222.156) with Microsoft SMTP Server (TLS) id 15.1.318.15; Tue, 17 Nov 2015 21:21:01 +0000 From: Yury Norov To: , , , CC: , , , , , , , , , , , , , , Yury Norov Subject: [PATCH v6 14/19] arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it Date: Wed, 18 Nov 2015 00:16:54 +0300 Message-ID: <1447795019-30176-15-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1447795019-30176-1-git-send-email-ynorov@caviumnetworks.com> References: <1447795019-30176-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.120] X-ClientProxiedBy: AM3PR01CA021.eurprd01.prod.exchangelabs.com (10.141.191.11) To BY2PR07MB616.namprd07.prod.outlook.com (10.141.222.156) X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB616; 2:F3eVWUDO4jTHYnqDBovZi7GspCTwrMjdh62bL/+3ZqlEiXYiLkyWv923sGNU+s7lzWxBHA9k9rKDdSjY1V8jsUm2gbdP11iifVg+eDUIFeL4jBCM4Fejg0aYibikqU87359ddFJXiV2MvIyTlc+wzsk7Pbn8elB5kpizfqzplAY=; 3:QCIIELH5ktGvGmbib2MxnSmVcK3MkCb7eJSOyFJJDOK2P7Ob2yT1LMz3DjFNrIFGMdFywBxfyRBhS+dFdWokt6/auGq/jehi7k6Ms/gA+fPZNrlmfcFLAcpmeDa4zTke82gv9hwteNvIoeR84WI+CQ==; 25:1CBf1RcQ92JqxCIzeeq/Fc+fAZM755HWtPx8l+sku4ri5ncOS5j3MOVCtpo9cCzZp/g+bNkjVTlJae/X8l7O7Zwr3F3+GvvjZ3avQH63HYWd3Lomqstjxq2UogU52RTRhGgaA0BDL+w+M+lSmN5vGXRc08s38aZ5Rsp4NJzRG10WN52Z3JuTUYgb5g5XEoYNgYGuzancgV76SlPaknK9gvFdp2imsqvBtAAlxl+SzU3BsNH0ms+uQ10x742GaNMb X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB616; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB616; 20:wVfOxO82NRkO43+scenIK0IpvlzmKiVfZ8QGElqGOKJNMAN/gTRkDJ1kZR3w7RKoA4qdZGI7OFmxeS/q13dEex1BaQhpWJUasFlXFhiCaz/eqEJ1WRxsbVk5F1B2/IFRSAQxlEumKK2XbdC7jVCee1BPYY9/tEeCsc1ldzVRb3yr0ZxMqwsdZaiRRpcuFPzXamAQCxSFv/oiF2LPdLgZDdPoC5SAIUfoJv1e2YowaVbsAg9FFQyDW4nA4OF7gBPuwCzQh/Vu3Dzhyui0YvHDBEr5+T7hPHv9o6gZwWASGRJMck9fVfOfrRIG76t86iumZYdWRt7J429Ys21OUHOyL9TROzpnb4P6eNw17LiOaw7TJe0Hijr58uy+iOA8qG1Lfd1muuFpkzpB77lxXLoi7YEYUMuRFgMFRf+sKP8e1fceOcmthU2v5CTvq1RgiIhZJnh59CbE80Nj2uL4AwN6ur9XmguKdWDUzUdSsPd1KWxgaNuffLvzc2V46y0YlXE2nk4qnmD3xrgAqLTaZ379psFDy2AN0xZLopsKOJybvPY4WrGeLZhWW2RvuBZr5JAygO340XMsxJWuowt04AHiwmhZCObZYOAkWoBkDjYuKz8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(10201501046)(3002001); SRVR:BY2PR07MB616; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB616; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB616; 4:8+fCj7EyqAVkVmtkzLUWaj3KQN2a62DfnlkP64KVZHZeQgdnIzxjiHUBRE8NHmNApTp62CJdDX3Sq4ElYO78EkhrJRCoIq5D534g4vllZSTgQiWCUZ3CYAmFVAEH9CCdBB+K6ZR0+jHwJ2zHgQJOgdcvjES0IE3gd40U9tg166IjyVqGFyQ2/zytlDI7QlZ1Ao87Ph2ouy4odmynO0tmtyOsdVqIyySq30vLk6P9jRmRNYT5y7ZrEhGpST7GnzlVTcGAE2R4EKbOZWCLzOHCxhdC5iNVD2SRIKo5ufPH1uSxyQZhQeLZxoSrXgUmCAttiLoYp9a3bYgC60/Y2VZNN24AdiiuB8MX+/OOgVYUEiqzJCBHs6VDWD0yoJZt2rvN X-Forefront-PRVS: 07630F72AD X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(199003)(189002)(50986999)(76176999)(50226001)(19580395003)(19580405001)(87976001)(101416001)(81156007)(2201001)(5001960100002)(107886002)(97736004)(5001770100001)(4001430100002)(122386002)(40100003)(586003)(106356001)(77096005)(36756003)(5003940100001)(47776003)(105586002)(50466002)(15975445007)(42186005)(189998001)(229853001)(92566002)(5008740100001)(48376002)(66066001)(76506005)(2950100001)(5007970100001)(5004730100002)(33646002)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BY2PR07MB616; 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; BY2PR07MB616; 23:K6cquuv4qJ+bSOjAU9bYMeQ/3r3S0mrWaG1o6ROunc?= =?us-ascii?Q?hQiaAealfwsOb/WItD7nPukcsyVk5DhqxHMtBRB+ndi67Z6yIBoRq+9KR6XX?= =?us-ascii?Q?MiSUX2V9ulyrBmdqUox8GRWLlaObn8C5TpZ3qSI8VWRq4VwoY4TGACCulfQm?= =?us-ascii?Q?Ccqf810y8yVrwskpkOWPw1R+VM8+whqyfZCXyNjwz5G+08cRAHs4j5xbW9cT?= =?us-ascii?Q?7zheRIob4RbcTZWyOfuULjnDi9Ea73ZjiQHCy6I+7LYuMVksZpQUWpXtbU05?= =?us-ascii?Q?zSTJf+SpFw3cnM/nGILy9vUhDppnV6oGEOXNBbVd3ei+mWXVWSQXYbXUoiZg?= =?us-ascii?Q?aCYP+aWDVFJdz1sVPWb5E2NFC7FCuvyM5ySCjyxPkLsqNQBMomk6nA8CgRy9?= =?us-ascii?Q?WZvVASNoZrxu3AxtBHXqSziC03luh8uDB9KSfM6JCiX/CAsprk4ixKSE29lF?= =?us-ascii?Q?ufectDbMpjv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LjgDgRxM6ArJp5i1thGPFciA1QuPKcS+MTKVCrA5GMH/ePxLBJpzpPdpYv0PakExYv9lMOuMPozV6juo=; 20:PScM4q+ul2k1fvg47SApRs9CtivGk1jyvkaGkMkEn9kKRtJYgDfzLyobA8QNW4DcdeqhRYUZOECECIBbjRMXIA== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2015 21:21:01.0078 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY2PR07MB616 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. Reviewed-by: David Daney Signed-off-by: Philipp Tomsich Signed-off-by: Christoph Muellner Signed-off-by: Yury Norov Signed-off-by: Andrew Pinski --- arch/arm64/include/asm/unistd.h | 7 ++- arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/entry.S | 12 +++- arch/arm64/kernel/sys_ilp32.c | 118 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 arch/arm64/kernel/sys_ilp32.c -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h index 4c2cbbc..696e638 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -13,13 +13,16 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ +#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 -#define __ARCH_WANT_SYS_LLSEEK #define __ARCH_WANT_SYS_NICE #define __ARCH_WANT_SYS_SIGPENDING #define __ARCH_WANT_SYS_SIGPROCMASK @@ -39,6 +42,8 @@ #define __NR_compat_sigreturn 119 #define __NR_compat_rt_sigreturn 173 +#define __ARCH_WANT_SYS_LLSEEK + /* * The following SVCs are ARM private. */ diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 35a59af..837d730 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -24,6 +24,7 @@ arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.o \ ../../arm/kernel/opcodes.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o +arm64-obj-$(CONFIG_ARM64_ILP32) += sys_ilp32.o arm64-obj-$(CONFIG_COMPAT) += entry32-common.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 52be5c8..bcd921a 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -664,9 +664,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 @@ -686,6 +690,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..c366d92 --- /dev/null +++ b/arch/arm64/kernel/sys_ilp32.c @@ -0,0 +1,118 @@ +/* + * AArch64- ILP32 specific system calls implementation + * + * Copyright (C) 2015 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 + +/* + * Wrappers to pass the pt_regs argument. + */ +asmlinkage long sys_rt_sigreturn_wrapper(void); +#define compat_sys_rt_sigreturn sys_rt_sigreturn_wrapper + +/* 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_pread64 sys_pread64 +#define compat_sys_pwrite64 sys_pwrite64 +#define compat_sys_readahead sys_readahead +#define compat_sys_rt_sigaction sys_rt_sigaction +#define compat_sys_shmat sys_shmat +#define compat_sys_sync_file_range sys_sync_file_range +#define compat_sys_truncate64 sys_truncate +#define compat_sys_sigaltstack sys_sigaltstack + +#define compat_sys_io_getevents sys_io_getevents +#define compat_sys_lookup_dcookie sys_lookup_dcookie +#define compat_sys_epoll_pwait sys_epoll_pwait +#define compat_sys_fcntl64 compat_sys_fcntl +#define compat_sys_preadv compat_sys_preadv64 +#define compat_sys_signalfd4 sys_signalfd4 + +#define compat_sys_rt_sigsuspend sys_rt_sigsuspend +#define compat_sys_rt_sigprocmask sys_rt_sigprocmask +#define compat_sys_rt_sigpending sys_rt_sigpending +#define compat_sys_rt_sigqueueinfo sys_rt_sigqueueinfo +#define compat_sys_semtimedop sys_semtimedop +#define compat_sys_rt_tgsigqueueinfo sys_rt_tgsigqueueinfo + +#define compat_sys_timer_create sys_timer_create +#define compat_sys_timer_gettime sys_timer_gettime +#define compat_sys_timer_settime sys_timer_settime +#define compat_sys_rt_sigtimedwait sys_rt_sigtimedwait + +#define compat_sys_mq_open sys_mq_open +#define compat_sys_mq_timedsend sys_mq_timedsend +#define compat_sys_mq_timedreceive sys_mq_timedreceive +#define compat_sys_mq_getsetattr sys_mq_getsetattr +#define compat_sys_mq_open sys_mq_open + +#define compat_sys_open_by_handle_at sys_open_by_handle_at +#define compat_sys_clock_adjtime sys_clock_adjtime + +#define compat_sys_openat sys_openat +#define compat_sys_getdents64 sys_getdents64 +#define compat_sys_waitid sys_waitid +#define compat_sys_timer_settime sys_timer_settime +#define compat_sys_sched_rr_get_interval sys_sched_rr_get_interval +#define compat_sys_execveat sys_execveat + +#define compat_sys_mq_notify sys_mq_notify +#define compat_sys_clock_nanosleep sys_clock_nanosleep +#define compat_sys_clock_getres sys_clock_getres + +#define sys_lseek sys_llseek + +asmlinkage long compat_sys_mmap2_wrapper(void); +#define sys_mmap2 compat_sys_mmap2_wrapper + +asmlinkage long compat_sys_fstatfs64_wrapper(void); +#define compat_sys_fstatfs64 compat_sys_fstatfs64_wrapper +asmlinkage long compat_sys_statfs64_wrapper(void); +#define compat_sys_statfs64 compat_sys_statfs64_wrapper + +#define compat_sys_pwritev compat_sys_pwritev64 + +#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 +};