From patchwork Tue Jul 12 05:05:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 9224559 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 414BB6086B for ; Tue, 12 Jul 2016 05:02:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CD7227F17 for ; Tue, 12 Jul 2016 05:02:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 203A727F99; Tue, 12 Jul 2016 05:02:13 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 9F1DE27F17 for ; Tue, 12 Jul 2016 05:02:12 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bMpoO-0004Uj-6X; Tue, 12 Jul 2016 05:00:48 +0000 Received: from mail-pa0-x229.google.com ([2607:f8b0:400e:c03::229]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bMpoK-0004Mz-Hz for linux-arm-kernel@lists.infradead.org; Tue, 12 Jul 2016 05:00:45 +0000 Received: by mail-pa0-x229.google.com with SMTP id dx3so2496868pab.2 for ; Mon, 11 Jul 2016 22:00:23 -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=XJ9GPbXumfORudb42RYvL6rLc/Qd961SFi95DSlXMmw=; b=FrvRCbbrQKuBL6jeZPq3NfqJN9GBOxtdlhnDP/HGcMXS8f70wPlh/SGVTDfjWTx88l COE1oSZz5uiq5gh3G5WaJtnNtS3kDjBsJIqoikOaNY4+Y8kDI8DYr6UQzD5K9QvErH69 LrUtOCgQ+5nDJQCVD7AsMzWgtvAUPpC0UepBs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=XJ9GPbXumfORudb42RYvL6rLc/Qd961SFi95DSlXMmw=; b=dS6lBlhm2cPylc0/NNcAmdovtdJBGdOJF0EJTMNjfhiBef3DxHJYDVE+AGStLHyh+e OGbqZYFHGv4x57xSjSSEDKWm4WxLy2lZ40lE6wJbKjX3CswWZlZTT1x4fVnaJdhegKBH m1MhFNBAD8AGZd+ehfwG04cNtZdeB82aThHCuoBnZISt3TEmUNwAAzZWbPfJ9YM1QNkV n0shfUAQaFKNiArd/Z84YqAjnYfFrMXd4wGDLL5uvRAb5Vc9fBmUGB+RCjpfYRBs+DPZ /Pb7bKmwqktl/hhMsg/e4Ap8CJCKCDLVVSfBU0b2wDRimNMlRWu/zoDF+u3sv2RBsGHU Ucvg== X-Gm-Message-State: ALyK8tJxwBbKPsuXsWyDDRD++epOU7APEjUzv+Mm+G0KO7tTgl/8pdfocUI6iWrwEJYNy74m X-Received: by 10.66.235.227 with SMTP id up3mr546693pac.32.1468299623093; Mon, 11 Jul 2016 22:00:23 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id b7sm3621915pat.27.2016.07.11.22.00.22 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Mon, 11 Jul 2016 22:00:22 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v22 2/8] arm64: limit memory regions based on DT property, usable-memory-range Date: Tue, 12 Jul 2016 14:05:08 +0900 Message-Id: <20160712050514.22307-3-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160712050514.22307-1-takahiro.akashi@linaro.org> References: <20160712050514.22307-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160711_220044_738716_FA70E95E X-CRM114-Status: GOOD ( 12.69 ) 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@arm.com, geoff@infradead.org, kexec@lists.infradead.org, AKASHI Takahiro , robh+dt@kernel.org, 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 will be run with a limited range of memory as System RAM. On arm64, we will use a device-tree property under /chosen, linux,usable-memory-range = in order for primary kernel either on uefi or non-uefi (device tree only) system to hand over the information about usable memory region to crash dump kernel. This property will supercede entries in uefi memory map table and "memory" nodes in a device tree. Signed-off-by: AKASHI Takahiro Reviewed-by: Geoff Levand --- arch/arm64/mm/init.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 51b1302..d8b296f 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -300,10 +300,48 @@ 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 = (struct memblock_region *)data; + const __be32 *reg; + int len; + + usablemem->size = 0; + + 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; + + of_scan_flat_dt(early_init_dt_scan_usablemem, ®); + + if (reg.size) { + memblock_remove(0, PAGE_ALIGN(reg.base)); + memblock_remove(round_down(reg.base + reg.size, PAGE_SIZE), + ULLONG_MAX); + } +} + 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