Keep alignment comment in elf code and use KERNEL_CMDLINE_ALIGN

This patch puts back the alignment comment to crashdump-elf.c and
adds a small check to make sure the arch-specific code aligns properly.
Instead of hardcoding 1024 we introduce KERNEL_CMDLINE_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                |    9 +++++++++
 kexec/crashdump.h                    |    2 ++
 5 files changed, 21 insertions(+), 5 deletions(-)

--- 0001/kexec/arch/i386/crashdump-x86.c
+++ work/kexec/arch/i386/crashdump-x86.c        2007-02-15 16:41:54.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,
+                                              KERNEL_CMDLINE_ALIGN) < 0)
                        return -1;
        }
        else {
                if (crash_create_elf32_headers(info, &elf_info32,
                                               crash_memory_range, nr_ranges,
-                                              &tmp, &sz, 1024) < 0)
+                                              &tmp, &sz,
+                                              KERNEL_CMDLINE_ALIGN) < 0)
                        return -1;
        }
 
--- 0001/kexec/arch/ppc64/crashdump-ppc64.c
+++ work/kexec/arch/ppc64/crashdump-ppc64.c     2007-02-15 16:45:21.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,
+                                              KERNEL_CMDLINE_ALIGN) < 0)
                        return -1;
        }
        else {
                if (crash_create_elf32_headers(info, &elf_info32,
                                               crash_memory_range, nr_ranges,
-                                              &tmp, &sz, 1024) < 0)
+                                              &tmp, &sz,
+                                              KERNEL_CMDLINE_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 16:43:08.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,
+                                      KERNEL_CMDLINE_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 16:40:48.000000000 +0900
@@ -73,6 +73,15 @@ int FUNC(struct kexec_info *info,
                sz += sizeof(PHDR);
        }
 
+       /*
+        * The kernel command line option memmap= requires 1k granularity,
+        * therefore we only accept sizes at least aligned to 1024 here.
+        */
+
+       if (align % KERNEL_CMDLINE_ALIGN) {
+               return -1;
+       }
+
        sz += align - 1;
        sz &= ~(align - 1);
 
--- 0001/kexec/crashdump.h
+++ work/kexec/crashdump.h      2007-02-15 16:42:34.000000000 +0900
@@ -7,6 +7,8 @@ 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
+/* Kernel command line alignment for memmap= argument */
+#define KERNEL_CMDLINE_ALIGN    1024
 
 /* structure passed to crash_create_elf32/64_headers() */
 
_______________________________________________
fastboot mailing list
fastboot@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/fastboot

Reply via email to