Blame SOURCES/kexec-tools-2.0.14-arm64-identify-PHYS_OFFSET-correctly.patch

766e0d
From 7a4381e2042e2be308c96bc927145bc39a0594cc Mon Sep 17 00:00:00 2001
766e0d
Message-Id: <7a4381e2042e2be308c96bc927145bc39a0594cc.1489676829.git.panand@redhat.com>
766e0d
In-Reply-To: <f85183096d31d865c97565614535d84943b12908.1489676829.git.panand@redhat.com>
766e0d
References: <f85183096d31d865c97565614535d84943b12908.1489676829.git.panand@redhat.com>
766e0d
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
766e0d
Date: Wed, 15 Mar 2017 18:38:18 +0900
766e0d
Subject: [PATCH 04/10] arm64: identify PHYS_OFFSET correctly
766e0d
766e0d
Due to the kernel patch, commit e7cd190385d1 ("arm64: mark reserved
766e0d
memblock regions explicitly in iomem"), the current code will not be able
766e0d
to identify the correct value of PHYS_OFFSET if some "reserved" memory
766e0d
region, which is likely to be UEFI runtime services code/data, exists at
766e0d
an address below the first "System RAM" regions.
766e0d
766e0d
This patch fixes this issue.
766e0d
766e0d
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
766e0d
---
766e0d
 kexec/arch/arm64/iomem.h       |  7 +++++++
766e0d
 kexec/arch/arm64/kexec-arm64.c | 12 ++++++++++--
766e0d
 2 files changed, 17 insertions(+), 2 deletions(-)
766e0d
 create mode 100644 kexec/arch/arm64/iomem.h
766e0d
766e0d
diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h
766e0d
new file mode 100644
766e0d
index 000000000000..7fd66eb063e1
766e0d
--- /dev/null
766e0d
+++ b/kexec/arch/arm64/iomem.h
766e0d
@@ -0,0 +1,7 @@
766e0d
+#ifndef IOMEM_H
766e0d
+#define IOMEM_H
766e0d
+
766e0d
+#define SYSTEM_RAM		"System RAM\n"
766e0d
+#define IOMEM_RESERVED		"reserved\n"
766e0d
+
766e0d
+#endif
766e0d
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
766e0d
index 04fd3968bb52..d02b9dac3d33 100644
766e0d
--- a/kexec/arch/arm64/kexec-arm64.c
766e0d
+++ b/kexec/arch/arm64/kexec-arm64.c
766e0d
@@ -21,6 +21,7 @@
766e0d
 #include "crashdump-arm64.h"
766e0d
 #include "dt-ops.h"
766e0d
 #include "fs2dt.h"
766e0d
+#include "iomem.h"
766e0d
 #include "kexec-syscall.h"
766e0d
 #include "arch/options.h"
766e0d
 
766e0d
@@ -476,7 +477,14 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
766e0d
 		return -1;
766e0d
 
766e0d
 	r = (struct memory_range *)data + nr;
766e0d
-	r->type = RANGE_RAM;
766e0d
+
766e0d
+	if (!strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)))
766e0d
+		r->type = RANGE_RAM;
766e0d
+	else if (!strncmp(str, IOMEM_RESERVED, strlen(IOMEM_RESERVED)))
766e0d
+		r->type = RANGE_RESERVED;
766e0d
+	else
766e0d
+		return 1;
766e0d
+
766e0d
 	r->start = base;
766e0d
 	r->end = base + length - 1;
766e0d
 
766e0d
@@ -495,7 +503,7 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
766e0d
 static int get_memory_ranges_iomem(struct memory_range *array,
766e0d
 	unsigned int *count)
766e0d
 {
766e0d
-	*count = kexec_iomem_for_each_line("System RAM\n",
766e0d
+	*count = kexec_iomem_for_each_line(NULL,
766e0d
 		get_memory_ranges_iomem_cb, array);
766e0d
 
766e0d
 	if (!*count) {
766e0d
-- 
766e0d
2.9.3
766e0d