From patchwork Thu Jun 27 17:24:35 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasly X-Patchwork-Id: 2794551 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 99C009F245 for ; Thu, 27 Jun 2013 17:27:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BD70120299 for ; Thu, 27 Jun 2013 17:27:09 +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 371AA20278 for ; Thu, 27 Jun 2013 17:27:08 +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 1UsFy4-0004FN-Ci; Thu, 27 Jun 2013 17:26:48 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UsFxr-0006m5-26; Thu, 27 Jun 2013 17:26:35 +0000 Received: from mail-la0-x230.google.com ([2a00:1450:4010:c03::230]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UsFxn-0006lR-8t for linux-arm-kernel@lists.infradead.org; Thu, 27 Jun 2013 17:26:32 +0000 Received: by mail-la0-f48.google.com with SMTP id lx15so1124199lab.7 for ; Thu, 27 Jun 2013 10:26:06 -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=m3AxxiAQtkODYGuwdfnm9alyLwTs13gdQxEU/OquWy0=; b=TuyvMwgPIalZO40lWqQPSZpf0dP5ye05EPkNPFnVjgxaOS0WTRBRN+bQfru/EuKAcz zhKnIJJIGPeVsiKKq0W9OHX9QRrQJb4VakXRiG5kTPPuWr/RDrk9a31ZgHtM4KrcLXNy JTuigATnGT8/BwGybgMiQorPSSdr8ZO84AMtUnRmugVXfl8aOCSc++bzUL7R0HLNdQyL 6mvmid4r58BAOKjUOqZ6+VFZMnkq87AGkbckxgIBu1pSVAiyCPRB3fKBaghQXY5s4r4a ut7ReH6CLe2RUzGa7ywVhCrpMWOMyLALErBOMzDyWpBnLaJCi/TyybO4z4dEiSiC+vbM Z1LA== X-Received: by 10.152.7.74 with SMTP id h10mr4675333laa.83.1372353966409; Thu, 27 Jun 2013 10:26:06 -0700 (PDT) Received: from localhost.localdomain (89-178-174-75.broadband.corbina.ru. [89.178.174.75]) by mx.google.com with ESMTPSA id s3sm1448433lbs.14.2013.06.27.10.26.04 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Jun 2013 10:26:05 -0700 (PDT) From: Sergey Dyasly To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] ARM: LPAE: don't reject mapping /dev/mem above 4GB Date: Thu, 27 Jun 2013 21:24:35 +0400 Message-Id: <1372353875-3262-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-20130627_132631_494722_C46AD5E4 X-CRM114-Status: GOOD ( 10.37 ) 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=-5.4 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=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 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. Reported-by: Vassili Karpov Tested-by: Vassili Karpov Signed-off-by: Sergey Dyasly --- arch/arm/mm/mmap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c index 10062ce..8f1bbbc 100644 --- a/arch/arm/mm/mmap.c +++ b/arch/arm/mm/mmap.c @@ -203,6 +203,15 @@ int valid_phys_addr_range(phys_addr_t addr, size_t size) return 1; } +#ifdef CONFIG_ARM_LPAE +/* + * 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 << PAGE_SHIFT) + size) & ~PHYS_MASK); +} +#else /* * 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 @@ -212,6 +221,7 @@ int valid_mmap_phys_addr_range(unsigned long pfn, size_t size) { return !(pfn + (size >> PAGE_SHIFT) > 0x00100000); } +#endif #ifdef CONFIG_STRICT_DEVMEM