From patchwork Tue Jul 26 07:56:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 72776 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1548990qga; Tue, 26 Jul 2016 00:55:21 -0700 (PDT) X-Received: by 10.67.14.200 with SMTP id fi8mr36969535pad.93.1469519721424; Tue, 26 Jul 2016 00:55:21 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id s20si37971754pao.188.2016.07.26.00.55.21 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jul 2016 00:55:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; 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 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org; dmarc=fail (p=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.85_2 #1 (Red Hat Linux)) id 1bRxC4-0001Pc-NI; Tue, 26 Jul 2016 07:54:24 +0000 Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bRxB1-0000eH-BB for linux-arm-kernel@lists.infradead.org; Tue, 26 Jul 2016 07:53:24 +0000 Received: by mail-pa0-x235.google.com with SMTP id ks6so69819913pab.0 for ; Tue, 26 Jul 2016 00:52:58 -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=AtFAzM2bzXpydPZ6avFv5JLgpU4m7NR4FSYZh8lwjOE=; b=VjNu98uvJBdpOVWokadqwGfrIeyjszubRYfjJwUJQd76mW/i6wY3E5FHz0Za2ogSGW DOlf1qB0IDHbPre+mvWby9lThnHGEF4krycljbo6ZdZACtrcX5tdn+wv8kIpqsBx9bDz bZdNsvqbljozwxvymvqNqV+fU3Bnbu0PaNAbI= 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=AtFAzM2bzXpydPZ6avFv5JLgpU4m7NR4FSYZh8lwjOE=; b=diCkYfdI8YLGB0K7/coibg20BU3CJ9t2hzHP2mum30hLaQ8JYUd2yftNvtOrIbDvJn wm2j7GCkEkFkBQ1pjOqyygtE48brt5u8sOcUHydbeRM3mocdgkrTOZ4+14zY41u/IpZS +3K430M6APzOo/0sx7U+p+jmBAaxLZ3UmaLnldzVbOmHy0QOXHaQK/JFeHYYDZZw/e5q QoQbAY+DMwv/0sr5FAnW4L69REbwXAdYpgSa79ruxNnjinSyJn9+fOcYwUzmkDRawJuY fR8Pg4N5Z8Ot9oLfjy3EZJhb+KClOJzSzeHoT7FKLm2K+ScDdm3TEc5z6UhJ7lWsDv/T yScw== X-Gm-Message-State: AEkoouukdcL296rprnHtTM6Ac9iFJ3EmKn0wBXUc9DIjBbe9ffI4yhZrVYeizlmleHq6du0b X-Received: by 10.66.101.1 with SMTP id fc1mr36435252pab.84.1469519578296; Tue, 26 Jul 2016 00:52:58 -0700 (PDT) Received: from linaro.org ([121.95.100.191]) by smtp.googlemail.com with ESMTPSA id 89sm45321115pft.96.2016.07.26.00.52.57 (version=TLS1_2 cipher=AES128-SHA bits=128/128); Tue, 26 Jul 2016 00:52:57 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v23 3/9] arm64: limit memory regions based on DT property, usable-memory-range Date: Tue, 26 Jul 2016 16:56:54 +0900 Message-Id: <20160726075659.2290-4-takahiro.akashi@linaro.org> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160726075659.2290-1-takahiro.akashi@linaro.org> References: <20160726075659.2290-1-takahiro.akashi@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160726_005319_721127_98066385 X-CRM114-Status: GOOD ( 12.62 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2607:f8b0:400e:c03:0:0:0:235 listed in] [list.dnswl.org] -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_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 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+patch=linaro.org@lists.infradead.org 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 | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) -- 2.9.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 27f756a..8699a8ea 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c @@ -297,10 +297,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