From patchwork Wed Mar 15 09:59:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 9625137 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 95AA760244 for ; Wed, 15 Mar 2017 09:57:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8018E2861C for ; Wed, 15 Mar 2017 09:57:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7496D2860F; Wed, 15 Mar 2017 09:57:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E8E982860A for ; Wed, 15 Mar 2017 09:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=NSRwgAKi8tgKty0A6OPaljMQLjXS54Y77ixhPZqQ4Lk=; b=Cq+iCQut+dq5klIXzEUx7UI5tF mNs2AhqJU0itRdQDSsnz5vDXtBEBGp3mf89xBsg3ILAFzB3CRAWlaho5rDDZZs1Wv8Z3WZZyfqpwZ CLzU1GjcP04SQMu0Z0l8L/spqxklFht0X4hxsQGm2yFto4TRpyXnqMPVFRZNQfBdVxpu+6hU9cJ0q UCHayHFtg2b7Ttq3zrcSzFOhEUdz6/roqfrmeV/kLT8WASsb/xoN/2fMKTcOf295KhzHm+p2e0TTY KMvgNZnKEi/Y7WZybxkLy/FMnYQqsYUBCcqYYXiWn7wzRvDnNnOJJU5SbGcmwX+OZFVOdyyRPuNWy EpEX1Rew==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1co5gY-0003RR-Oe; Wed, 15 Mar 2017 09:57:38 +0000 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1co5gT-0003Jn-Ac for linux-arm-kernel@lists.infradead.org; Wed, 15 Mar 2017 09:57:36 +0000 Received: by mail-pf0-x234.google.com with SMTP id w189so6875872pfb.0 for ; Wed, 15 Mar 2017 02:57:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yG8LYLA9luGBuG+IiDgZOxxyJ1iX6XtqqjqRrOFiOos=; b=BVXpVNeordccsxlypaPidQGaVmd3sD4xnGiCTAeXP2u8K71p59/7oATt5Wp0y5FFiT gAKDMu+Aw6/aDbZ6XlRVRYds9T8qBe7P2fFfeHMPZAxRBFVhWbbz3nWQDLWgPCLyfRp9 jL7/57YNJifPO8wkOqFxhV+GfgIIoxz76AIuc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yG8LYLA9luGBuG+IiDgZOxxyJ1iX6XtqqjqRrOFiOos=; b=jolhcrIhAayXMuxDSn7fMlg67/ZXEIo091cbPN4zJJ5NrRvJhnwOcnRm53/1HiiV9K 2zmacfZReCveAIs268tSejCdl/UTH6lPa0m8aOiN29S9QuYYZnNp+PBuLAnhZWbHQxaL 2wasAazJxVVMXXhnOK1+AinBS4T6ew3xZU/IZLhlYRdjRiWGpz/3GqmwRjK/kLNQlvWo nLxkm8Y6Yag3GcM7GGRXelH12u6AUAlSyAWtHKEP42itQJSse+MIPVMs/R5GFScizy/j 7xxhCOtpfWFY0sNnMIHlruS921ukYAmLy6UYPS79+pCuNQIV4Q9KQjk2UTC7Rw07U71d MaDQ== X-Gm-Message-State: AFeK/H3wYYC1hrU90nqtMlpObMWTMOSyW/RpH0ZQVxmmrtO/jCCSiqahYiI+9X7xZ5/7zi+Y X-Received: by 10.98.156.203 with SMTP id u72mr2634814pfk.127.1489571832717; Wed, 15 Mar 2017 02:57:12 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id p6sm3221950pgn.40.2017.03.15.02.57.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Mar 2017 02:57:12 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v33 03/14] arm64: limit memory regions based on DT property, usable-memory-range Date: Wed, 15 Mar 2017 18:59:32 +0900 Message-Id: <20170315095941.25119-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170315095656.24992-1-takahiro.akashi@linaro.org> References: <20170315095656.24992-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170315_025733_406373_7DBC858A X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , james.morse@arm.com, bauerman@linux.vnet.ibm.com, dyoung@redhat.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Crash dump kernel uses only a limited range of available memory as System RAM. On arm64 kdump, This memory range is advertised to crash dump kernel via a device-tree property under /chosen, linux,usable-memory-range = Crash dump kernel reads this property at boot time and calls memblock_cap_memory_range() to limit usable memory which are listed either in UEFI memory map table or "memory" nodes of a device tree blob. Signed-off-by: AKASHI Takahiro Reviewed-by: Geoff Levand Acked-by: Catalin Marinas Acked-by: Mark Rutland --- arch/arm64/mm/init.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index e19e06593e37..290794b1a0f1 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -188,10 +188,45 @@ static int __init early_mem(char *p) } early_param("mem", early_mem); +static int __init early_init_dt_scan_usablemem(unsigned long node, + const char *uname, int depth, void *data) +{ + struct memblock_region *usablemem = data; + const __be32 *reg; + int len; + + if (depth != 1 || strcmp(uname, "chosen") != 0) + return 0; + + reg = of_get_flat_dt_prop(node, "linux,usable-memory-range", &len); + if (!reg || (len < (dt_root_addr_cells + dt_root_size_cells))) + return 1; + + usablemem->base = dt_mem_next_cell(dt_root_addr_cells, ®); + usablemem->size = dt_mem_next_cell(dt_root_size_cells, ®); + + return 1; +} + +static void __init fdt_enforce_memory_region(void) +{ + struct memblock_region reg = { + .size = 0, + }; + + of_scan_flat_dt(early_init_dt_scan_usablemem, ®); + + if (reg.size) + memblock_cap_memory_range(reg.base, reg.size); +} + void __init arm64_memblock_init(void) { const s64 linear_region_size = -(s64)PAGE_OFFSET; + /* Handle linux,usable-memory-range property */ + fdt_enforce_memory_region(); + /* * Ensure that the linear region takes up exactly half of the kernel * virtual address space. This way, we can distinguish a linear address