From patchwork Wed Mar 11 13:35:39 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Schwab X-Patchwork-Id: 5985191 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id ECDA49F318 for ; Wed, 11 Mar 2015 13:42:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1126C202AE for ; Wed, 11 Mar 2015 13:42:44 +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 D2F89203E3 for ; Wed, 11 Mar 2015 13:42:42 +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 1YVgrc-0005O3-6F; Wed, 11 Mar 2015 13:39:56 +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 1YVgnr-0001uS-3T for linux-arm-kernel@lists.infradead.org; Wed, 11 Mar 2015 13:36:04 +0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 354D6AAC8; Wed, 11 Mar 2015 13:35:40 +0000 (UTC) From: Andreas Schwab To: Alexander Graf Subject: Re: [PATCH] arm64: Enable CONFIG_COMPAT also for 64k page size References: <1417707993-82290-1-git-send-email-agraf@suse.de> <20141208101026.GD27367@arm.com> <550025E0.7030008@suse.de> <5396604.TRferrWZgF@wuerfel> X-Yow: I'd like TRAINED SEALS and a CONVERTIBLE on my doorstep by NOON!! Date: Wed, 11 Mar 2015 14:35:39 +0100 In-Reply-To: (Alexander Graf's message of "Wed, 11 Mar 2015 08:08:41 -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-20150311_063603_545076_2AEEC0D4 X-CRM114-Status: GOOD ( 14.67 ) 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 From 29457829093014f39c7d1c926c9b86b6cb5709db Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Mon, 9 Mar 2015 17:27:36 +0100 Subject: [PATCH] arm64: fix implementation of mmap2 compat syscall 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. Tested-by: Alexander Graf --- 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..61e416d 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_SIZE > 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,