From: geoff@infradead.org (Geoff Levand)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v14 16/20] arm64: limit memory regions based on DT property, usable-memory
Date: Fri, 04 Mar 2016 23:51:15 +0000 [thread overview]
Message-ID: <a9498b31faab23d9c0db1e03ab09bcc27a5c4a95.1457135058.git.geoff@infradead.org> (raw)
In-Reply-To: <cover.1457135058.git.geoff@infradead.org>
From: AKASHI Takahiro <takahiro.akashi@linaro.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 = <BASE SIZE>
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 <takahiro.akashi@linaro.org>
---
arch/arm64/mm/init.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index ff5e01a..f46e33b 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -215,8 +215,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", &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)
{
+ fdt_enforce_memory_region();
+
memblock_enforce_memory_limit(memory_limit);
/*
--
2.5.0
next prev parent reply other threads:[~2016-03-04 23:51 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-04 23:51 [PATCH v14 00/20] arm64 kexec kernel patches v14 Geoff Levand
2016-03-04 23:51 ` [PATCH v14 06/20] arm64: kernel: Include _AC definition in page.h Geoff Levand
2016-03-04 23:51 ` [PATCH v14 11/20] Revert "arm64: remove dead code" Geoff Levand
2016-03-04 23:51 ` [PATCH v14 02/20] arm64: Cleanup SCTLR flags Geoff Levand
2016-03-04 23:51 ` [PATCH v14 08/20] arm64: Add new asm macro copy_page Geoff Levand
2016-03-04 23:51 ` [PATCH v14 04/20] arm64: Add new hcall HVC_CALL_FUNC Geoff Levand
2016-03-04 23:51 ` [PATCH v14 09/20] arm64: Add back cpu_reset routines Geoff Levand
2016-03-04 23:51 ` [PATCH v14 10/20] Revert "arm64: mm: remove unused cpu_set_idmap_tcr_t0sz function" Geoff Levand
2016-03-04 23:51 ` [PATCH v14 01/20] arm64: Fold proc-macros.S into assembler.h Geoff Levand
2016-03-04 23:51 ` [PATCH v14 03/20] arm64: Convert hcalls to use HVC immediate value Geoff Levand
2016-03-04 23:51 ` [PATCH v14 07/20] arm64: Promote KERNEL_START/KERNEL_END definitions to a header file Geoff Levand
2016-03-04 23:51 ` [PATCH v14 12/20] arm64/kexec: Add core kexec support Geoff Levand
2016-03-11 11:37 ` James Morse
2016-03-04 23:51 ` [PATCH v14 05/20] arm64: kvm: allows kvm cpu hotplug Geoff Levand
2016-03-04 23:51 ` [PATCH v14 14/20] arm64/kexec: Add pr_debug output Geoff Levand
2016-03-11 11:39 ` James Morse
2016-03-04 23:51 ` [PATCH v14 17/20] arm64: kdump: implement machine_crash_shutdown() Geoff Levand
2016-03-04 23:51 ` [PATCH v14 13/20] arm64/kexec: Enable kexec in the arm64 defconfig Geoff Levand
2016-03-04 23:51 ` [PATCH v14 18/20] arm64: kdump: add kdump support Geoff Levand
2016-03-04 23:51 ` [PATCH v14 20/20] arm64: kdump: update a kernel doc Geoff Levand
2016-03-04 23:51 ` Geoff Levand [this message]
2016-03-04 23:51 ` [PATCH v14 15/20] arm64: kdump: reserve memory for crash dump kernel Geoff Levand
2016-03-04 23:51 ` [PATCH v14 19/20] arm64: kdump: enable kdump in the arm64 defconfig Geoff Levand
2016-03-07 22:25 ` [PATCH v14 00/20] arm64 kexec kernel patches v14 Azriel Samson
2016-03-07 23:35 ` Geoff Levand
2016-03-08 0:23 ` AKASHI Takahiro
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=a9498b31faab23d9c0db1e03ab09bcc27a5c4a95.1457135058.git.geoff@infradead.org \
--to=geoff@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).