From patchwork Mon Jan 9 11:29:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9504503 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9207A60757 for ; Mon, 9 Jan 2017 11:56:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71200284B6 for ; Mon, 9 Jan 2017 11:56:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65501284B9; Mon, 9 Jan 2017 11:56:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BE91D284B6 for ; Mon, 9 Jan 2017 11:56:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cQYYT-0003Kj-0e; Mon, 09 Jan 2017 11:56:01 +0000 Received: from merlin.infradead.org ([2001:4978:20e::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQYXm-0001zn-B7 for linux-arm-kernel@bombadil.infradead.org; Mon, 09 Jan 2017 11:55:18 +0000 Received: from mail-co1nam03on0057.outbound.protection.outlook.com ([104.47.40.57] helo=NAM03-CO1-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cQYDE-00078D-1T for linux-arm-kernel@lists.infradead.org; Mon, 09 Jan 2017 11:34:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-caviumnetworks-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=YvQSdEefFgXnhryZsCQk8h8wRsH+HpcC7fKLn8Rb+Xc=; b=l43H0XIUZbW2pz5lM5n+wimxXUNEljkrMsx1JJ4pG3orKO9plPfZI21VX+qXz2F0+T633dyiKAnq1t3AMFO0kLuJH2KIlEQO5a/YNYztPN8+Z24zrOA26HKDWKpZCjMdq8ulOMmv6i2IISN0TQmoQ/qlIR7NmNsaBqDXVSFyEIY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (103.78.20.242) by DM3PR07MB2251.namprd07.prod.outlook.com (10.164.33.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.829.7; Mon, 9 Jan 2017 11:33:40 +0000 From: Yury Norov To: , , , "linux-arch @ vger . kernel . org Arnd Bergmann" , Catalin Marinas Subject: [PATCH 14/20] arm64: ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it Date: Mon, 9 Jan 2017 16:59:51 +0530 Message-ID: <1483961397-8599-15-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1483961397-8599-1-git-send-email-ynorov@caviumnetworks.com> References: <1483961397-8599-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [103.78.20.242] X-ClientProxiedBy: DB6P191CA0007.EURP191.PROD.OUTLOOK.COM (10.175.236.145) To DM3PR07MB2251.namprd07.prod.outlook.com (10.164.33.149) X-MS-Office365-Filtering-Correlation-Id: 2da5fbe1-3c95-48f6-781a-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bb0d2Wv9UCQvvLjE2avrpB74yBHu3RI+ST+Ys14yyg9pjGd2xbrGFv3FKRf1Yj3I9Z1hj7HY7RLyDWwZOmY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(250305191791016)(22074186197030); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123562025)(20161123555025)(20161123564025)(20161123560025)(6072148); SRVR:DM3PR07MB2251; BCL:0; PCL:0; RULEID:; SRVR:DM3PR07MB2251; X-Microsoft-Exchange-Diagnostics: 1; DM3PR07MB2251; 4:aggCEbsRy0lXIJ/UqzMfHWrd/QL+X4f2LFUuqmahkWTHZgwUn0DynMYjOEjykIxKAWzJZhE2ICjZ3DoI48GckNSJquod1ldLrz6uUGkGAla/8ah5xwZjGSQIsm+c0746MzrSdipzYUAGTPubp8JcrROWR6wkdtgF1PLGvA2ypC0wkmHZRsREV8QBKoUtLOJiS68B9AFgwf+fACsG8Wb/gh3IHR4l6pVM296PZL+nw7bpfuwawkG2BLvTkw5F6ovsZW1j5S69utP0rA21qhCSvsl5+esrD2UW5UOWnvXA8EH6/06ehPuUZ4mtPu6Fqj7O2llgpvX6vxO6KnMUW3EgT+w6eoX9NmEGnYpO0WSUBdNXcM5AwFvWf0YXvL3oq1arcov+kdjAFSNQUxVLdlVfwLcCxg5AFABMm/MlZZbOxwfqIcVRjmeK4YIv4Yxg9FZFrAE15kZSXdEnXGMcnLYl9A9C8w0/yYGEkqVtHwWKNVTXOyNbQPnIsXkxK/DCww7lXncgAdkgjkQpu6fxpCdLiaD1ckNx1laC5w/u4DxWtCVARHVUtN1zO3Qe1tkGGecleUabdVhU7QexrXGCr0S9XwCOVhOah1pwsiXBdwwepznM8ozYPu8S/D+HFSnzZSfbfpLD5QquhFgxUDy18tq18A== X-Forefront-PRVS: 0182DBBB05 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6069001)(6009001)(7916002)(39450400003)(189002)(199003)(54906002)(48376002)(97736004)(5660300001)(7736002)(305945005)(50226002)(50466002)(4326007)(50986999)(66066001)(81156014)(81166006)(8676002)(76176999)(2950100002)(101416001)(6666003)(47776003)(42186005)(38730400001)(7416002)(2906002)(76506005)(106356001)(2201001)(105586002)(6306002)(5003940100001)(189998001)(68736007)(39060400001)(92566002)(36756003)(25786008)(5001770100001)(4001430100002)(6116002)(3846002)(107886002)(6486002)(6496003)(33646002)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:DM3PR07MB2251; H:localhost; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A: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; DM3PR07MB2251; 23:uahKeXO15drVY0QFVoSygq4iYPY3itPthXa/BF/0S?= =?us-ascii?Q?Pa2AwCVWBtMIPRYbRxEISrh4xmd7+GWXiW2K1oQqsVH9y3ms1uXlioV65fOq?= =?us-ascii?Q?lm6Lr53ZowGqS5LwBUJurE2gyxmHrWIHqnZNqz9Ch/sgc2nmMhS+4xGQ2XLR?= =?us-ascii?Q?7wD5g6DW4XaiX/LojtZk1vGOhSfU99PPSWshU6jkxSSPjlrjEZVuhiH3U5Y6?= =?us-ascii?Q?XUlgMnd60fjeQyn9t4SdaLp8F68PrkDXbsAauNzBLde1njiQ04LlMkH2bhNY?= =?us-ascii?Q?vs6vah3PtCT4cACnQt8LOPhbywIHBWgho21G9LjkAdjVAMj1sC7y5WaZ6RT3?= =?us-ascii?Q?IVQrldJooNc6c+b03dfCZtM6da1RFwOhl/2BnkS4cZ663xY6mhKDKAwUEuC7?= =?us-ascii?Q?BUVT+GBmiXXwFxCKz8PS0yo7Qo44jkXG+/PKEVgA8Xyg6wUz5qPlSOT6RSgZ?= =?us-ascii?Q?xpeen6FcOP2jeDLu4+glErN6FrAiz4O7J8tXhLNCq8/zhNFf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sRGWypRgxtYzkV1/Rumt70eOgRCZRq8GV4DWcBlykFdQSjDP9QUEqKxzr6f3dP0joEVxFAClYN+ESyVIDLz9KDJEX8h9Hz8fJ2M4Q== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jan 2017 11:33:40.7389 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM3PR07MB2251 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170109_063404_353622_465DF6E5 X-CRM114-Status: GOOD ( 17.99 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Pinski , Heiko Carstens , Chris Metcalf , Yury Norov , philipp.tomsich@theobroma-systems.com, Joseph Myers , zhouchengming1@huawei.com, Steve Ellcey , Prasun.Kapoor@caviumnetworks.com, Andreas Schwab , agraf@suse.de, szabolcs.nagy@arm.com, geert@linux-m68k.org, Adam Borowski , manuel.montezelo@gmail.com, Chris Metcalf , Andrew Pinski , linyongting@huawei.com, klimov.linux@gmail.com, broonie@kernel.org, Bamvor Zhangjian , Maxim Kuvyrkov , Florian Weimer , Nathan_Lynch@mentor.com, Andrew Pinski , Ramana Radhakrishnan , schwidefsky@de.ibm.com, davem@davemloft.net, 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-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 | 8 ++- arch/arm64/include/uapi/asm/unistd.h | 12 +++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/entry.S | 28 +++++++++- arch/arm64/kernel/sys_ilp32.c | 100 +++++++++++++++++++++++++++++++++++ 5 files changed, 145 insertions(+), 5 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 fe9d6c1..851cc8a 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -13,13 +13,17 @@ * 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 +#define __ARCH_WANT_SYS_LLSEEK +#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 diff --git a/arch/arm64/include/uapi/asm/unistd.h b/arch/arm64/include/uapi/asm/unistd.h index 48355a6..e7106bb 100644 --- a/arch/arm64/include/uapi/asm/unistd.h +++ b/arch/arm64/include/uapi/asm/unistd.h @@ -14,7 +14,19 @@ * along with this program. If not, see . */ +/* + * Use AARCH32 interface for sys_sync_file_range() as it passes 64-bit arguments. + */ +#if defined(__ILP32__) || defined(__SYSCALL_COMPAT) +#define __ARCH_WANT_SYNC_FILE_RANGE2 +#endif + +/* + * AARCH64/ILP32 is introduced after next syscalls were deprecated. + */ +#if !(defined(__ILP32__) || defined(__SYSCALL_COMPAT)) #define __ARCH_WANT_RENAMEAT #define __ARCH_WANT_SET_GET_RLIMIT +#endif #include diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index 9123bb8..06070f5 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -29,7 +29,7 @@ $(obj)/%.stub.o: $(obj)/%.o FORCE arm64-obj-$(CONFIG_AARCH32_EL0) += sys32.o kuser32.o signal32.o \ sys_compat.o entry32.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_COMPAT) += entry32_common.o arm64-obj-$(CONFIG_FUNCTION_TRACER) += ftrace.o entry-ftrace.o arm64-obj-$(CONFIG_MODULES) += arm64ksyms.o module.o diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 45e74df..9b1ac4c 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -308,6 +308,23 @@ tsk .req x28 // current thread_info .text +#ifdef CONFIG_ARM64_ILP32 +/* + * AARCH64/ILP32. Zero top halves of x0-x7 + * registers as userspace may put garbage there. + */ + .macro delouse_input_regs + mov w0, w0 + mov w1, w1 + mov w2, w2 + mov w3, w3 + mov w4, w4 + mov w5, w5 + mov w6, w6 + mov w7, w7 + .endm +#endif + /* * Exception vectors. */ @@ -576,6 +593,7 @@ el0_svc_compat: * AArch32 syscall handling */ adrp stbl, compat_sys_call_table // load compat syscall table pointer + ldr x16, [tsk, #TSK_TI_FLAGS] uxtw scno, w7 // syscall number in w7 (r7) mov sc_nr, #__NR_compat_syscalls b el0_svc_naked @@ -797,15 +815,21 @@ ENDPROC(ret_from_fork) .align 6 el0_svc: adrp stbl, sys_call_table // load syscall table pointer + ldr x16, [tsk, #TSK_TI_FLAGS] uxtw scno, w8 // syscall number in w8 mov sc_nr, #__NR_syscalls +#ifdef CONFIG_ARM64_ILP32 + tst x16, #_TIF_32BIT_AARCH64 + b.eq el0_svc_naked // We are using LP64 syscall table + adrp stbl, sys_call_ilp32_table // load ilp32 syscall table pointer + delouse_input_regs +#endif el0_svc_naked: // compat entry point stp x0, scno, [sp, #S_ORIG_X0] // save the original x0 and syscall number enable_dbg_and_irq ct_user_exit 1 - ldr x16, [tsk, #TSK_TI_FLAGS] // check for syscall hooks - tst x16, #_TIF_SYSCALL_WORK + tst x16, #_TIF_SYSCALL_WORK // check for syscall hooks b.ne __sys_trace cmp scno, sc_nr // check upper syscall limit b.hs ni_sys diff --git a/arch/arm64/kernel/sys_ilp32.c b/arch/arm64/kernel/sys_ilp32.c new file mode 100644 index 0000000..d203dec --- /dev/null +++ b/arch/arm64/kernel/sys_ilp32.c @@ -0,0 +1,100 @@ +/* + * AArch64- ILP32 specific system calls implementation + * + * Copyright (C) 2017 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 . + */ + +#define __SYSCALL_COMPAT + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * AARCH32 requires 4-page alignement for shared memory, + * but AARCH64 - only 1 page. This is the only difference + * between compat and native sys_shmat(). So ILP32 just pick + * AARCH64 version. + */ +#define compat_sys_shmat sys_shmat + +/* + * ILP32 needs special handling for some ptrace requests. + */ +#define sys_ptrace compat_sys_ptrace + +/* + * Using AARCH32 interface for syscalls that take 64-bit + * parameters in registers. + */ +#define compat_sys_fadvise64_64 compat_sys_fadvise64_64_wrapper +#define compat_sys_fallocate compat_sys_fallocate_wrapper +#define compat_sys_ftruncate64 compat_sys_ftruncate64_wrapper +#define compat_sys_pread64 compat_sys_pread64_wrapper +#define compat_sys_pwrite64 compat_sys_pwrite64_wrapper +#define compat_sys_readahead compat_sys_readahead_wrapper +#define compat_sys_sync_file_range2 compat_sys_sync_file_range2_wrapper +#define compat_sys_truncate64 compat_sys_truncate64_wrapper +#define sys_mmap2 compat_sys_mmap2_wrapper + +/* + * Using AARCH32 interface for syscalls that take the size of + * sfruct statfs as an argument, as it's calculated differently + * in kernel and user spaces. + */ +#define compat_sys_fstatfs64 compat_sys_fstatfs64_wrapper +#define compat_sys_statfs64 compat_sys_statfs64_wrapper + +/* + * Using custom wrapper for rt_sigreturn() to handle custom + * struct rt_sigframe. + */ +#define compat_sys_rt_sigreturn ilp32_sys_rt_sigreturn_wrapper + +asmlinkage long compat_sys_fstatfs64_wrapper(void); +asmlinkage long compat_sys_statfs64_wrapper(void); +asmlinkage long compat_sys_fadvise64_64_wrapper(void); +asmlinkage long compat_sys_fallocate_wrapper(void); +asmlinkage long compat_sys_ftruncate64_wrapper(void); +asmlinkage long compat_sys_mmap2_wrapper(void); +asmlinkage long compat_sys_pread64_wrapper(void); +asmlinkage long compat_sys_pwrite64_wrapper(void); +asmlinkage long compat_sys_readahead_wrapper(void); +asmlinkage long compat_sys_sync_file_range2_wrapper(void); +asmlinkage long compat_sys_truncate64_wrapper(void); +asmlinkage long ilp32_sys_rt_sigreturn_wrapper(void); + +#include + +#undef __SYSCALL +#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 +};