From patchwork Thu Jan 7 23:34:32 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7980721 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 89C249F3F6 for ; Thu, 7 Jan 2016 23:46:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7FEC220149 for ; Thu, 7 Jan 2016 23:46:10 +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 3AAD12010E for ; Thu, 7 Jan 2016 23:46:09 +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 1aHKDg-0007ea-MY; Thu, 07 Jan 2016 23:43:52 +0000 Received: from mail-bn1on0060.outbound.protection.outlook.com ([157.56.110.60] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1aHKAB-0002Vs-Fs for linux-arm-kernel@lists.infradead.org; Thu, 07 Jan 2016 23:40:21 +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, 7 Jan 2016 23:39:57 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 14/21] arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it Date: Fri, 8 Jan 2016 02:34:32 +0300 Message-ID: <1452209679-19445-15-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452209679-19445-1-git-send-email-ynorov@caviumnetworks.com> References: <1452209679-19445-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [95.143.213.121] X-ClientProxiedBy: AM3PR01CA036.eurprd01.prod.exchangelabs.com (10.141.191.26) To BY2PR07MB614.namprd07.prod.outlook.com (10.141.222.146) X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB614; 2:xnWalU/fYkzVnkFWoJhyI4ub6H/ct/5bp67NFxSZzLoxk0+pdDq/AZMTkvFemJfL3jb6vwDmIJy3KuEn5FMoE71u/WSMJ6f6Junn2s8S42plu7lJ5sTqC/wLKeoByOiC9EBl0VrB4moI3fExlQPDig==; 3:Vl9l54F2slXe1PDv7taQnNBh16Glin/bS60/ZpRtSh2Nrh7fodZ6l64sV1r0jKoux1LD4JWk+v7I/wm3of5t+hqz+8COGyiGW7vCctgA0DR9RUfQkLx+YQdndBqwLiaP; 25:5JSQ+p/O+kvNMKIV1kqS9c5GZgtLspcWFjETdsa/Yofo0DP4TqZvD4fbEGg6u+ki3u+JldAQeMmOZ6KtVuWZzBPbKd8/v8Nym2En20TKL46/ydELrXTzLVSGj9SuvlHxL3sEllSHEk8+BT9+GOvmpHh1Ik4IRUev4pE3zIJPMSF4PaLUvXj9kwXZTIIHCqpVZILDLlHzSH2AYwkFaH0j5wUnCUbD11G9Xk37/RZQlHV2XlY6aw4Mmtvlix3zPYIz X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BY2PR07MB614; X-MS-Office365-Filtering-Correlation-Id: 60df5041-3b7a-465c-55cb-08d317bbdaa0 X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB614; 20:A+zbrr38uTrinZEXDiDcIdyCBSQMZFJ09n3VHt3nFA2oBSisnwoTuiGrWY+k8SQYZqsv3qX/ziLGAYwLDS5Ewon7OvXVVtdbdClXlHS1JrLUv9m/G5ruXCIxdZuXfLGwalud/REN5GYv9LlsOQxlFXvYsI9zR+rS46icay95W7HG0eFto3hIoXdw7TF0meI8Bm5ACKuSrXV/ixa8MGfrvYNTiPzZH4qtyhyxY1ZoMMRbFxO5tpUwDj6C6foVXZuE2X58iNfp0SBb6/NAPRdsuGNpgIuB3zMRSnvpO5VSOjYpfejZOkq1929YmM2XK3wNjLVHyaLiD4HYdNY+Mmj6kdpxIRhI8jHWkWUijDLZpmPELbu4T7JgecIufd0JzYmqSddohSAjazM9JUr+VULXisI1mBuTOcV3PTgzJI8OB0FsdhKLyK/iaXUZzK67khO/zBypXQ7oiQ4YdB8uLXTgZ9KnnuHQyPldJ0w24wklFmzj5ZwrgDoDKtLHiR4Z3tZ4Jh8qfsV1VoGVjaPzfg3oGM6hEMwLsYF/p1cq2fdkgYoj9l9odtPorRrvfPev8rKs3Hw1+8PkkJ4+SAyVxg00IRq8EmQOTomHiWU+YZq9aIE= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(236414709691187); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(520078)(10201501046)(3002001); SRVR:BY2PR07MB614; BCL:0; PCL:0; RULEID:; SRVR:BY2PR07MB614; X-Microsoft-Exchange-Diagnostics: 1; BY2PR07MB614; 4:HAxz9fXhmCfe0AEa7U5Ls6e1NEbFtNNc9O7/JkOlyUpp/GE950SKcVrgyfToimTr2iyyxMo7sydb6NgXqdX+OLOb9bsqVIu0rq8SvNbdLhqhbjV14It6P/g6dkf2ZNf+/OF4u0+7cINMzTOrjWCwW1PJBpO74qpzVhe4kIbCra6/hBNV84W8KygRGCwsQa8FShwLIYxBsZzSzdl4B8FtCFshdpZMBg0+HrQZHCAw4vyRXZDzL06LPQ8btlkbOSp73Na/X8/rOZQmNxuDrCX6hfJwygWEes/32k9/VO7se78zzq0yXfG4oROMF5bHWWLT+xWf/DKXAAmiZuccs8ODPliR3Dei9vUzbRsf9HrBClTHtey+OiZLObWJFYiSJ/N8fx9s/zPv2OCPXaYu6kW+NIurz95ubPrRylmwXgc0y1I= X-Forefront-PRVS: 0814A2C7A3 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(199003)(189002)(33646002)(107886002)(105586002)(5001770100001)(50986999)(189998001)(106356001)(81156007)(1096002)(2950100001)(5003940100001)(47776003)(97736004)(50226001)(87976001)(92566002)(40100003)(5001960100002)(50466002)(229853001)(5008740100001)(3846002)(4326007)(19580395003)(76176999)(77096005)(19580405001)(586003)(122386002)(42186005)(36756003)(5004730100002)(6116002)(15975445007)(2906002)(4001430100002)(101416001)(66066001)(48376002)(76506005)(2201001)(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:65GAoeFWU6WxX46pht+MuMZtj4RnmxhByaVrMzKjWO?= =?us-ascii?Q?mNDMpXPqqj5CH+1YghqLGFIYlduSMQdKjHkLvKYUHCUzwtW1vvNkn2ZUxo3a?= =?us-ascii?Q?b6g6x53MQvRHu0+1tHcW4jdGJRAIeFaO9f3gzdloOH1CCq/zwbRZ9QI7dxHq?= =?us-ascii?Q?B3b0Ce5OZM0yk4Is9jK6wE/34EjftzYpkebv1DnmUZlqxQSOhUpyNDWuT6dt?= =?us-ascii?Q?xv3G3+O/WnhpUVR1BrGm0jJvhwm/yVrF9OVL0kK9hkSTGeXxtsmG2NHTPXAo?= =?us-ascii?Q?2zpheOZFLv1hPcJp3klgPqbu2i8tmRXH6+ohALBOwJU8Kxlm55J4/swrmTYb?= =?us-ascii?Q?gy4vil6uSjucykRIYAQaw7AeotMDODi4iSJDfzSxWtJnsKJJshFlIi8bW3E/?= =?us-ascii?Q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BY2PR07MB614; 5:fRybbpWaPWP4g9iFHbeC6DpPlYob6tiHIqOsaRSxGP3Wr6+tVk6Zt4yi69eWVJQBbAQKy4a3jUCs4Hdh9UJI3bF8NJQUKwVi7/iZtIme1q56bxPw3dK5k+O/qooWDL8i7guanZ52uFDtIm8jw6UsaA==; 24:EE9OOKKBwy+dkXVlGgcvFjL4M162jtpXUh6sIOVcHUrtIxjtS4V4tKVkxfbMaSmKhTnyC566IoML9zmxvgsRou6Rt9XTabdtIgwDgV8UEd0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jan 2016 23:39:57.8948 (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-20160107_154016_451410_CDD2CC78 X-CRM114-Status: GOOD ( 14.05 ) 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, Nathan_Lynch@mentor.com, agraf@suse.de, klimov.linux@gmail.com, Andrew Pinski , ynorov@caviumnetworks.com, jan.dakinevich@gmail.com, Andrew Pinski , ddaney.cavm@gmail.com, bamvor.zhangjian@huawei.com, philipp.tomsich@theobroma-systems.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 | 66 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 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..71912b0 --- /dev/null +++ b/arch/arm64/kernel/sys_ilp32.c @@ -0,0 +1,66 @@ +/* + * 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 + +/* 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 + +asmlinkage long sys_mmap(unsigned long addr, unsigned long len, + unsigned long prot, unsigned long flags, + unsigned long fd, off_t off); +#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 +};