From patchwork Wed Mar 1 19:19:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 9599031 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 6185A60453 for ; Wed, 1 Mar 2017 19:28:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4BDC2204C1 for ; Wed, 1 Mar 2017 19:28:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3F9882854E; Wed, 1 Mar 2017 19:28:08 +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=-1.9 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, DKIM_SIGNED,DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A81DE204C1 for ; Wed, 1 Mar 2017 19:28:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=UuWd2tqrWP0uXaqEN3WU95JGNfaq65s63hx0FMrz+rk=; b=XQwuix/XqpAbsb BGxNhs6FyjlCkhQ4CfL4UyvZ4Pz1Yiu9ykgGyYlJ93UWR38xun0o7HRPd6OF7Q3PIARqslD3sfnXE VdhNpIZKMjIt9k7LLy/Qi/y9w4FR6dxOyl4ebYurlOumPWek3qj6gXlStc+ypa2ntTvfJvV34N6iR d/YjTmsRNPCtn5J6LPZhg4eVqGHtiN3FmPTz9MQ7IbY2kA4Ss2S9+xkaxQc78myO/+62vB70dAGbM yyCH0KMjCMML2JhyKEWr2ja+/YwRh2iC0OpYpgEkpw1LdefAHFm/xa/GvWHg2ftjxnPxpf5+zLLn7 wG1IhOzHvk+8kHe/gDKA==; 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 1cj9uu-0000KO-HS; Wed, 01 Mar 2017 19:28:04 +0000 Received: from mail-sn1nam02on0080.outbound.protection.outlook.com ([104.47.36.80] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cj9pn-0002Oa-7z for linux-arm-kernel@lists.infradead.org; Wed, 01 Mar 2017 19:22:59 +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=+Jo9ALhoawYW4pf/6b1D30K6EHcFH+QzYyy8tnSgOZ8=; b=binN8rD5awoPXglsCm4MJhlHTgCt/0YH4BEMZua13HFF2Lu/F7ZY4ulO+A7oLODgYfi0lVgr+atty6H6nAthnxLRvPJ+qWg/1GyrlzTRIzNpwU1TmqGT0SWbdzglso621Q5l+9+gp7ZY2/+o7RIsht8ZTvVe1OA6LLSLNOuI634= Authentication-Results: lists.infradead.org; dkim=none (message not signed) header.d=none; lists.infradead.org; dmarc=none action=none header.from=caviumnetworks.com; Received: from localhost (27.97.135.110) by BN4PR07MB2244.namprd07.prod.outlook.com (10.164.63.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.933.12; Wed, 1 Mar 2017 19:22:23 +0000 From: Yury Norov To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-doc@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: Thu, 2 Mar 2017 00:49:22 +0530 Message-Id: <1488395968-14313-15-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> References: <1488395968-14313-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [27.97.135.110] X-ClientProxiedBy: VI1PR07CA0049.eurprd07.prod.outlook.com (10.164.94.145) To BN4PR07MB2244.namprd07.prod.outlook.com (10.164.63.150) X-MS-Office365-Filtering-Correlation-Id: 06fa051b-c57e-4c7e-fa3c-08d460d84a63 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN4PR07MB2244; X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2244; 3:KYWAIfdot0Z6pZFej293f5WjzRiktJjwJbG2nXyYygCLkqbK4Os3plpT8KEGjZ09KTzm3ybHXXu8oadJb/SCB3YuOC8VbuHqaYey3frXJ8+uvFPH2k9jVLqapxn/IpP0Oynbe+ffQO1iSWcjSdCy8OFgfzdpBQaLNAhlMj/EqPCb0r8HFz3aQuffDzTbBZ7sLLOqbWee54eE+A6Gh0fVPKMgtASHSsujIp11RoNszX0AyO6TOQcGYX8w9k7JYwasaZdpLJlHrSSiNtjZpD4fEg==; 25:TSIxc8bhQtkrTZkZG1MDgwWrj+sGf/ycPnQuO4ff9Tt3Pslr1uDkzB0IF0cBX/viRkM5mSNfRsUGpvwZ/GXLlJoreAt+L3OLgw5dh1nsZmlNt6Qvm8YzdsmA9gqBkgJIaagO0D1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Zs1nnLHWSaP5Zq9ClGiW2AfO1ITpegXT+zLFVBZPM4z9oO6TXzDjw93K8pBHqtXpVomPXKCODqN78BvBCmtq2t4QuMqXK/rB2CoPkiJ6o1qKo4Cv6G49YNl7ilic46MoBjB5++m+04pjA1ZZ8YlKC+1P++yKA8hjCFejQyPt0D4= 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)(8121501046)(5005006)(3002001)(10201501046)(6041248)(20161123555025)(20161123564025)(20161123558025)(20161123562025)(20161123560025)(6072148); SRVR:BN4PR07MB2244; BCL:0; PCL:0; RULEID:; SRVR:BN4PR07MB2244; X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2244; 4:VQyhnUcE4NSWMkwpyzs3Wmb+qnu000nVE3yY4Ol79HAoC7rvayaK86GAXlvGyXz0umF5V536FEXNqzoGE0lBnCi8QjlkUG3zCSdOMd+fO5B+/H4WHOt6gPz3NuNq2G12SM3OUOqljAosrVD/lV+OoffFRERFzC6JkPN4Ppyag3ZjijN4iY2+nNhfnWsO79AcfrTH5ST2Iu7iYxJJ7sUj1dhhgjYmXc7Boj5AcTz5uA/syO0Nm1muqFhB3CksngD+VCrhkJ5Z1FUKk3tXTUVRUlLHNDiiA3mub3JuP4bzJoKhS1x/WlH2FZ9n01SjqJFy1aJoP34JufiurCXpvenn+UmElLHiYwaUx7y9cwGIA7k3ev5H7daZcAjM9kwXZQ+0ayx00ly+Q3vaTR2paKak8/3V1BltWInUFxpZqPIBomoCB7zvjdNaGkV+BUZtwwHjOLi24L3iM9zqxu5/8mb5DrzDRXbfBedRUv65sisoTxijLqAYEdR/KnKnTTzU5vnar8tGwDrHczWXkQTJoyUnEVUsrQUlrCcaBymUbTmY2YxWE4UJ1JQ3PY2DPrnCKKIvDz11fykuSWtp7yTbo/934ED4P4JzpJ+wc5kOHxLiWt1Ku/Xy5qQEOL7QTGmdRdQkZf6ijHJwMeE5txyAL2khI/mrJ5SQS0RZXH59lqW64iraO2lAT1RHu35DvMzCN+p7 X-Forefront-PRVS: 0233768B38 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(6069001)(7916002)(39450400003)(6486002)(50986999)(7736002)(76176999)(42186005)(76506005)(66066001)(50226002)(305945005)(6116002)(36756003)(4326008)(2906002)(48376002)(3846002)(8676002)(50466002)(81166006)(33646002)(25786008)(5009440100003)(5660300001)(47776003)(38730400002)(2950100002)(54906002)(7416002)(6496005)(53936002)(92566002)(5003940100001)(189998001)(6306002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN4PR07MB2244; H:localhost; FPR:; SPF:None; MLV:sfv; LANG:en; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN4PR07MB2244; 23:N4DPIrgvD27BOSmHFoHp0KIjqKG3Od+h08l50NfHI?= =?us-ascii?Q?G1tLS9Fklle3pz72C5Y9S4SNSTuzwiGat52xhEO8T2VaZKlDw66iDQfAYxHT?= =?us-ascii?Q?4MKUOhtXAqaxULXjABVmIYjILzTrMnRdSD6wMiLdMud3wzNdvKYFCcU0CqW+?= =?us-ascii?Q?EyPLSy+/+NaCYrbFMeXwH+mJm9LB0ff157/q0ijMzr3e1kcwzW+Gawg154WF?= =?us-ascii?Q?KXloVX/nc38XwjQ0itPA6zrF1QjRet8ZgyLTQX8ILvkK9tkst+n45HClld3s?= =?us-ascii?Q?lYHd/1M1SyJGV5LAkrD7RvIrbPyuKyCmwTB72mKFiQlbwwNKzZmelJf5ra80?= =?us-ascii?Q?YVVMA5tCg2m8d0uC2BGrbnQlbQHNgdaELiooTY4nBt71q1wOoxYL15DP3pDH?= =?us-ascii?Q?pti3t8HPsHteehiBCEdfG/Hh/3+U4jKBrpb/LBXwpUcdO6E0uIs8T1OduepJ?= =?us-ascii?Q?cKCT3JT27bbNDnfOG9z/gN7omiAM5YVLwJBrYhxePmiaLKRC257Hml9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1tn0Kigwp39bFVLQzA7XHaX5EOPJza/b+7iHIS203P4ZVHCazBuyntUp0g3zgawt3nZ0vLTWQ21BAUaUofsSBBUILfk8jquRMERRcS42ZMs8t/ipE1i04=; 24:h7NEZ6uv4Pa1ZhyhKE4v5eLIhScr0WvByBnl0VjEZvOdkAvUOWSHoq9rjPZvhv3cQLZk9TO0wRh2SoF8sp5ZVbYfhHXn+klufFcAwegkQME= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN4PR07MB2244; 7:HfWlSiBjHs0KXU6kN6TGd7Qsb93V2VQVG5MO8J/mQ8cSX8tUDveknGXFED4qYelARqKzkxrDy1MZ5m18ep+ngCbxtsOGCilT6kj/vE9nYNIQqBajJYubTe/78XHSnuraIpCKk4z2xIaVnbnDTMHhzNOmVtlzNXHHYP9Y2A9LwHccHr5kzx9cQjVyuk6B+Z/B91NcxgQL8bX5+Uu/pWGwSyLTW7mEgpChHjZK6V1qXRCWmhmwAZoo9XApGG5g17YK68GP35r4+Hwe55kQgbEPZ3pu4PhaIG1GghWTQbOG1vGSeWOnGKfGJGkGuulMxw3x/fnIm/H5w8lPuSCiyGvwgg== X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Mar 2017 19:22:23.5069 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN4PR07MB2244 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170301_112247_527242_4AF9E131 X-CRM114-Status: GOOD ( 13.62 ) 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 , Bamvor Jian Zhang , 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 Signed-off-by: Bamvor Jian Zhang --- 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 e0798d7..4ea7b97f 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 a143d00..7dbb473 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 +};