summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMagnus Damm <magnus@valinux.co.jp>2007-02-15 18:57:06 +0900
committerSimon Horman <horms@verge.net.au>2007-02-16 17:54:02 +0900
commitf09cb6fb977e58e77054107e1df908bb18b92e86 (patch)
treee774a82b49a5b50b3f5b4bde964ce2c22d1202dc
parent40f4b56e54c3e42ef32189682a85bcdc1bf240f1 (diff)
Keep alignment comment in elf code and use ELF_CORE_HEADER_ALIGN
Keep alignment comment in elf code and use ELF_CORE_HEADER_ALIGN This patch puts back and extends the alignment comment in crashdump-elf.c and adds a small check to make sure the arch-specific code aligns properly. Instead of hardcoding 1024 we introduce ELF_CORE_HEADER_ALIGN. The idea behind the alignment requirement is explained here: http://lists.osdl.org/mailman/htdig/fastboot/2006-November/005147.html Signed-off-by: Magnus Damm <magnus@valinux.co.jp> Acked-by: Vivek Goyal <vgoyal@in.ibm.com> Removed trainling whitespace after "kilobytes," Signed-off-by: Simon Horman <horms@verge.net.au>
-rw-r--r--kexec/arch/i386/crashdump-x86.c6
-rw-r--r--kexec/arch/ppc64/crashdump-ppc64.c6
-rw-r--r--kexec/arch/x86_64/crashdump-x86_64.c3
-rw-r--r--kexec/crashdump-elf.c11
-rw-r--r--kexec/crashdump.h6
5 files changed, 27 insertions, 5 deletions
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
index 6d33ca4..a4087b0 100644
--- a/kexec/arch/i386/crashdump-x86.c
+++ b/kexec/arch/i386/crashdump-x86.c
@@ -524,13 +524,15 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
if (arch_options.core_header_type == CORE_TYPE_ELF64) {
if (crash_create_elf64_headers(info, &elf_info64,
crash_memory_range, nr_ranges,
- &tmp, &sz, 1024) < 0)
+ &tmp, &sz,
+ ELF_CORE_HEADER_ALIGN) < 0)
return -1;
}
else {
if (crash_create_elf32_headers(info, &elf_info32,
crash_memory_range, nr_ranges,
- &tmp, &sz, 1024) < 0)
+ &tmp, &sz,
+ ELF_CORE_HEADER_ALIGN) < 0)
return -1;
}
diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c
index 66aa64a..9c0b621 100644
--- a/kexec/arch/ppc64/crashdump-ppc64.c
+++ b/kexec/arch/ppc64/crashdump-ppc64.c
@@ -344,13 +344,15 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
if (arch_options.core_header_type == CORE_TYPE_ELF64) {
if (crash_create_elf64_headers(info, &elf_info64,
crash_memory_range, nr_ranges,
- &tmp, &sz, 1024) < 0)
+ &tmp, &sz,
+ ELF_CORE_HEADER_ALIGN) < 0)
return -1;
}
else {
if (crash_create_elf32_headers(info, &elf_info32,
crash_memory_range, nr_ranges,
- &tmp, &sz, 1024) < 0)
+ &tmp, &sz,
+ ELF_CORE_HEADER_ALIGN) < 0)
return -1;
}
diff --git a/kexec/arch/x86_64/crashdump-x86_64.c b/kexec/arch/x86_64/crashdump-x86_64.c
index 0dc07c4..4afae7b 100644
--- a/kexec/arch/x86_64/crashdump-x86_64.c
+++ b/kexec/arch/x86_64/crashdump-x86_64.c
@@ -607,7 +607,8 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline,
/* Create elf header segment and store crash image data. */
if (crash_create_elf64_headers(info, &elf_info,
crash_memory_range, nr_ranges,
- &tmp, &sz, 1024) < 0)
+ &tmp, &sz,
+ ELF_CORE_HEADER_ALIGN) < 0)
return -1;
/* Hack: With some ld versions (GNU ld version 2.14.90.0.4 20030523),
diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
index 850087e..dd89180 100644
--- a/kexec/crashdump-elf.c
+++ b/kexec/crashdump-elf.c
@@ -73,6 +73,17 @@ int FUNC(struct kexec_info *info,
sz += sizeof(PHDR);
}
+ /*
+ * Make sure the ELF core header is aligned to at least 1024.
+ * We do this because the secondary kernel gets the ELF core
+ * header address on the kernel command line through the memmap=
+ * option, and this option requires 1k granularity.
+ */
+
+ if (align % ELF_CORE_HEADER_ALIGN) {
+ return -1;
+ }
+
sz += align - 1;
sz &= ~(align - 1);
diff --git a/kexec/crashdump.h b/kexec/crashdump.h
index 482acb0..2e9c7cc 100644
--- a/kexec/crashdump.h
+++ b/kexec/crashdump.h
@@ -7,6 +7,12 @@ extern int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len);
#define MAX_NOTE_BYTES 1024
/* Expecting ELF headers to fit in 4K. Increase it if you need more. */
#define KCORE_ELF_HEADERS_SIZE 4096
+/* The address of the ELF header is passed to the secondary kernel
+ * using the kernel command line option memmap=nnn.
+ * The smallest unit the kernel accepts is in kilobytes,
+ * so we need to make sure the ELF header is aligned to 1024.
+ */
+#define ELF_CORE_HEADER_ALIGN 1024
/* structure passed to crash_create_elf32/64_headers() */