From patchwork Tue Aug 18 14:24:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Catalin Marinas X-Patchwork-Id: 7031691 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 F03A6C05AC for ; Tue, 18 Aug 2015 14:27:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F23B3207D0 for ; Tue, 18 Aug 2015 14:27:19 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1FF80207CA for ; Tue, 18 Aug 2015 14:27:19 +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 1ZRhp4-0000lv-H4; Tue, 18 Aug 2015 14:25:06 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZRhp2-0008G1-8Z for linux-arm-kernel@lists.infradead.org; Tue, 18 Aug 2015 14:25:04 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 04D6475; Tue, 18 Aug 2015 07:24:32 -0700 (PDT) Received: from e104818-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8D0453F59E; Tue, 18 Aug 2015 07:24:38 -0700 (PDT) Date: Tue, 18 Aug 2015 15:24:36 +0100 From: Catalin Marinas To: Will Deacon Subject: Re: [PATCH 2/2] arm64: set MAX_MEMBLOCK_ADDR according to linear region size Message-ID: <20150818142435.GC11571@e104818-lin.cambridge.arm.com> References: <1439890482-20798-1-git-send-email-ard.biesheuvel@linaro.org> <1439890482-20798-3-git-send-email-ard.biesheuvel@linaro.org> <20150818100018.GA11021@arm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150818100018.GA11021@arm.com> User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150818_072504_356909_4AC2253C X-CRM114-Status: GOOD ( 20.70 ) X-Spam-Score: -7.3 (-------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , "robh@kernel.org" , Ard Biesheuvel , "stuart.yoder@freescale.com" , "grant.likely@linaro.org" , "linux-arm-kernel@lists.infradead.org" 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.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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 On Tue, Aug 18, 2015 at 11:00:27AM +0100, Will Deacon wrote: > On Tue, Aug 18, 2015 at 10:34:42AM +0100, Ard Biesheuvel wrote: > > The linear region size of a 39-bit VA kernel is only 256 GB, which > > may be insufficient to cover all of system RAM, even on platforms > > that have much less than 256 GB of memory but which is laid out > > very sparsely. > > > > So make sure we clip the memory we will not be able to map before > > installing it into the memblock memory table, by setting > > MAX_MEMBLOCK_ADDR accordingly. > > > > Signed-off-by: Ard Biesheuvel > > --- > > arch/arm64/include/asm/memory.h | 8 ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h > > index f800d45ea226..44a59c20e773 100644 > > --- a/arch/arm64/include/asm/memory.h > > +++ b/arch/arm64/include/asm/memory.h > > @@ -114,6 +114,14 @@ extern phys_addr_t memstart_addr; > > #define PHYS_OFFSET ({ memstart_addr; }) > > > > /* > > + * The maximum physical address that the linear direct mapping > > + * of system RAM can cover. (PAGE_OFFSET can be interpreted as > > + * a 2's complement signed quantity and negated to derive the > > + * maximum size of the linear mapping.) > > + */ > > +#define MAX_MEMBLOCK_ADDR ({ memstart_addr - PAGE_OFFSET - 1; }) With the current memory layout, this could also be __pa(~0UL). I guess we could solve this with a single patch, though I'm not sure whether we break other architectures: > If we initialised memory_limit to this value and changed early_mem to > use min (i.e. only restrict the limit further), would that avoid the > need to change the of code? Only that we can't initialise memory_limit statically since memstart_addr is not constant. We would need to do this somewhere before early_mem() is run (in setup_machine_fdt or immediately after it). My point to Ard was that since we already do a sanity check on the memblocks in early_init_dt_add_memory_arch() and ignore those below PHYS_OFFSET, it makes sense to reuse the same function since it already has all the logic in place and corresponding warnings. With a later memblock limiting we would have to add extra printing to inform the user. diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 07496560e5b9..ff8a885d5ff0 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -967,7 +967,7 @@ int __init early_init_dt_scan_chosen(unsigned long node, const char *uname, } #ifdef CONFIG_HAVE_MEMBLOCK -#define MAX_PHYS_ADDR ((phys_addr_t)~0) +#define MAX_PHYS_ADDR (__pa(~0UL)) void __init __weak early_init_dt_add_memory_arch(u64 base, u64 size) {