[PATCH 2/2] kexec: ARM: add LPAE support

Liu Hua sdu.liu at huawei.com
Thu Jun 5 04:20:08 PDT 2014


For 32-bit ARM systems with CONFIG_ARM_LPAE=y, when kexec utility
loads the crash kernel. 32-bit elf header is not enough if the
physical address exceeds 4G.

This patch checkes whether the largest physical address of the system
exceeds 4G. If so, kexec creates 64-bit elf header.Otherwise it
creates 32-bit elf header.

Signed-off-by: Wei Jitao <weijitao at huawei.com>
Signed-off-by: Liu Hua <sdu.liu at huawei.com>
---
 kexec/arch/arm/crashdump-arm.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
index 726c1e9..b523e5f 100644
--- a/kexec/arch/arm/crashdump-arm.c
+++ b/kexec/arch/arm/crashdump-arm.c
@@ -20,6 +20,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
+#include <limits.h>
 #include <elf.h>
 #include <errno.h>
 #include <stdio.h>
@@ -335,6 +336,7 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	unsigned long bufsz;
 	void *buf;
 	int err;
+	int last_ranges;
 
 	/*
 	 * First fetch all the memory (RAM) ranges that we are going to pass to
@@ -354,10 +356,25 @@ int load_crashdump_segments(struct kexec_info *info, char *mod_cmdline)
 	if (get_kernel_page_offset(info, &elf_info))
 		return -1;
 
-	err = crash_create_elf32_headers(info, &elf_info,
+	last_ranges = usablemem_rgns.size - 1;
+	if (last_ranges < 0)
+		last_ranges = 0;
+
+	if (crash_memory_ranges[last_ranges].end > ULONG_MAX) {
+
+		/* for support LPAE enabled kernel*/
+		elf_info.class = ELFCLASS64;
+
+		err = crash_create_elf64_headers(info, &elf_info,
 					 usablemem_rgns.ranges,
 					 usablemem_rgns.size, &buf, &bufsz,
 					 ELF_CORE_HEADER_ALIGN);
+	} else {
+		err = crash_create_elf32_headers(info, &elf_info,
+					 usablemem_rgns.ranges,
+					 usablemem_rgns.size, &buf, &bufsz,
+					 ELF_CORE_HEADER_ALIGN);
+	}
 	if (err)
 		return err;
 
-- 
1.9.0




More information about the kexec mailing list