Blob Blame History Raw
From 359dec003b758e4d950de965f76ecaf6d81c007d Mon Sep 17 00:00:00 2001
Message-Id: <359dec003b758e4d950de965f76ecaf6d81c007d.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: Wed, 22 Apr 2015 11:20:27 +0900
Subject: [PATCH 12/17] arm64: clean up on crash dump

---
 kexec/arch/arm64/crashdump-arm64.c | 12 +++---------
 kexec/arch/arm64/crashdump-arm64.h |  6 +++---
 kexec/arch/arm64/kexec-elf-arm64.c |  9 +++++----
 3 files changed, 11 insertions(+), 16 deletions(-)

diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
index 04958418ae82..a929b9e3ecb1 100644
--- a/kexec/arch/arm64/crashdump-arm64.c
+++ b/kexec/arch/arm64/crashdump-arm64.c
@@ -288,7 +288,7 @@ int load_crashdump_segments(struct kexec_info *info, char **option)
 	return 0;
 }
 
-void modify_ehdr_for_crashmem(struct mem_ehdr *ehdr)
+void modify_ehdr_for_crashdump(struct mem_ehdr *ehdr)
 {
 	struct mem_phdr *phdr;
 	int i;
@@ -304,13 +304,7 @@ void modify_ehdr_for_crashmem(struct mem_ehdr *ehdr)
 	}
 }
 
-void set_crash_entry(struct mem_ehdr *ehdr, struct kexec_info *info)
+void *get_crash_entry(void)
 {
-	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);
+	return (void *)crash_reserved_mem.start + arm64_mem.text_offset;
 }
diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h
index d4fd3f2288c9..6457ea7cabec 100644
--- a/kexec/arch/arm64/crashdump-arm64.h
+++ b/kexec/arch/arm64/crashdump-arm64.h
@@ -17,10 +17,10 @@
 #define CRASH_MAX_MEMORY_RANGES	32
 
 extern struct memory_ranges usablemem_rgns;
+extern struct memory_range crash_reserved_mem;
 
 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);
+void modify_ehdr_for_crashdump(struct mem_ehdr *ehdr);
+void *get_crash_entry(void);
 
 #endif
diff --git a/kexec/arch/arm64/kexec-elf-arm64.c b/kexec/arch/arm64/kexec-elf-arm64.c
index f5ecda825278..9fda5e539471 100644
--- a/kexec/arch/arm64/kexec-elf-arm64.c
+++ b/kexec/arch/arm64/kexec-elf-arm64.c
@@ -93,16 +93,17 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
 	}
 
 	if (info->kexec_flags & KEXEC_ON_CRASH) {
+		/* allocate and initialize elf core header */
 		result = load_crashdump_segments(info, &header_option);
 
 		if (result) {
 			fprintf(stderr, "kexec: creating eflcorehdr failed.\n");
 			goto exit;
 		}
-	}
 
-	if (info->kexec_flags & KEXEC_ON_CRASH)
-		modify_ehdr_for_crashmem(&ehdr);
+		/* offset addresses to load vmlinux(elf_exec) in crash memory */
+		modify_ehdr_for_crashdump(&ehdr);
+	}
 
 	result = elf_exec_load(&ehdr, info);
 
@@ -112,7 +113,7 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
 	}
 
 	if (info->kexec_flags & KEXEC_ON_CRASH)
-		set_crash_entry(&ehdr, info);
+		info->entry = get_crash_entry();
 	else
 		info->entry = (void *)virt_to_phys(ehdr.e_entry);
 
-- 
2.1.0