From patchwork Tue Jan 24 08:49:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 92287 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1612608qgi; Tue, 24 Jan 2017 00:51:07 -0800 (PST) X-Received: by 10.200.35.150 with SMTP id q22mr29148720qtq.237.1485247867534; Tue, 24 Jan 2017 00:51:07 -0800 (PST) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id h39si12674879qtc.171.2017.01.24.00.51.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:51:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 1cVwoj-0000EN-1U; Tue, 24 Jan 2017 08:51:05 +0000 Received: from mail-pf0-f172.google.com ([209.85.192.172]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cVwo3-00075L-I3 for linux-arm-kernel@lists.infradead.org; Tue, 24 Jan 2017 08:50:25 +0000 Received: by mail-pf0-f172.google.com with SMTP id e4so48663005pfg.1 for ; Tue, 24 Jan 2017 00:50:03 -0800 (PST) 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=HyfH8919B4iVG50MWIhtqalqSgWnduuRxqCyWdUriXc=; b=PSuEByT/uiBoTaItjnK/rHonIfHF0AYrRmj2YKJzPILVObJYcwMJwzpXnI8aDs/Em9 7QBkwfKy7qfoY7BC+HJIaaVfkTePyGSA1yAbmEm0e0MhKwNNcfFcCdR3Ay361Viumf4c W68md6Uz9R7eGKa9ZIEc+nQmOt3iWOLNqDyDc= 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=HyfH8919B4iVG50MWIhtqalqSgWnduuRxqCyWdUriXc=; b=lT9ZoIY92AinU636SNE9FU1NlNulFqTAVMZ2dr2N0M0ksTawsUZXe0zPGMJCH8bHUb ZSSEYJMa9YirnqFzxTZijQE3ZTxr6O8FinwGioRZ3He0NAto/kvcTb0qM5LbW+Y4TbpM Qbmf0tj0y6+rv8UKKg0aU6vMSxoFJntz92JzcONYa1cSgXthZ4K7kw+MStOI7zKG1nt0 9gZTts2zKoLg6fOuSA6fADQZBX3UPfFO1h2mJ76AWtHvDQUo+mjMKfJRl5N1mfs26FCK guoKhhf1p6gRl3caL7aya/D5Z86USHYgVPLWLsUE/xAsNljBlHQPjKviUBegLTzByXvl nQ9Q== X-Gm-Message-State: AIkVDXLGow0KdKcQ9iGt+P2jd4NtJm1pATD2KfPhsTl2ICvUhOb9mnelMdppC4Wtn0dIObZk X-Received: by 10.84.233.193 with SMTP id m1mr50079215pln.126.1485247743002; Tue, 24 Jan 2017 00:49:03 -0800 (PST) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id j128sm42622210pfg.73.2017.01.24.00.49.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Jan 2017 00:49:02 -0800 (PST) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v30 02/11] arm64: limit memory regions based on DT property, usable-memory-range Date: Tue, 24 Jan 2017 17:49:56 +0900 Message-Id: <20170124085004.3892-1-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170124084638.3770-1-takahiro.akashi@linaro.org> References: <20170124084638.3770-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170124_005023_624037_493C4990 X-CRM114-Status: GOOD ( 13.73 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.5 RCVD_IN_SORBS_SPAM RBL: SORBS: sender is a spam source [209.85.192.172 listed in dnsbl.sorbs.net] -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.172 listed in list.dnswl.org] -1.2 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.192.172 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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+patch=linaro.org@lists.infradead.org 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 Acked-by: Catalin Marinas --- arch/arm64/mm/init.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.11.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index 380ebe705093..6cddb566eb21 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