From patchwork Mon Nov 2 23:30:42 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yury Norov X-Patchwork-Id: 7538881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B0F13BEEA4 for ; Mon, 2 Nov 2015 23:39:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 73E89205E3 for ; Mon, 2 Nov 2015 23:38:59 +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 182D42057F for ; Mon, 2 Nov 2015 23:38:58 +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 1ZtOev-0001xV-4Y; Mon, 02 Nov 2015 23:37:05 +0000 Received: from mail-bn1bon0093.outbound.protection.outlook.com ([157.56.111.93] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZtOby-0005z7-22 for linux-arm-kernel@lists.infradead.org; Mon, 02 Nov 2015 23:34:43 +0000 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Yuri.Norov@caviumnetworks.com; Received: from localhost (109.252.143.100) by BLUPR07MB612.namprd07.prod.outlook.com (10.141.207.27) with Microsoft SMTP Server (TLS) id 15.1.312.18; Mon, 2 Nov 2015 23:33:57 +0000 From: Yury Norov To: , , , Subject: [PATCH v6 13/17] arm64:ilp32: add sys_ilp32.c and a separate table (in entry.S) to use it Date: Tue, 3 Nov 2015 02:30:42 +0300 Message-ID: <1446507046-24604-14-git-send-email-ynorov@caviumnetworks.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1446507046-24604-1-git-send-email-ynorov@caviumnetworks.com> References: <1446507046-24604-1-git-send-email-ynorov@caviumnetworks.com> MIME-Version: 1.0 X-Originating-IP: [109.252.143.100] X-ClientProxiedBy: VI1PR05CA0017.eurprd05.prod.outlook.com (25.162.33.155) To BLUPR07MB612.namprd07.prod.outlook.com (10.141.207.27) X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB612; 2:QQSYsO9I9doowty87qPBLlKKGVxPIvt9XztCoMyq/9rVD7Xdg1aNuzHbYeDFNL4l6IdSw63u/OAKdhIJN81uzbXbtFJEGpzMkW2qaJ2u18J2VNyJvBYTqfzzviwlqg/elI/yKxtp0XbTqrS8impIsAzM7f3ur0/cLHzQOEiq+0k=; 3:bzmCVadBn3k/a5WjMTvWWHt79PNT87rINg4t+lIl9ANebPEGjs5xiciUcuPJgzbgL+MFEaVv6PcJkOiS+eyxCj56o1XqIaRX9OWWrqHgPSMBhHFp55M5QAub39lxqLFKkCVhkgXebw4HWsW1HV3bkQ==; 25:2BB/raGDFuPVWqUkildVXuPAL/4JUovREOa3gKbPrX5+UQ5QQRcTA5TddYWeWG9uKZzgmGaqz+4OlPfBwo4oYuUagcujUtatmp/lblljFh2n9EYk7Sh3ollR0LKBbPzpuSSzk6rfZ1jOWGn6iAfAtBWpZsX0d0QSMbrN/2Lzb1dUbH5VSjvnMxCGTNQPqy/MBBTrjxt64B9YyizP05tuGMELTZRSsVosQjS1bgKIL+aQwy9HSgUgRnUnDvPpTQMv X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR07MB612; X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB612; 20:eKVnGlhm7kW6M7cR8MSbjq+z9XPho3VS1Urm+gyb7E/4SPWmd3Ai4vjTTT/gsl94cKskjca8BjLHqgJzjrl/l//H1Pv6xUJPJFJhpTScO5iwupugA3NmskqnhrooZcqvs7m6B6bIj2haeVb832rMtuWK5JDnyOtz1yVmvPhTiW24kd6QlnkrsP8vnkYeaJlsTLLk1NOEmRRfuqA1sRkGyRe0vbyYCAMU7KFw4gfsPb95rfNYpOziHkyI1p6L3jytDkGIOD8v6hRwXbiW5v1WLcYn/+JqXDJsONLbwrl87OWLLojMw14wxDjOzT7QdeBTFO6F4rE2GeXTygflyrk+lHCDs1jimfZsguwWw371S2Rt0fwa1NqXFnyuH4HmJSf1ijggMiac0RYLmrbMRiM1mBlI078Y1EwZQibHH6vNk69d2Bue8G6n4OSfSoUEqsUo0kw5sdb2zP2FQ+SVionDW24M9W55Q5vAGsG6GbAirlv1pJSvSTgYIN7NIFiqksKzizp2DQKlzP92osJhuDXrNJktpQakdfG74cnXKviRxwo36Kw0zCdD2JlXlz5zQmseoNrHMs5bEDE3bSVC/0AOP/7Vc+uzPE5XFBvRhXGeJRI= 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)(520078)(5005006)(3002001)(10201501046); SRVR:BLUPR07MB612; BCL:0; PCL:0; RULEID:; SRVR:BLUPR07MB612; X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB612; 4:nD9kM/0basFaBkx1y0Mf6aMybGsUG2F2V40Mxw+PQ7zh+pdvibmzdZrvkB88XhfYlNl/NAb6Yqtg2/F+hHaC1z4PpVG86Z1ALYCh2pxzU2LstotMfuEJatdsiE05X94njWRz46b5WEDhqjoCUMTDi8wzwE3uxTI6X44/UfvO8s8SwyQ1PZWqRMndMId975cD690MmkLjemqJ21IwZ+pvDZzkftQp25pbpsOzPI6gbUil+BsxN33dqZYSXXM7UsCO4W4Ir2FHRGsar0MoaH+BHOBy4K4DVx3yVhPbXq4tqa4EXahhMHcIzhpjGojdzmhv19+6nZ3izXrZm4fk7m7QxYBXeJ798xqyja0jRO4y0mjoCVvORRm8DHbpzY4ZHjXR X-Forefront-PRVS: 0748FF9A04 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(199003)(189002)(4001430100002)(19580395003)(106356001)(92566002)(50466002)(19580405001)(36756003)(5003940100001)(50226001)(87976001)(47776003)(2201001)(66066001)(40100003)(189998001)(122386002)(97736004)(81156007)(101416001)(5004730100002)(77096005)(5008740100001)(33646002)(50986999)(105586002)(229853001)(48376002)(5001960100002)(107886002)(5007970100001)(2950100001)(42186005)(15975445007)(5001770100001)(76506005)(76176999)(2004002)(2101003); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR07MB612; 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; BLUPR07MB612; 23:zY/vAhb6UQ9Qq3sbdmorJO01ZgvBCyZ6kCMHyKiNdL?= =?us-ascii?Q?rh5H8/FUp23Zh+RnmC/OXrTaDu1vwI70FzH69tF550TJTZBJkmcj17q+ufQW?= =?us-ascii?Q?T6dk4k1GzrWEwVcH3jcRa7/nfGZR1r6yey56GJ8RpN4BYgyO3w5tQn1TfZPJ?= =?us-ascii?Q?j5DJKu94HSMcwROszcmwgu6olNxCC1aTEHEB4xfHNnTearjXZiol09ueqA6J?= =?us-ascii?Q?fyvep6qHvWlKZmZgkDXK3oOSAlx4zUJKwuYijdnJsgU5AooZ0XD2x2mOoGis?= =?us-ascii?Q?hj0I0RUG64HPC33O2SQy8eCQTbPk0qwuAElbOQbaJLAgN9hSxJ6GTChh5GFw?= =?us-ascii?Q?RuDOfVOQx2GU12r/4LFjuU1nexiKYewjNe9GQ/XoB1ZOjKaDYrk8QXhIBMx9?= =?us-ascii?Q?4hI5IZpbHcxgJ0laUzYX6NNQzdMBaqEwdGeDmw3z/oFt4nxEil+gZaQx/Y7W?= =?us-ascii?Q?uzH7LRrloM5QFXqzVBb7nB4WKSbbP7tuLhErnFpv+QBa6G2AD0rOx31aUsJF?= =?us-ascii?Q?2FUTx2CNeIQdw4/dtiz4fB0jD9K/rq5dCUCZXmzu1HK6MPf08zT+eHBT+0kn?= =?us-ascii?Q?8bKv/qfBts7haLds1oSbsO3xvBh8M1GmZTtj9AZVOlDCT/WNGo87u9RLq1jF?= =?us-ascii?Q?mg/u8gBvc3ThqU3V9sM5Jsr7RFFUodgClmR1ZHw/jFls60gnJ1i2/pHQnMJY?= =?us-ascii?Q?lCy43g0wS4q8A3P3grK1HPFVkBFGjbWQK5NWP8Gu5do1BR42ikiotGsAeTx5?= =?us-ascii?Q?0dIxBxZ/3CoivVpSLPSbkuexP8JCLSDpdMgfGgDkdlzOOt8c4IBLBLDfBx3J?= =?us-ascii?Q?p1wm1o56VCioyC2raySpIRJf7aTdjHW4xwOreJnIhfsdH9iHcCo7A2IznfP0?= =?us-ascii?Q?W6bO5JFFFaJFzsDTS9YXzIEr5cAHwqQ5z7WDqMAs6MI2yzmiJlJK1LZKZLsX?= =?us-ascii?Q?O9lntF912/Kpn6TtXo9cS0X7oOTZHXRaQ+X6XQ9AYdzT+85v89JbPAR838qI?= =?us-ascii?Q?TriPUDMgSxV48Zg0Lk6oqKCbnCwd1By3cZ2POOn9641wiCowwlL/7C8WOb4K?= =?us-ascii?Q?j2gt1GSPEeTYgrmuD9fIeQX1ZUfDZ6SnKiIH2QvuUsu8SL5ZTvJBwtytiOE8?= =?us-ascii?Q?kvBCxVBubl4K/lWlHWUfS3ZNWtuYG3?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR07MB612; 5:LTOpJJZUlLliHZmNQe758TqmH3D1sl9ArSM3eWl8/ll84ukz1qpjMpDxmh9SWGssgl05V9bjYcrpNuwsvsmC5WyIB9OTi64ET49y3meMqC1Yr4ySukSLmG8elzYwYJUgv2KPjUcQ7LKzLBviFurv7w==; 24:OZT/DOp8R42mSHXTicH1Ag/7vYy9PjzEnMarpeI2HqG90KXknJF1vzmGgwSTtWznqWklg7h3OiGo4IZNJNhUiAQqertuWzvwZPXlsNXPXuw=; 20:rEAuviYuEZVd6mKM7onSQ7Ft2D4p/PTl8OjmKtH22uszy+J/QvDab8RBZaMqcJNgiUGkdmRXPWw/FimzWlA1Jg== SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Nov 2015 23:33:57.5535 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR07MB612 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151102_153403_275270_3E18A8A7 X-CRM114-Status: GOOD ( 14.32 ) 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, Nathan_Lynch@mentor.com, agraf@suse.de, klimov.linux@gmail.com, Andrew Pinski , broonie@kernel.org, jan.dakinevich@gmail.com, Andrew Pinski , ddaney.cavm@gmail.com, bamvor.zhangjian@huawei.com, Yury Norov , philipp.tomsich@theobroma-systems.com, andrey.konovalov@linaro.org, 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, T_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: Philipp Tomsich Signed-off-by: Christoph Muellner Signed-off-by: Yury Norov Signed-off-by: Andrew Pinski Reviewed-by: David Daney --- arch/arm64/include/asm/unistd.h | 7 +- arch/arm64/kernel/Makefile | 1 + arch/arm64/kernel/entry.S | 12 ++- arch/arm64/kernel/sys_ilp32.c | 221 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 239 insertions(+), 2 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 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..6c7d274 --- /dev/null +++ b/arch/arm64/kernel/sys_ilp32.c @@ -0,0 +1,221 @@ +/* + * 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 sys_rt_sigreturn sys_rt_sigreturn_wrapper +#define sys_rt_sigsuspend compat_sys_rt_sigsuspend +#define sys_rt_sigaction compat_sys_rt_sigaction +#define sys_rt_sigprocmask compat_sys_rt_sigprocmask +#define sys_rt_sigpending compat_sys_rt_sigpending +#define sys_rt_sigtimedwait compat_sys_rt_sigtimedwait +#define sys_rt_sigqueueinfo compat_sys_rt_sigqueueinfo +#define sys_rt_sigpending compat_sys_rt_sigpending + +/* Using Compat syscalls where necessary */ +#define sys_ioctl compat_sys_ioctl +/* iovec */ +#define sys_readv compat_sys_readv +#define sys_writev compat_sys_writev +#define sys_preadv compat_sys_preadv64 +#define sys_pwritev compat_sys_pwritev64 +#define sys_vmsplice compat_sys_vmsplice +/* robust_list_head */ +#define sys_set_robust_list compat_sys_set_robust_list +#define sys_get_robust_list compat_sys_get_robust_list + +/* kexec_segment */ +#define sys_kexec_load compat_sys_kexec_load + +/* Ptrace has some structures which are different between ILP32 and LP64 */ +#define sys_ptrace compat_sys_ptrace + +/* struct msghdr */ +#define sys_msgctl compat_sys_msgctl +#define sys_recvfrom compat_sys_recvfrom +#define sys_recvmmsg compat_sys_recvmmsg +#define sys_sendmmsg compat_sys_sendmmsg +#define sys_sendmsg compat_sys_sendmsg +#define sys_recvmsg compat_sys_recvmsg +#define sys_msgsnd compat_sys_msgsnd +#define sys_msgrcv compat_sys_msgrcv + +#define sys_setsockopt compat_sys_setsockopt +#define sys_getsockopt compat_sys_getsockopt + +/* Array of pointers */ +#define sys_execve compat_sys_execve +#define sys_move_pages compat_sys_move_pages + +/* iovec */ +#define sys_process_vm_readv compat_sys_process_vm_readv +#define sys_process_vm_writev compat_sys_process_vm_writev + +/* Pointer in struct */ +#define sys_mount compat_sys_mount + +/* NUMA */ +/* unsigned long bitmaps */ +#define sys_get_mempolicy compat_sys_get_mempolicy +#define sys_set_mempolicy compat_sys_set_mempolicy +#define sys_mbind compat_sys_mbind +/* array of pointers */ +/* unsigned long bitmaps */ +#define sys_migrate_pages compat_sys_migrate_pages + +/* Scheduler */ +/* unsigned long bitmaps */ +#define sys_sched_setaffinity compat_sys_sched_setaffinity +#define sys_sched_getaffinity compat_sys_sched_getaffinity + +/* iov usage */ +#define sys_keyctl compat_sys_keyctl + +/* aio */ +/* Pointer to Pointer */ +#define sys_io_setup compat_sys_io_setup +/* Array of pointers */ +#define sys_io_submit compat_sys_io_submit + +#define sys_nanosleep compat_sys_nanosleep + +#define sys_lseek sys_llseek + +#define sys_setitimer compat_sys_setitimer +#define sys_getitimer compat_sys_getitimer + +#define sys_gettimeofday compat_sys_gettimeofday +#define sys_settimeofday compat_sys_settimeofday +#define sys_adjtimex compat_sys_adjtimex + +#define sys_clock_gettime compat_sys_clock_gettime +#define sys_clock_settime compat_sys_clock_settime + +#define sys_timerfd_gettime compat_sys_timerfd_gettime +#define sys_timerfd_settime compat_sys_timerfd_settime +#define sys_utimensat compat_sys_utimensat + +#define sys_getrlimit compat_sys_getrlimit +#define sys_setrlimit compat_sys_setrlimit +#define sys_getrusage compat_sys_getrusage + +#define sys_futex compat_sys_futex +#define sys_get_robust_list compat_sys_get_robust_list +#define sys_set_robust_list compat_sys_set_robust_list + +#define sys_pselect6 compat_sys_pselect6 +#define sys_ppoll compat_sys_ppoll + +asmlinkage long compat_sys_mmap2_wrapper(void); +#define sys_mmap compat_sys_mmap2_wrapper + +asmlinkage long compat_sys_fstatfs64_wrapper(void); +#define sys_fstatfs compat_sys_fstatfs64_wrapper +asmlinkage long compat_sys_statfs64_wrapper(void); +#define sys_statfs compat_sys_statfs64_wrapper + +/* We need to make sure the pointer gets copied correctly. */ +asmlinkage long ilp32_sys_mq_notify(mqd_t mqdes, const struct sigevent __user *u_notification) +{ + struct sigevent __user *p = NULL; + if (u_notification) { + struct sigevent n; + p = compat_alloc_user_space(sizeof(*p)); + if (copy_from_user(&n, u_notification, sizeof(*p))) + return -EFAULT; + if (n.sigev_notify == SIGEV_THREAD) + n.sigev_value.sival_ptr = compat_ptr((uintptr_t)n.sigev_value.sival_ptr); + if (copy_to_user(p, &n, sizeof(*p))) + return -EFAULT; + } + return sys_mq_notify(mqdes, p); +} + +/* sigevent contains sigval_t which is now 64bit always + but need special handling due to padding for SIGEV_THREAD. */ +#define sys_mq_notify ilp32_sys_mq_notify + +/* sigaltstack needs some special handling as the + padding for stack_t might not be non-zero. */ +long ilp32_sys_sigaltstack(const stack_t __user *uss_ptr, + stack_t __user *uoss_ptr) +{ + stack_t uss, uoss; + int ret; + mm_segment_t seg; + + if (uss_ptr) { + if (!access_ok(VERIFY_READ, uss_ptr, sizeof(*uss_ptr))) + return -EFAULT; + if (__get_user(uss.ss_sp, &uss_ptr->ss_sp) | + __get_user(uss.ss_flags, &uss_ptr->ss_flags) | + __get_user(uss.ss_size, &uss_ptr->ss_size)) + return -EFAULT; + /* Zero extend the sp address and the size. */ + uss.ss_sp = (void *)(uintptr_t)(unsigned int)(uintptr_t)uss.ss_sp; + uss.ss_size = (size_t)(unsigned int)uss.ss_size; + } + seg = get_fs(); + set_fs(KERNEL_DS); + /* Note we need to use uoss as we have changed the segment to the + kernel one so passing an user one around is wrong. */ + ret = sys_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL), + (stack_t __force __user *) &uoss); + set_fs(seg); + if (ret >= 0 && uoss_ptr) { + if (!access_ok(VERIFY_WRITE, uoss_ptr, sizeof(stack_t)) || + __put_user(uoss.ss_sp, &uoss_ptr->ss_sp) || + __put_user(uoss.ss_flags, &uoss_ptr->ss_flags) || + __put_user(uoss.ss_size, &uoss_ptr->ss_size)) + ret = -EFAULT; + } + return ret; +} + +/* sigaltstack needs some special handling as the padding + for stack_t might not be non-zero. */ +#define sys_sigaltstack ilp32_sys_sigaltstack + + +#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 +};