From patchwork Tue Jul 2 15:58:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasly X-Patchwork-Id: 2813671 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 7A103BF4A1 for ; Tue, 2 Jul 2013 15:59:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5CA2920179 for ; Tue, 2 Jul 2013 15:59:17 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4675920177 for ; Tue, 2 Jul 2013 15:59:16 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uu2yu-0007kt-9I; Tue, 02 Jul 2013 15:59:04 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uu2yr-0002zw-GP; Tue, 02 Jul 2013 15:59:01 +0000 Received: from mail-lb0-x22a.google.com ([2a00:1450:4010:c04::22a]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uu2yo-0002zE-Cz for linux-arm-kernel@lists.infradead.org; Tue, 02 Jul 2013 15:58:59 +0000 Received: by mail-lb0-f170.google.com with SMTP id t13so3561748lbd.15 for ; Tue, 02 Jul 2013 08:58:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer; bh=fBrNgnZGSOgIly6qhp43/SJfpv8Ku+9La6Z25vY75x4=; b=Z+zVYQsZuNXmT2FvJY0BOW5sPdwZp8rApgDbZtup/PJp5un90/5ruV9pjABNYSqPng 4aNY43NiR95yWY5yPuoWpfxR3t9dkloqM8f827Z9CEszzCSv7RgX5XvDlG6mojTllM85 8SuBRL5yKVifxmx+SrxspEXRLzODgilQlw2INvumVnUytj0ItCBHd6YVh2C8HMxsfcLB pDmGvHbH4+ZTTa4gCWSdag0SE8ucMRgy2JTnPviHmOmKmzmbr2EPhQgtfbKt1fbkTeIf 78B4c55JP3uzJC5gdadlcz/8WtYy7d6ic4c3wQuvvHIFPa0X56a1PgVG8mo0vYZSnQJL pO0Q== X-Received: by 10.112.198.10 with SMTP id iy10mr7092215lbc.38.1372780711628; Tue, 02 Jul 2013 08:58:31 -0700 (PDT) Received: from localhost.localdomain (95-28-150-27.broadband.corbina.ru. [95.28.150.27]) by mx.google.com with ESMTPSA id y5sm9310999lae.2.2013.07.02.08.58.29 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Jul 2013 08:58:30 -0700 (PDT) From: Sergey Dyasly To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2] ARM: LPAE: don't reject mapping /dev/mem above 4GB Date: Tue, 2 Jul 2013 19:58:05 +0400 Message-Id: <1372780685-2528-1-git-send-email-dserrg@gmail.com> X-Mailer: git-send-email 1.8.1.2 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130702_115858_610610_538E85B7 X-CRM114-Status: GOOD ( 11.16 ) X-Spam-Score: -2.0 (--) Cc: Catalin Marinas , Russell King , Will Deacon , Sergey Dyasly X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham 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 With LPAE enabled, physical address space is larger than 4GB. Allow mapping any part of it via /dev/mem by utilizing the same check as in arm64. PHYS_MASK covers 40 bits with LPAE enabled and 32 bits otherwise. Signed-off-by: Sergey Dyasly --- v2: - Removed #ifdef and changed original function as suggested by Catalin Marinas arch/arm/mm/mmap.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c index 10062ce..09bab92 100644 --- a/arch/arm/mm/mmap.c +++ b/arch/arm/mm/mmap.c @@ -204,13 +204,11 @@ int valid_phys_addr_range(phys_addr_t addr, size_t size) } /* - * We don't use supersection mappings for mmap() on /dev/mem, which - * means that we can't map the memory area above the 4G barrier into - * userspace. + * Do not allow /dev/mem mappings beyond the supported physical range. */ int valid_mmap_phys_addr_range(unsigned long pfn, size_t size) { - return !(pfn + (size >> PAGE_SHIFT) > 0x00100000); + return !(((pfn << PAGE_SHIFT) + size) & ~PHYS_MASK); } #ifdef CONFIG_STRICT_DEVMEM