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 <[EMAIL PROTECTED]> --- Applies to kexec-tools-testing 40f4b56e54c3e42ef32189682a85bcdc1bf240f1. kexec/arch/i386/crashdump-x86.c | 6 ++++-- kexec/arch/ppc64/crashdump-ppc64.c | 6 ++++-- kexec/arch/x86_64/crashdump-x86_64.c | 3 ++- kexec/crashdump-elf.c | 11 +++++++++++ kexec/crashdump.h | 6 ++++++ 5 files changed, 27 insertions(+), 5 deletions(-) --- 0001/kexec/arch/i386/crashdump-x86.c +++ work/kexec/arch/i386/crashdump-x86.c 2007-02-15 18:41:24.000000000 +0900 @@ -524,13 +524,15 @@ int load_crashdump_segments(struct kexec 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; } --- 0001/kexec/arch/ppc64/crashdump-ppc64.c +++ work/kexec/arch/ppc64/crashdump-ppc64.c 2007-02-15 18:42:15.000000000 +0900 @@ -344,13 +344,15 @@ int load_crashdump_segments(struct kexec 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; } --- 0001/kexec/arch/x86_64/crashdump-x86_64.c +++ work/kexec/arch/x86_64/crashdump-x86_64.c 2007-02-15 18:41:44.000000000 +0900 @@ -607,7 +607,8 @@ int load_crashdump_segments(struct kexec /* 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), --- 0001/kexec/crashdump-elf.c +++ work/kexec/crashdump-elf.c 2007-02-15 18:47:39.000000000 +0900 @@ -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); --- 0001/kexec/crashdump.h +++ work/kexec/crashdump.h 2007-02-15 18:48:56.000000000 +0900 @@ -7,6 +7,12 @@ extern int get_crash_notes_per_cpu(int c #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() */ _______________________________________________ fastboot mailing list [email protected] https://lists.osdl.org/mailman/listinfo/fastboot
