[PATCH 2/2] fixup! arm64: Add support for binary image files

AKASHI Takahiro takahiro.akashi at linaro.org
Mon Aug 29 01:28:41 PDT 2016


Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
 kexec/arch/arm64/kexec-image-arm64.c | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c
index b77b63e..77cff59 100644
--- a/kexec/arch/arm64/kexec-image-arm64.c
+++ b/kexec/arch/arm64/kexec-image-arm64.c
@@ -3,7 +3,9 @@
  */
 
 #define _GNU_SOURCE
+
 #include "kexec-arm64.h"
+#include <limits.h>
 
 int image_arm64_probe(const char *kernel_buf, off_t kernel_size)
 {
@@ -29,27 +31,44 @@ int image_arm64_load(int argc, char **argv, const char *kernel_buf,
 {
 	const struct arm64_image_header *h;
 	unsigned long image_base;
+	int result;
 
 	h = (const struct arm64_image_header *)(kernel_buf);
 
 	if (arm64_process_image_header(h))
 		return -1;
 
+        image_base = arm64_locate_kernel_segment(info);
+        if (image_base == ULONG_MAX) {
+                dbgprintf("%s: Kernel segment is not allocated\n", __func__);
+                result = -EFAILED;
+                goto exit;
+        }
+
+	dbgprintf("%s: image_base:    %016lx\n", __func__, image_base);
 	dbgprintf("%s: text_offset:   %016lx\n", __func__,
 		arm64_mem.text_offset);
 	dbgprintf("%s: image_size:    %016lx\n", __func__,
 		arm64_mem.image_size);
 	dbgprintf("%s: phys_offset:   %016lx\n", __func__,
 		arm64_mem.phys_offset);
+	dbgprintf("%s: vp_offset:     %016lx\n", __func__,
+		arm64_mem.vp_offset);
 	dbgprintf("%s: PE format:     %s\n", __func__,
 		(arm64_header_check_pe_sig(h) ? "yes" : "no"));
 
-	image_base = get_phys_offset() + arm64_mem.text_offset;
-	
-	add_segment_phys_virt(info, kernel_buf, kernel_size, image_base,
-		arm64_mem.image_size, 0);
+	/* load the kernel */
+	add_segment_phys_virt(info, kernel_buf, kernel_size,
+			image_base + arm64_mem.text_offset,
+			arm64_mem.image_size, 0);
+
+	result = arm64_load_other_segments(info,
+			image_base + arm64_mem.text_offset);
 
-	return arm64_load_other_segments(info, image_base);
+exit:
+        if (result)
+                fprintf(stderr, "kexec: load failed.\n");
+        return result;
 }
 
 void image_arm64_usage(void)
-- 
2.9.0




More information about the kexec mailing list