summaryrefslogtreecommitdiff
path: root/kexec/crashdump-elf.c
diff options
context:
space:
mode:
authorKen'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>2007-08-22 21:13:39 +0900
committerSimon Horman <horms@verge.net.au>2007-10-18 14:36:03 +0900
commit2e152ffba39a9234dfa984966deba273824e73c1 (patch)
tree270b9e12e03b1c9461595e4764c8694d9045d82f /kexec/crashdump-elf.c
parent6282f6f4e662ca7c8fa9c53d31f1e1057c3d6192 (diff)
Pass vmcoreinfo's address and size
The patch is for kexec-tools-testing-20070330. (http://www.kernel.org/pub/linux/kernel/people/horms/kexec-tools/) The kexec command gets the address and size of the vmcoreinfo data from /sys/kernel/vmcoreinfo, and passes them to the second kernel through ELF header of /proc/vmcore. When the second kernel is booting, the kernel gets them from the ELF header and creates vmcoreinfo's PT_NOTE segment into /proc/vmcore. Signed-off-by: Dan Aloni <da-x@monatomic.org> Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'kexec/crashdump-elf.c')
-rw-r--r--kexec/crashdump-elf.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
index c048f75..b979c1c 100644
--- a/kexec/crashdump-elf.c
+++ b/kexec/crashdump-elf.c
@@ -34,6 +34,8 @@ int FUNC(struct kexec_info *info,
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())
@@ -45,7 +47,12 @@ int FUNC(struct kexec_info *info,
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
@@ -146,6 +153,21 @@ int FUNC(struct kexec_info *info,
dbgprintf_phdr("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)++;
+ dbgprintf_phdr("vmcoreinfo header", phdr);
+ }
+
/* Setup an PT_LOAD type program header for the region where
* Kernel is mapped if info->kern_size is non-zero.
*/