From patchwork Wed Nov 2 04:52:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 9408459 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 9EDF960721 for ; Wed, 2 Nov 2016 04:46:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9111229CC8 for ; Wed, 2 Nov 2016 04:46:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 845B729DFE; Wed, 2 Nov 2016 04:46:56 +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 198C129CC8 for ; Wed, 2 Nov 2016 04:46:56 +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 1c1nQB-0003MP-W5; Wed, 02 Nov 2016 04:45:08 +0000 Received: from mail-pf0-x22d.google.com ([2607:f8b0:400e:c00::22d]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c1nQ5-0002rc-P5 for linux-arm-kernel@lists.infradead.org; Wed, 02 Nov 2016 04:45:02 +0000 Received: by mail-pf0-x22d.google.com with SMTP id d2so4288849pfd.0 for ; Tue, 01 Nov 2016 21:44:41 -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=27VD0LkD8me/FSBJ0wn5Q2CN31+i49H0wOj5UREBolc=; b=Ap8nvVe/f3TZ3ngKH8nT5a1sdIc9JFry/U88cSJfsbkVws4oynM/t5D6I4qpdSnPTx 4Xe6wYfKwJFnZhF5g/fRWPNk0R7YTnc1qjTSpcV6VWVxE+ww928ZRvC/LPfdfzfeS/mE leInRWvSHu+EvynnPwhUF3pne8pWHVtz91Cf0= 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=27VD0LkD8me/FSBJ0wn5Q2CN31+i49H0wOj5UREBolc=; b=Tg2Nf7S2vs/7hivlQzS11iedr25V4uIS0eA/QRfqE8cw7W/RF04vQJCvvl5J+3A72v EeqoawKvL6MCBBEoJtL8zvRYTLCBj/+hZGMDkZigo1Rc6n9bZ38yQC9ffJ0Tbe7qpLqC K39CqAwOq3s0Y3rNW0fKIGNQq93UUycwCs64SkZhQGk8WhavU70kUxrdev7UIgEqtEjq J1k4tYjepwUMLKIKIwHdBbnBUSkkOsjHcbr95qDtTHHOfrLOU4KOmEmDpeH25VXl+1MM 8Z3NaNmpqHnyygGv9MFwmnLVcYXPm3K4s79As99EnOBY8cD5yrOdKOsezkPGkm7AG3ge Z/kw== X-Gm-Message-State: ABUngve9RGevS2gPo8ddYUD/6J9ShTnV8wx+s8lfZo7VgZQM2aK+oryq3NT8wZsTJ9gztHff X-Received: by 10.98.31.154 with SMTP id l26mr3166993pfj.87.1478061880973; Tue, 01 Nov 2016 21:44:40 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id k7sm516962pan.8.2016.11.01.21.44.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Nov 2016 21:44:40 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v27 2/9] arm64: limit memory regions based on DT property, usable-memory-range Date: Wed, 2 Nov 2016 13:52:43 +0900 Message-Id: <20161102045249.12058-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161102044959.11954-1-takahiro.akashi@linaro.org> References: <20161102044959.11954-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161101_214501_944943_4814DB6A X-CRM114-Status: GOOD ( 13.94 ) 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 , 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 utilizes only a subset of available memory as System RAM. On arm64 kdump, This memory range is advertized 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 ranges which are described as entries in UEFI memory map table or "memory" nodes in a device tree blob. Signed-off-by: AKASHI Takahiro Reviewed-by: Geoff Levand --- 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 212c4d1..65f1241 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -187,10 +187,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 = (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_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