From: "Ken'ichi Ohmichi" <oomichi@mxs.nes.nec.co.jp>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: lkml <linux-kernel@vger.kernel.org>,
kexec-ml <kexec@lists.infradead.org>,
Neil Horman <nhorman@redhat.com>, Vivek Goyal <vgoyal@in.ibm.com>,
Bernhard Walle <bwalle@suse.de>, Don Zickus <dzickus@redhat.com>,
Dan Aloni <da-x@monatomic.org>
Subject: [PATCH 2/3] [kexec-tools] Pass vmcoreinfo's address and size
Date: Wed, 22 Aug 2007 21:13:39 +0900 [thread overview]
Message-ID: <20070822211339oomichi@mail.jp.nec.com> (raw)
In-Reply-To: <20070822210838oomichi@mail.jp.nec.com>
[2/3] [kexec-tools] 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/)
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.
Thanks
Ken'ichi Ohmichi
---
Signed-off-by: Dan Aloni <da-x@monatomic.org>
Signed-off-by: Ken'ichi Ohmichi <oomichi@mxs.nes.nec.co.jp>
---
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 @@ 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())
@@ -47,7 +49,11 @@ 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
@@ -148,6 +154,21 @@ int FUNC(struct kexec_info *info,
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.
*/
diff -rpuN backup/kexec-tools-testing-20070330/kexec/crashdump.c kexec-tools/kexec/crashdump.c
--- 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,35 @@ int get_crash_notes_per_cpu(int cpu, uin
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) {
+ die("Could not open \"%s\": %s\n", kdump_info,
+ strerror(errno));
+ 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
_
next prev parent reply other threads:[~2007-08-22 12:14 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-22 12:08 [PATCH 0/3] vmcoreinfo support for dump filtering Ken'ichi Ohmichi
2007-08-22 12:11 ` [PATCH 1/3] [linux] Add vmcoreinfo Ken'ichi Ohmichi
2007-08-22 12:13 ` Ken'ichi Ohmichi [this message]
2007-10-17 2:33 ` [PATCH 2/3] [kexec-tools] Pass vmcoreinfo's address and size Simon Horman
2007-10-17 5:16 ` Ken'ichi Ohmichi
2007-10-17 5:27 ` Andrew Morton
2007-10-17 13:37 ` Simon Horman
2007-10-18 5:37 ` Simon Horman
2007-10-18 9:14 ` tachibana
2007-10-19 3:38 ` Simon Horman
2007-08-22 12:16 ` [PATCH 3/3] [makedumpfile] Extract vmcoreinfo from /proc/vmcore Ken'ichi Ohmichi
2007-08-22 22:40 ` [PATCH 0/3] vmcoreinfo support for dump filtering Andrew Morton
2007-08-23 10:20 ` Ken'ichi Ohmichi
2007-08-23 5:47 ` Vivek Goyal
2007-09-03 8:15 ` Ken'ichi Ohmichi
2007-10-17 17:19 ` Tony Luck
2007-10-17 20:20 ` Andrew Morton
2007-10-17 21:32 ` Luck, Tony
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070822211339oomichi@mail.jp.nec.com \
--to=oomichi@mxs.nes.nec.co.jp \
--cc=akpm@linux-foundation.org \
--cc=bwalle@suse.de \
--cc=da-x@monatomic.org \
--cc=dzickus@redhat.com \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nhorman@redhat.com \
--cc=vgoyal@in.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox