kexec-tools/kexec-tools-1.102pre-vmcore...

95 lines
2.9 KiB
Diff

diff -rpuN backup/kexec-tools-testing-20070330/kexec/crashdump-elf.c kexec-tools/kexec/crashdump-elf.c
--- backup/kexec-tools-testing-20070330/kexec/crashdump-elf.c 2007-03-30 13:34:36.000000000 +0900
+++ kexec-tools/kexec/crashdump-elf.c 2007-08-03 14:45:47.000000000 +0900
@@ -36,6 +36,8 @@
char *bufp;
long int nr_cpus = 0;
uint64_t notes_addr, notes_len;
+ uint64_t vmcoreinfo_addr, vmcoreinfo_len;
+ int has_vmcoreinfo = 0;
int (*get_note_info)(int cpu, uint64_t *addr, uint64_t *len);
if (xen_present())
@@ -47,7 +49,11 @@
return -1;
}
- sz = sizeof(EHDR) + nr_cpus * sizeof(PHDR) + ranges * sizeof(PHDR);
+ if (get_kernel_vmcoreinfo(&vmcoreinfo_addr, &vmcoreinfo_len) == 0) {
+ has_vmcoreinfo = 1;
+ }
+
+ sz = sizeof(EHDR) + (nr_cpus + has_vmcoreinfo) * sizeof(PHDR) + ranges * sizeof(PHDR);
/*
* Certain architectures such as x86_64 and ia64 require a separate
@@ -148,6 +154,21 @@
dfprintf_phdr(stdout, "Elf header", phdr);
}
+ if (has_vmcoreinfo) {
+ phdr = (PHDR *) bufp;
+ bufp += sizeof(PHDR);
+ phdr->p_type = PT_NOTE;
+ phdr->p_flags = 0;
+ phdr->p_offset = phdr->p_paddr = vmcoreinfo_addr;
+ phdr->p_vaddr = 0;
+ phdr->p_filesz = phdr->p_memsz = vmcoreinfo_len;
+ /* Do we need any alignment of segments? */
+ phdr->p_align = 0;
+
+ (elf->e_phnum)++;
+ dfprintf_phdr(stdout, "vmcoreinfo header", phdr);
+ }
+
/* Setup an PT_LOAD type program header for the region where
* Kernel is mapped if info->kern_size is non-zero.
*/
--- backup/kexec-tools-testing-20070330/kexec/crashdump.c 2007-03-30 13:34:36.000000000 +0900
+++ kexec-tools/kexec/crashdump.c 2007-08-03 14:45:05.000000000 +0900
@@ -108,3 +108,32 @@
return 0;
}
+
+/* Returns the physical address of start of crash notes buffer for a kernel. */
+int get_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len)
+{
+ char kdump_info[PATH_MAX];
+ char line[MAX_LINE];
+ int count;
+ FILE *fp;
+ unsigned long long temp, temp2;
+
+ *addr = 0;
+ *len = 0;
+
+ sprintf(kdump_info, "/sys/kernel/vmcoreinfo");
+ fp = fopen(kdump_info, "r");
+ if (!fp)
+ return -1;
+
+ if (!fgets(line, sizeof(line), fp))
+ die("Cannot parse %s: %s\n", kdump_info, strerror(errno));
+ count = sscanf(line, "%Lx %Lx", &temp, &temp2);
+ if (count != 2)
+ die("Cannot parse %s: %s\n", kdump_info, strerror(errno));
+
+ *addr = (uint64_t) temp;
+ *len = (uint64_t) temp2;
+
+ return 0;
+}
diff -rpuN backup/kexec-tools-testing-20070330/kexec/crashdump.h kexec-tools/kexec/crashdump.h
--- backup/kexec-tools-testing-20070330/kexec/crashdump.h 2007-03-30 13:34:36.000000000 +0900
+++ kexec-tools/kexec/crashdump.h 2007-08-03 14:45:05.000000000 +0900
@@ -2,6 +2,7 @@
#define CRASHDUMP_H
extern int get_crash_notes_per_cpu(int cpu, uint64_t *addr, uint64_t *len);
+extern int get_kernel_vmcoreinfo(uint64_t *addr, uint64_t *len);
/* Need to find a better way to determine per cpu notes section size. */
#define MAX_NOTE_BYTES 1024
_