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: 59311 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp222677lbb; Thu, 7 Jan 2016 15:40:12 -0800 (PST) X-Received: by 10.98.87.20 with SMTP id l20mr287450pfb.70.1452210012107; Thu, 07 Jan 2016 15:40:12 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si12058093pas.96.2016.01.07.15.40.11; Thu, 07 Jan 2016 15:40:12 -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 S1754073AbcAGXkH (ORCPT + 29 others); Thu, 7 Jan 2016 18:40:07 -0500 Received: from mail-bn1on0091.outbound.protection.outlook.com ([157.56.110.91]:43472 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752738AbcAGXkA (ORCPT ); Thu, 7 Jan 2016 18:40:00 -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, 7 Jan 2016 23:39:57 +0000 From: Yury Norov To: , , , CC: , , , , , , , , , , , , , , Andrew Pinski , Andrew Pinski 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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 1; 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 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 | 66 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 88 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..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 +};