diff options
-rw-r--r-- | kexec/arch/i386/crashdump-x86.c | 20 | ||||
-rw-r--r-- | kexec/arch/ia64/crashdump-ia64.c | 16 | ||||
-rw-r--r-- | kexec/arch/ppc64/crashdump-ppc64.c | 8 | ||||
-rw-r--r-- | kexec/arch/x86_64/crashdump-x86_64.c | 8 | ||||
-rw-r--r-- | kexec/crashdump.c | 5 | ||||
-rw-r--r-- | kexec/crashdump.h | 2 |
6 files changed, 30 insertions, 29 deletions
diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c index b5d1d60..ee25306 100644 --- a/kexec/arch/i386/crashdump-x86.c +++ b/kexec/arch/i386/crashdump-x86.c @@ -434,7 +434,7 @@ static int cmdline_add_elfcorehdr(char *cmdline, unsigned long addr) * backward compatibility, other architectures can use the per * cpu version get_crash_notes_per_cpu() directly. */ -static int get_crash_notes(int cpu, uint64_t *addr) +static int get_crash_notes(int cpu, uint64_t *addr, uint64_t *len) { char crash_notes[PATH_MAX]; char line[MAX_LINE]; @@ -451,13 +451,15 @@ static int get_crash_notes(int cpu, uint64_t *addr) die("Cannot parse %s: %s\n", crash_notes, strerror(errno)); } + *addr = __pa(vaddr + (cpu * MAX_NOTE_BYTES)); + *len = MAX_NOTE_BYTES; #if 0 printf("crash_notes addr = %Lx\n", *addr); #endif return 0; } else - return get_crash_notes_per_cpu(cpu, addr); + return get_crash_notes_per_cpu(cpu, addr, len); } /* Prepares the crash memory elf64 headers and stores in supplied buffer. */ @@ -469,7 +471,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, int i; char *bufp; long int nr_cpus = 0; - uint64_t notes_addr; + uint64_t notes_addr, notes_len; bufp = (char*) buf; @@ -503,7 +505,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, } for (i = 0; i < nr_cpus; i++) { - if (get_crash_notes(i, ¬es_addr) < 0) { + if (get_crash_notes(i, ¬es_addr, ¬es_len) < 0) { /* This cpu is not present. Skip it. */ continue; } @@ -513,7 +515,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, phdr->p_flags = 0; phdr->p_offset = phdr->p_paddr = notes_addr; phdr->p_vaddr = 0; - phdr->p_filesz = phdr->p_memsz = MAX_NOTE_BYTES; + phdr->p_filesz = phdr->p_memsz = notes_len; /* Do we need any alignment of segments? */ phdr->p_align = 0; @@ -564,7 +566,7 @@ static int prepare_crash_memory_elf32_headers(struct kexec_info *info, int i; char *bufp; long int nr_cpus = 0; - uint64_t notes_addr; + uint64_t notes_addr, notes_len; bufp = (char*) buf; @@ -597,10 +599,8 @@ static int prepare_crash_memory_elf32_headers(struct kexec_info *info, return -1; } - /* Need to find a better way to determine per cpu notes section size. */ -#define MAX_NOTE_BYTES 1024 for (i = 0; i < nr_cpus; i++) { - if (get_crash_notes(i, ¬es_addr) < 0) { + if (get_crash_notes(i, ¬es_addr, ¬es_len) < 0) { /* This cpu is not present. Skip it. */ return -1; } @@ -610,7 +610,7 @@ static int prepare_crash_memory_elf32_headers(struct kexec_info *info, phdr->p_flags = 0; phdr->p_offset = phdr->p_paddr = notes_addr; phdr->p_vaddr = 0; - phdr->p_filesz = phdr->p_memsz = MAX_NOTE_BYTES; + phdr->p_filesz = phdr->p_memsz = notes_len; /* Do we need any alignment of segments? */ phdr->p_align = 0; diff --git a/kexec/arch/ia64/crashdump-ia64.c b/kexec/arch/ia64/crashdump-ia64.c index 39cd4f1..0d67806 100644 --- a/kexec/arch/ia64/crashdump-ia64.c +++ b/kexec/arch/ia64/crashdump-ia64.c @@ -80,7 +80,8 @@ static void add_loaded_segments_info(struct kexec_info *info, } } -static int get_crash_notes_section_addr(unsigned long *addr, int cpu) +static int get_crash_notes_section_addr(int cpu, unsigned long *addr, + unsigned long *len) { char crash_notes[128]; char line[MAX_LINE]; @@ -97,6 +98,9 @@ static int get_crash_notes_section_addr(unsigned long *addr, int cpu) *addr = 0; return -1; } + + *len = MAX_NOTE_BYTES; + return 0; } @@ -157,7 +161,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, int i; long int nr_cpus = 0; char *bufp = buf; - unsigned long notes_addr, notes_offset; + unsigned long notes_addr, notes_offset, notes_len; /* Setup ELF Header*/ elf = (Elf64_Ehdr *) bufp; @@ -188,11 +192,9 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, return -1; } - /* Need to find a better way to determine per cpu notes section size. */ -#define MAX_NOTE_BYTES 1024 - for (i = 0; i < nr_cpus; i++) { - if (get_crash_notes_section_addr (¬es_addr, i) < 0) + if (get_crash_notes_section_addr (i, ¬es_addr, + ¬es_len) < 0) break; notes_offset = notes_addr; phdr = (Elf64_Phdr *) bufp; @@ -201,7 +203,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, phdr->p_flags = 0; phdr->p_offset = notes_offset; phdr->p_vaddr = phdr->p_paddr = notes_offset; - phdr->p_filesz = phdr->p_memsz = MAX_NOTE_BYTES; + phdr->p_filesz = phdr->p_memsz = notes_len; /* Do we need any alignment of segments? */ phdr->p_align = 0; diff --git a/kexec/arch/ppc64/crashdump-ppc64.c b/kexec/arch/ppc64/crashdump-ppc64.c index 4f7e0a2..59acb1c 100644 --- a/kexec/arch/ppc64/crashdump-ppc64.c +++ b/kexec/arch/ppc64/crashdump-ppc64.c @@ -269,7 +269,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, int i; char *bufp; long int nr_cpus = 0; - unsigned long notes_addr; + unsigned long notes_addr, notes_len; bufp = (char*) buf; @@ -301,10 +301,8 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, if (nr_cpus < 0) return -1; - /* Need to find a better way to determine per cpu notes section size. */ -#define MAX_NOTE_BYTES 1024 for (i = 0; i < nr_cpus; i++) { - if (get_crash_notes_per_cpu(i, ¬es_addr) < 0) { + if (get_crash_notes_per_cpu(i, ¬es_addr, ¬es_len) < 0) { /* This cpu is not present. Skip it. */ continue; } @@ -314,7 +312,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, phdr->p_flags = 0; phdr->p_offset = phdr->p_paddr = notes_addr; phdr->p_vaddr = 0; - phdr->p_filesz = phdr->p_memsz = MAX_NOTE_BYTES; + phdr->p_filesz = phdr->p_memsz = notes_len; /* Do we need any alignment of segments? */ phdr->p_align = 0; diff --git a/kexec/arch/x86_64/crashdump-x86_64.c b/kexec/arch/x86_64/crashdump-x86_64.c index ae5d5d0..5c8d66c 100644 --- a/kexec/arch/x86_64/crashdump-x86_64.c +++ b/kexec/arch/x86_64/crashdump-x86_64.c @@ -583,7 +583,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, int i; char *bufp; long int nr_cpus = 0; - uint64_t notes_addr; + uint64_t notes_addr, notes_len; bufp = (char*) buf; @@ -616,10 +616,8 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, return -1; } - /* Need to find a better way to determine per cpu notes section size. */ -#define MAX_NOTE_BYTES 1024 for (i = 0; i < nr_cpus; i++) { - if (get_crash_notes_per_cpu(i, ¬es_addr) < 0) { + if (get_crash_notes_per_cpu(i, ¬es_addr, ¬es_len) < 0) { /* This cpu is not present. Skip it. */ continue; } @@ -630,7 +628,7 @@ static int prepare_crash_memory_elf64_headers(struct kexec_info *info, phdr->p_flags = 0; phdr->p_offset = phdr->p_paddr = notes_addr; phdr->p_vaddr = 0; - phdr->p_filesz = phdr->p_memsz = MAX_NOTE_BYTES; + phdr->p_filesz = phdr->p_memsz = notes_len; /* Do we need any alignment of segments? */ phdr->p_align = 0; diff --git a/kexec/crashdump.c b/kexec/crashdump.c index e987b16..0c10cf8 100644 --- a/kexec/crashdump.c +++ b/kexec/crashdump.c @@ -26,9 +26,10 @@ #include <sys/stat.h> #include <unistd.h> #include "kexec.h" +#include "crashdump.h" /* Returns the physical address of start of crash notes buffer for a cpu. */ -int get_crash_notes_per_cpu(int cpu, uint64_t *addr) +int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len) { char crash_notes[PATH_MAX]; char line[MAX_LINE]; @@ -40,6 +41,7 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr) int stat_errno; *addr = 0; + *len = 0; sprintf(crash_notes, "/sys/devices/system/cpu/cpu%d/crash_notes", cpu); fp = fopen(crash_notes, "r"); @@ -68,6 +70,7 @@ int get_crash_notes_per_cpu(int cpu, uint64_t *addr) if (count != 1) die("Cannot parse %s: %s\n", crash_notes, strerror(errno)); *addr = (uint64_t) temp; + *len = MAX_NOTE_BYTES; /* we should get this from the kernel instead */ #if 0 printf("crash_notes addr = %Lx\n", *addr); #endif diff --git a/kexec/crashdump.h b/kexec/crashdump.h index bb3649f..dd3c317 100644 --- a/kexec/crashdump.h +++ b/kexec/crashdump.h @@ -1,7 +1,7 @@ #ifndef CRASHDUMP_H #define CRASHDUMP_H -extern int get_crash_notes_per_cpu(int cpu, uint64_t *addr); +extern int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len); /* Need to find a better way to determine per cpu notes section size. */ #define MAX_NOTE_BYTES 1024 |