Blob Blame History Raw
From 55cd3491542a0d696451611a4cae38db78f964dd Mon Sep 17 00:00:00 2001
Message-Id: <55cd3491542a0d696451611a4cae38db78f964dd.1431592766.git.panand@redhat.com>
In-Reply-To: <1fb6841aa15407dbf371589d7abca7bc2d35815c.1431592766.git.panand@redhat.com>
References: <1fb6841aa15407dbf371589d7abca7bc2d35815c.1431592766.git.panand@redhat.com>
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
Date: Tue, 24 Feb 2015 15:48:29 +0900
Subject: [PATCH 10/17] arm64: kdump: copy dtb file into crash kernel memory

---
 kexec/arch/arm64/crashdump-arm64.c |  6 ++++++
 kexec/arch/arm64/crashdump-arm64.h |  1 +
 kexec/arch/arm64/kexec-arm64.c     | 15 +++++++++------
 3 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
index ec83cf0c0f38..80f5985c5d85 100644
--- a/kexec/arch/arm64/crashdump-arm64.c
+++ b/kexec/arch/arm64/crashdump-arm64.c
@@ -306,3 +306,9 @@ void set_crash_entry(struct mem_ehdr *ehdr, struct kexec_info *info)
 {
 	info->entry = (void *)crash_reserved_mem.start + arm64_mem.text_offset;
 }
+
+off_t locate_dtb_in_crashmem(struct kexec_info *info, off_t dtb_size)
+{
+	return locate_hole(info, dtb_size, 128UL * 1024,
+		crash_reserved_mem.start, crash_reserved_mem.end, -1);
+}
diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h
index 3f8b38350841..d4fd3f2288c9 100644
--- a/kexec/arch/arm64/crashdump-arm64.h
+++ b/kexec/arch/arm64/crashdump-arm64.h
@@ -21,5 +21,6 @@ extern struct memory_ranges usablemem_rgns;
 int load_crashdump_segments(struct kexec_info *info, char **option);
 void modify_ehdr_for_crashmem(struct mem_ehdr *ehdr);
 void set_crash_entry(struct mem_ehdr *ehdr, struct kexec_info *info);
+off_t locate_dtb_in_crashmem(struct kexec_info *info, off_t dtb_size);
 
 #endif
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
index 173631c66951..190037c75186 100644
--- a/kexec/arch/arm64/kexec-arm64.c
+++ b/kexec/arch/arm64/kexec-arm64.c
@@ -650,12 +650,15 @@ int arm64_load_other_segments(struct kexec_info *info,
 
 	dtb_max = dtb_2.size + 2 * 1024;
 
-	dtb_base = locate_hole(info, dtb_max, 128UL * 1024,
-		arm64_mem.memstart + arm64_mem.text_offset
-			+ arm64_mem.image_size,
-		_ALIGN_UP(arm64_mem.memstart + arm64_mem.text_offset,
-			512UL * 1024 * 1024),
-		1);
+	if (info->kexec_flags & KEXEC_ON_CRASH)
+		dtb_base = locate_dtb_in_crashmem(info, dtb_max);
+	else
+		dtb_base = locate_hole(info, dtb_max, 128UL * 1024,
+			arm64_mem.memstart + arm64_mem.text_offset
+				+ arm64_mem.image_size,
+			_ALIGN_UP(arm64_mem.memstart + arm64_mem.text_offset,
+				512UL * 1024 * 1024),
+			1);
 
 	dbgprintf("dtb:    base %lx, size %lxh (%ld)\n", dtb_base, dtb_2.size,
 		dtb_2.size);
-- 
2.1.0