From patchwork Thu Mar 12 09:07:09 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 5992191 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 1E366BF90F for ; Thu, 12 Mar 2015 09:09:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 304CA20383 for ; Thu, 12 Mar 2015 09:09:57 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4D3F820381 for ; Thu, 12 Mar 2015 09:09:56 +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 1YVz5e-00022B-2x; Thu, 12 Mar 2015 09:07:38 +0000 Received: from cantor2.suse.de ([195.135.220.15] helo=mx2.suse.de) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YVz5Y-0001HS-RT for linux-arm-kernel@lists.infradead.org; Thu, 12 Mar 2015 09:07:33 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1E62DADCA; Thu, 12 Mar 2015 09:07:09 +0000 (UTC) From: Andreas Schwab To: Alexander Graf Subject: [PATCH] arm64: fix implementation of mmap2 compat syscall References: <1417707993-82290-1-git-send-email-agraf@suse.de> <2583329.jVX0TanYzO@wuerfel> <550062D6.3000101@suse.de> <55008557.3000200@suse.de> X-Yow: Wow! Look!! A stray meatball!! Let's interview it! Date: Thu, 12 Mar 2015 10:07:09 +0100 In-Reply-To: <55008557.3000200@suse.de> (Alexander Graf's message of "Wed, 11 Mar 2015 13:11:35 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.91 (gnu/linux) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150312_020733_259234_0C9947F9 X-CRM114-Status: GOOD ( 13.36 ) X-Spam-Score: -5.0 (-----) Cc: Arnd Bergmann , Catalin Marinas , Michael Matz , Will Deacon , "linux-kernel@vger.kernel.org" , Dirk =?utf-8?Q?M=C3=BCller?= , Suravee Suthikulanit , "linux-arm-kernel@lists.infradead.org" X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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=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 The arm mmap2 syscall takes the offset in units of 4K, thus with 64K pages the offset needs to be scaled to units of pages. Signed-off-by: Andreas Schwab --- arch/arm64/include/asm/unistd32.h | 2 +- arch/arm64/kernel/entry32.S | 18 ++++++++++++++++++ arch/arm64/kernel/sys32.c | 6 ++++++ 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index 2722442..cef934a 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -406,7 +406,7 @@ __SYSCALL(__NR_vfork, sys_vfork) #define __NR_ugetrlimit 191 /* SuS compliant getrlimit */ __SYSCALL(__NR_ugetrlimit, compat_sys_getrlimit) /* SuS compliant getrlimit */ #define __NR_mmap2 192 -__SYSCALL(__NR_mmap2, sys_mmap_pgoff) +__SYSCALL(__NR_mmap2, compat_sys_mmap2_wrapper) #define __NR_truncate64 193 __SYSCALL(__NR_truncate64, compat_sys_truncate64_wrapper) #define __NR_ftruncate64 194 diff --git a/arch/arm64/kernel/entry32.S b/arch/arm64/kernel/entry32.S index 9a8f6ae..17f3296 100644 --- a/arch/arm64/kernel/entry32.S +++ b/arch/arm64/kernel/entry32.S @@ -19,9 +19,12 @@ */ #include +#include #include #include +#include +#include /* * System call wrappers for the AArch32 compatibility layer. @@ -54,6 +57,21 @@ ENTRY(compat_sys_fstatfs64_wrapper) ENDPROC(compat_sys_fstatfs64_wrapper) /* + * Note: off_4k (w5) is always units of 4K. If we can't do the requested + * offset, we return EINVAL. + */ +#if PAGE_SHIFT > 12 +ENTRY(compat_sys_mmap2_wrapper) + tst w5, #~PAGE_MASK >> 12 + b.ne 1f + lsr w5, w5, #PAGE_SHIFT - 12 + b sys_mmap_pgoff +1: mov x0, #-EINVAL + ret lr +ENDPROC(compat_sys_mmap2_wrapper) +#endif + +/* * Wrappers for AArch32 syscalls that either take 64-bit parameters * in registers or that take 32-bit parameters which require sign * extension. diff --git a/arch/arm64/kernel/sys32.c b/arch/arm64/kernel/sys32.c index 2d5ab3c..7800bb1 100644 --- a/arch/arm64/kernel/sys32.c +++ b/arch/arm64/kernel/sys32.c @@ -24,6 +24,7 @@ #include #include +#include asmlinkage long compat_sys_sigreturn_wrapper(void); asmlinkage long compat_sys_rt_sigreturn_wrapper(void); @@ -37,6 +38,11 @@ asmlinkage long compat_sys_readahead_wrapper(void); asmlinkage long compat_sys_fadvise64_64_wrapper(void); asmlinkage long compat_sys_sync_file_range2_wrapper(void); asmlinkage long compat_sys_fallocate_wrapper(void); +#if PAGE_SHIFT > 12 +asmlinkage long compat_sys_mmap2_wrapper(void); +#else +#define compat_sys_mmap2_wrapper sys_mmap_pgoff +#endif #undef __SYSCALL #define __SYSCALL(nr, sym) [nr] = sym,