Blame SOURCES/kexec-tools-2.0.8-arm64-Pass-RAM-boundary-to-purgatory.patch

a6d77e
From 04a2b7bb55bfee0495cc39796846adf8d6a313bc Mon Sep 17 00:00:00 2001
a6d77e
Message-Id: <04a2b7bb55bfee0495cc39796846adf8d6a313bc.1430751022.git.panand@redhat.com>
a6d77e
In-Reply-To: <8b40614f4c1925fe94f274dfc69d1a63537fe399.1430751022.git.panand@redhat.com>
a6d77e
References: <8b40614f4c1925fe94f274dfc69d1a63537fe399.1430751022.git.panand@redhat.com>
a6d77e
From: Pratyush Anand <panand@redhat.com>
a6d77e
Date: Mon, 4 May 2015 17:47:14 +0530
a6d77e
Subject: [PATCH 2/3] arm64: Pass RAM boundary to purgatory
a6d77e
a6d77e
RAM boundary which includes all the sections is needed for creating
a6d77e
identity page mapping and to enable d-cache for those areas.
a6d77e
a6d77e
Signed-off-by: Pratyush Anand <panand@redhat.com>
a6d77e
---
a6d77e
 kexec/arch/arm64/include/types.h | 16 ++++++++++++++++
a6d77e
 kexec/arch/arm64/kexec-arm64.c   | 16 +++++++++++++++-
a6d77e
 purgatory/arch/arm64/entry.S     | 10 ++++++++++
a6d77e
 3 files changed, 41 insertions(+), 1 deletion(-)
a6d77e
 create mode 100644 kexec/arch/arm64/include/types.h
a6d77e
a6d77e
diff --git a/kexec/arch/arm64/include/types.h b/kexec/arch/arm64/include/types.h
a6d77e
new file mode 100644
a6d77e
index 000000000000..08f833a6d585
a6d77e
--- /dev/null
a6d77e
+++ b/kexec/arch/arm64/include/types.h
a6d77e
@@ -0,0 +1,16 @@
a6d77e
+#ifndef _TYPES_H_
a6d77e
+#define _TYPES_H_
a6d77e
+
a6d77e
+#define min(x,y) ({ \
a6d77e
+	typeof(x) _x = (x);	\
a6d77e
+	typeof(y) _y = (y);	\
a6d77e
+	(void) (&_x == &_y);	\
a6d77e
+	_x < _y ? _x : _y; })
a6d77e
+
a6d77e
+#define max(x,y) ({ \
a6d77e
+	typeof(x) _x = (x);	\
a6d77e
+	typeof(y) _y = (y);	\
a6d77e
+	(void) (&_x == &_y);	\
a6d77e
+	_x > _y ? _x : _y; })
a6d77e
+
a6d77e
+#endif /* _TYPES_H_ */
a6d77e
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
a6d77e
index 12c589f8001c..8ce4a61fc9c2 100644
a6d77e
--- a/kexec/arch/arm64/kexec-arm64.c
a6d77e
+++ b/kexec/arch/arm64/kexec-arm64.c
a6d77e
@@ -28,6 +28,7 @@
a6d77e
 #include "fs2dt.h"
a6d77e
 #include "kexec-syscall.h"
a6d77e
 #include "arch/options.h"
a6d77e
+#include "types.h"
a6d77e
 
a6d77e
 /* Global varables the core kexec routines expect. */
a6d77e
 
a6d77e
@@ -588,9 +589,11 @@ static uint64_t read_sink(const char *command_line)
a6d77e
 int arm64_load_other_segments(struct kexec_info *info,
a6d77e
 	unsigned long kernel_entry, char *option)
a6d77e
 {
a6d77e
-	int result;
a6d77e
+	int result, i;
a6d77e
 	struct mem_ehdr ehdr;
a6d77e
 	unsigned long dtb_base;
a6d77e
+	unsigned long arm64_ram_start = -1;
a6d77e
+	unsigned long arm64_ram_end = 0;
a6d77e
 	unsigned long hole_min, hole_max;
a6d77e
 	char *initrd_buf = NULL;
a6d77e
 	uint64_t purgatory_sink;
a6d77e
@@ -720,6 +723,17 @@ int arm64_load_other_segments(struct kexec_info *info,
a6d77e
 
a6d77e
 		elf_rel_set_symbol(&info->rhdr, "arm64_dtb_addr", &dtb_base,
a6d77e
 				sizeof(dtb_base));
a6d77e
+		for (i = 0; i < info->nr_segments; i++) {
a6d77e
+			arm64_ram_start = min(arm64_ram_start,
a6d77e
+					(unsigned long)info->segment[i].mem);
a6d77e
+			arm64_ram_end = max(arm64_ram_end,
a6d77e
+				((unsigned long)info->segment[i].mem + 
a6d77e
+				info->segment[i].memsz));
a6d77e
+		}
a6d77e
+		elf_rel_set_symbol(&info->rhdr, "arm64_ram_start",
a6d77e
+				&arm64_ram_start, sizeof(arm64_ram_start));
a6d77e
+		elf_rel_set_symbol(&info->rhdr, "arm64_ram_end",
a6d77e
+				&arm64_ram_end, sizeof(arm64_ram_end));
a6d77e
 	}
a6d77e
 
a6d77e
 	return 0;
a6d77e
diff --git a/purgatory/arch/arm64/entry.S b/purgatory/arch/arm64/entry.S
a6d77e
index 140e91d87ab1..0713ccdec4ad 100644
a6d77e
--- a/purgatory/arch/arm64/entry.S
a6d77e
+++ b/purgatory/arch/arm64/entry.S
a6d77e
@@ -52,3 +52,13 @@ size arm64_kernel_entry
a6d77e
 arm64_dtb_addr:
a6d77e
 	.quad	0
a6d77e
 size arm64_dtb_addr
a6d77e
+
a6d77e
+.globl arm64_ram_start
a6d77e
+arm64_ram_start:
a6d77e
+	.quad	0
a6d77e
+size arm64_ram_start
a6d77e
+
a6d77e
+.globl arm64_ram_end
a6d77e
+arm64_ram_end:
a6d77e
+	.quad	0
a6d77e
+size arm64_ram_end
a6d77e
-- 
a6d77e
2.1.0
a6d77e