mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "K.Prasad" <prasad@linux.vnet.ibm.com>
To: linux-kernel@vger.kernel.org, crash-utility@redhat.com,
	kexec@lists.infradead.org
Cc: Vivek Goyal <vgoyal@redhat.com>, Andi Kleen <andi@firstfloor.org>,
	"Luck, Tony" <tony.luck@intel.com>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	anderson@redhat.com, tachibana@mxm.nes.nec.co.jp,
	oomichi@mxs.nes.nec.co.jp
Subject: [Patch 2/4][kexec-tools] Recognise NT_NOCOREDUMP elf-note type
Date: Mon, 3 Oct 2011 13:05:27 +0530	[thread overview]
Message-ID: <20111003073527.GB22694@in.ibm.com> (raw)
In-Reply-To: <20111003070735.GJ2223@in.ibm.com>

The kernel vmcore may contain a new elf-note of type NT_NOCOREDUMP. Include this
new note, whose address and length are made available at
/sys/kernel/nt_nocoredump, while loading elf-headers.

Signed-off-by: K.Prasad <prasad@linux.vnet.ibm.com>
---

diff --git a/kexec/crashdump-elf.c b/kexec/crashdump-elf.c
index 8d82db9..b009227 100644
--- a/kexec/crashdump-elf.c
+++ b/kexec/crashdump-elf.c
@@ -39,7 +39,9 @@ int FUNC(struct kexec_info *info,
 	long int nr_cpus = 0;
 	uint64_t notes_addr, notes_len;
 	uint64_t vmcoreinfo_addr, vmcoreinfo_len;
+	uint64_t nt_nocoredump_addr, nt_nocoredump_len;
 	int has_vmcoreinfo = 0;
+	int has_nt_nocoredump = 0;
 	uint64_t vmcoreinfo_addr_xen, vmcoreinfo_len_xen;
 	int has_vmcoreinfo_xen = 0;
 	int (*get_note_info)(int cpu, uint64_t *addr, uint64_t *len);
@@ -57,6 +59,9 @@ int FUNC(struct kexec_info *info,
 		has_vmcoreinfo = 1;
 	}
 
+	if (get_kernel_nt_nocoredump(&nt_nocoredump_addr, &nt_nocoredump_len) == 0)
+		has_nt_nocoredump = 1;
+
 	if (xen_present() &&
 	    get_xen_vmcoreinfo(&vmcoreinfo_addr_xen, &vmcoreinfo_len_xen) == 0) {
 		has_vmcoreinfo_xen = 1;
@@ -179,6 +184,21 @@ int FUNC(struct kexec_info *info,
 		dbgprintf_phdr("vmcoreinfo header", phdr);
 	}
 
+	if (has_nt_nocoredump && !(info->kexec_flags & KEXEC_PRESERVE_CONTEXT)) {
+		phdr = (PHDR *) bufp;
+		bufp += sizeof(PHDR);
+		phdr->p_type	= PT_NOTE;
+		phdr->p_flags	= 0;
+		phdr->p_offset  = phdr->p_paddr = nt_nocoredump_addr;
+		phdr->p_vaddr   = 0;
+		phdr->p_filesz	= phdr->p_memsz	= nt_nocoredump_len;
+		/* Do we need any alignment of segments? */
+		phdr->p_align	= 0;
+
+		(elf->e_phnum)++;
+		dbgprintf_phdr("nocoredump note present", phdr);
+	}
+
 	if (has_vmcoreinfo_xen) {
 		phdr = (PHDR *) bufp;
 		bufp += sizeof(PHDR);
diff --git a/kexec/crashdump.c b/kexec/crashdump.c
index 945b052..0ee05f0 100644
--- a/kexec/crashdump.c
+++ b/kexec/crashdump.c
@@ -136,12 +136,43 @@ static int get_vmcoreinfo(const char *kdump_info, uint64_t *addr, uint64_t *len)
 	return 0;
 }
 
+static int get_nt_nocoredump(const char *kdump_info, uint64_t *addr, uint64_t *len)
+{
+	char line[MAX_LINE];
+	int count;
+	FILE *fp;
+	unsigned int temp2;
+	unsigned long long temp;
+
+	*addr = 0;
+	*len = 0;
+
+	if (!(fp = fopen(kdump_info, "r")))
+		return -1;
+	if (!fgets(line, sizeof(line), fp))
+		die("Cannot parse %s: %s\n", kdump_info, strerror(errno));
+	count = sscanf(line, "%Lx %x", &temp, &temp2);
+	if (count != 2)
+		die("Cannot parse %s: %s\n", kdump_info, strerror(errno));
+
+	*addr = (uint64_t) temp;
+	*len = (uint64_t) temp2;
+
+	fclose(fp);
+	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)
 {
 	return get_vmcoreinfo("/sys/kernel/vmcoreinfo", addr, len);
 }
 
+/* Returns the physical address of start of nocoredump buffer for a kernel. */
+int get_kernel_nt_nocoredump(uint64_t *addr, uint64_t *len)
+{
+	return get_nt_nocoredump("/sys/kernel/nt_nocoredump", addr, len);
+}
+
 int get_xen_vmcoreinfo(uint64_t *addr, uint64_t *len)
 {
 	return get_vmcoreinfo("/sys/hypervisor/vmcoreinfo", addr, len);
-- 
1.7.4.1


  parent reply	other threads:[~2011-10-03  7:36 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-03  7:07 [Patch 0/4] Slimdump framework using NT_NOCOREDUMP elf-note K.Prasad
2011-10-03  7:32 ` [Patch 1/4][kernel][slimdump] Add new elf-note of type NT_NOCOREDUMP to capture slimdump K.Prasad
2011-10-03 10:10   ` Eric W. Biederman
2011-10-03 12:03     ` K.Prasad
2011-10-04  6:34       ` Borislav Petkov
2011-10-05  7:07         ` K.Prasad
2011-10-05  7:31           ` Borislav Petkov
2011-10-05  9:47             ` K.Prasad
2011-10-05 12:41               ` Borislav Petkov
2011-10-05 15:52               ` Vivek Goyal
2011-10-05 16:00                 ` Valdis.Kletnieks
2011-10-05 16:16                   ` Borislav Petkov
2011-10-05 17:20                     ` Vivek Goyal
2011-10-05 17:13                   ` Vivek Goyal
2011-10-05 11:55             ` Valdis.Kletnieks
2011-10-05 12:31               ` Borislav Petkov
2011-10-05 15:19           ` Vivek Goyal
2011-10-05 15:30           ` Vivek Goyal
2011-10-03 22:53     ` Luck, Tony
2011-10-04 14:04   ` Vivek Goyal
2011-10-05  7:18     ` K.Prasad
2011-10-05  7:33       ` Borislav Petkov
2011-10-05  9:23         ` K.Prasad
2011-10-05 15:25       ` Vivek Goyal
2011-10-07 16:12         ` K.Prasad
2011-10-10  7:07           ` Borislav Petkov
2011-10-11 18:44             ` K.Prasad
2011-10-11 18:59               ` Luck, Tony
2011-10-12  0:20               ` Andi Kleen
2011-10-12 10:44               ` Borislav Petkov
2011-10-12 15:59                 ` Vivek Goyal
2011-10-12 15:51               ` Vivek Goyal
2011-10-14 11:30                 ` K.Prasad
2011-10-14 14:14                   ` Vivek Goyal
2011-10-18 17:41                     ` K.Prasad
2011-10-04 14:30   ` Vivek Goyal
2011-10-05  7:41     ` K.Prasad
2011-10-05 15:40       ` Vivek Goyal
     [not found]         ` <987664A83D2D224EAE907B061CE93D5301EE62D58D@orsmsx505.amr.corp.intel.com>
2011-10-05 16:25           ` Borislav Petkov
2011-10-05 17:10           ` Vivek Goyal
2011-10-05 17:20             ` Borislav Petkov
2011-10-05 17:29               ` Vivek Goyal
2011-10-05 17:43                 ` Borislav Petkov
2011-10-05 18:00                 ` Dave Anderson
2011-10-05 18:09                   ` Vivek Goyal
2011-10-04 15:04   ` Nick Bowler
2011-10-07 16:36     ` K.Prasad
2011-10-07 18:19       ` Nick Bowler
2011-10-03  7:35 ` K.Prasad [this message]
2011-10-03  7:37 ` [Patch 3/4][makedumpfile] Capture slimdump if elf-note NT_NOCOREDUMP present K.Prasad
2011-10-03  7:45 ` [Patch 4/4][crash] Recognise elf-note of type NT_NOCOREDUMP before vmcore analysis K.Prasad

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=20111003073527.GB22694@in.ibm.com \
    --to=prasad@linux.vnet.ibm.com \
    --cc=anderson@redhat.com \
    --cc=andi@firstfloor.org \
    --cc=crash-utility@redhat.com \
    --cc=ebiederm@xmission.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oomichi@mxs.nes.nec.co.jp \
    --cc=tachibana@mxm.nes.nec.co.jp \
    --cc=tony.luck@intel.com \
    --cc=vgoyal@redhat.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

all inboxes | Powered by JetHome®