From patchwork Thu Jul 4 15:36:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergey Dyasly X-Patchwork-Id: 2823851 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 67AFB9F3C3 for ; Thu, 4 Jul 2013 15:37:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7561620134 for ; Thu, 4 Jul 2013 15:37:32 +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 C30DF200F2 for ; Thu, 4 Jul 2013 15:37:30 +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 1Uular-0001s0-Ub; Thu, 04 Jul 2013 15:37:14 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uulam-0003rt-Kk; Thu, 04 Jul 2013 15:37:08 +0000 Received: from mail-la0-x22a.google.com ([2a00:1450:4010:c03::22a]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Uulak-0003rH-6L for linux-arm-kernel@lists.infradead.org; Thu, 04 Jul 2013 15:37:06 +0000 Received: by mail-la0-f42.google.com with SMTP id eb20so1366164lab.15 for ; Thu, 04 Jul 2013 08:36:43 -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=tI+5a3s1/RTRaxAkSz11G0WtRGtMSPI9q87BE3g/8D8=; b=sQktS/B4A4wfXouKMhUvaYsInmKXHTPIUgkj39T6Ft2lsPufFaol0fjP3WZRmwtvsc QeVs6vwWlPJhtDbKiKXfluDnr1godRsXF0LNs/laPygEaeTdXchvjf8vtJ3jUs9I03m7 MDXghqHtw0INRwjbZLu1l3B3kDNmmBPd6Vqp0/QFOPbVWERNkOMbsFZ6L+XZuXp82ktL HdpcORBC8QoADaNPlUcFRZVe0mmLKT3QVkRMRSJW9FR8DS4q9OVLtFpvv7iZhPIZcddM P/3SsN5CzCEjKlDnVCBtgM+emmEei+R0od/yaCRnZ9+Q+HBDermouCEVCPEmSfxxNbTq Pkrg== X-Received: by 10.152.9.69 with SMTP id x5mr3112739laa.57.1372952203760; Thu, 04 Jul 2013 08:36:43 -0700 (PDT) Received: from localhost.localdomain (95-24-237-85.broadband.corbina.ru. [95.24.237.85]) by mx.google.com with ESMTPSA id am8sm1341776lac.1.2013.07.04.08.36.42 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 04 Jul 2013 08:36:42 -0700 (PDT) From: Sergey Dyasly To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v3] ARM: LPAE: don't reject mapping /dev/mem above 4GB Date: Thu, 4 Jul 2013 19:36:25 +0400 Message-Id: <1372952185-2553-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-20130704_113706_385610_6680FB63 X-CRM114-Status: GOOD ( 11.69 ) 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.3 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 using PHYS_MASK to determine valid range. PHYS_MASK covers 40 bits with LPAE enabled and 32 bits otherwise. Reported-by: Vassili Karpov Signed-off-by: Sergey Dyasly Acked-by: Catalin Marinas --- v3: - Fixed 32-bit overflow v2: - Removed #ifdef and changed original function 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..2db5d2d 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 + (size >> PAGE_SHIFT)) <= (1 + (PHYS_MASK >> PAGE_SHIFT)); } #ifdef CONFIG_STRICT_DEVMEM