Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Ivan Delalande <colona@arista.com>
To: Atsushi Kumagai <ats-kumagai@wm.jp.nec.com>
Cc: Masaki Tachibana <mas-tachibana@vf.jp.nec.com>,
	Daisuke Nishimura <dai-nishimura@rc.jp.nec.com>,
	Minoru Usui <min-usui@ti.jp.nec.com>,
	kexec-ml <kexec@lists.infradead.org>
Subject: [PATCH v2] makedumpfile: readpage_elf: handle 0-pages not stored in the ELF file
Date: Wed, 27 Jan 2016 23:17:00 +0100	[thread overview]
Message-ID: <20160127221700.GA31203@ycc.fr> (raw)
In-Reply-To: <0910DD04CBD6DE4193FCF86B9C00BE9701E19AFB@BPXM01GP.gisp.nec.co.jp>

Handle pages filled with zero that are not stored in the ELF file
directly, but have addresses between p_filesz and p_memsz of a segment.

This allows makedumpfile to dump-dmesg from a previously makedumpfile-ed
vmcore where all 0-page were excluded (dump_level & 1) for example.

Signed-off-by: Ivan Delalande <colona@arista.com>
---
 elf_info.c     | 22 ++++++++++++++++++++++
 elf_info.h     |  1 +
 makedumpfile.c | 17 +++++++++++++++++
 3 files changed, 40 insertions(+)

diff --git a/elf_info.c b/elf_info.c
index 8bce942..d9d1f42 100644
--- a/elf_info.c
+++ b/elf_info.c
@@ -42,6 +42,7 @@ struct pt_load_segment {
 	unsigned long long	phys_end;
 	unsigned long long	virt_start;
 	unsigned long long	virt_end;
+	size_t			mem_size;
 };
 
 static int			nr_cpus;             /* number of cpu */
@@ -166,6 +167,7 @@ dump_Elf_load(Elf64_Phdr *prog, int num_load)
 	pls->virt_start  = prog->p_vaddr;
 	pls->virt_end    = pls->virt_start + prog->p_filesz;
 	pls->file_offset = prog->p_offset;
+	pls->mem_size    = prog->p_memsz;
 
 	DEBUG_MSG("LOAD (%d)\n", num_load);
 	DEBUG_MSG("  phys_start : %llx\n", pls->phys_start);
@@ -584,6 +586,26 @@ offset_to_pt_load_end(off_t offset)
 }
 
 /*
+ * Return true if a page is in the zone between p_filesz and p_memsz of a
+ * segment, which is a page filled with zero and not stored in the ELF file.
+ */
+int
+paddr_is_null(unsigned long long paddr)
+{
+	int i;
+	struct pt_load_segment *pls;
+
+	for (i = 0; i < num_pt_loads; i++) {
+		pls = &pt_loads[i];
+		if ((paddr >= pls->phys_end)
+		    && (paddr + info->page_size
+			<= pls->phys_start + pls->mem_size))
+			return TRUE;
+	}
+	return FALSE;
+}
+
+/*
  * Judge whether the page is fractional or not.
  */
 int
diff --git a/elf_info.h b/elf_info.h
index e712253..4823311 100644
--- a/elf_info.h
+++ b/elf_info.h
@@ -36,6 +36,7 @@ unsigned long long page_head_to_phys_start(unsigned long long head_paddr);
 unsigned long long page_head_to_phys_end(unsigned long long head_paddr);
 off_t offset_to_pt_load_start(off_t offset);
 off_t offset_to_pt_load_end(off_t offset);
+int paddr_is_null(unsigned long long paddr);
 unsigned long long vaddr_to_paddr_general(unsigned long long vaddr);
 off_t vaddr_to_offset_slow(int fd, char *filename, unsigned long long vaddr);
 unsigned long long get_max_paddr(void);
diff --git a/makedumpfile.c b/makedumpfile.c
index b802446..491f278 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -652,11 +652,20 @@ readpage_elf(unsigned long long paddr, void *bufptr)
 	size_t size1, size2;
 	unsigned long long phys_start, phys_end, frac_head = 0;
 
+	/*
+	 * Check the 0-filled pages that are not in the ELF file.
+	 */
+	if (paddr_is_null(paddr)) {
+		memset(bufptr, 0, info->page_size);
+		return TRUE;
+	}
+
 	offset1 = paddr_to_offset(paddr);
 	offset2 = paddr_to_offset(paddr + info->page_size);
 	phys_start = paddr;
 	phys_end = paddr + info->page_size;
 
+
 	/*
 	 * Check the case phys_start isn't aligned by page size like below:
 	 *
@@ -726,6 +735,14 @@ readpage_elf_parallel(int fd_memory, unsigned long long paddr, void *bufptr)
 	size_t size1, size2;
 	unsigned long long phys_start, phys_end, frac_head = 0;
 
+	/*
+	 * Check the 0-filled pages that are not in the ELF file.
+	 */
+	if (paddr_is_null(paddr)) {
+		memset(bufptr, 0, info->page_size);
+		return TRUE;
+	}
+
 	offset1 = paddr_to_offset(paddr);
 	offset2 = paddr_to_offset(paddr + info->page_size);
 	phys_start = paddr;
-- 
2.7.0


-- 
Ivan "Colona" Delalande
Arista Networks

_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

      parent reply	other threads:[~2016-01-27 22:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-22 23:35 [PATCH] makedumpfile: readpage_elf: handle 0-pages not stored in the ELF file Ivan Delalande
2016-01-27  2:21 ` Atsushi Kumagai
     [not found]   ` <20160127085821.3be424e1@hananiah.suse.cz>
2016-01-27  9:37     ` Petr Tesarik
2016-02-01  6:48       ` Atsushi Kumagai
2016-02-01 12:00         ` Petr Tesarik
2016-02-02  6:48           ` Atsushi Kumagai
2016-02-02  7:00             ` Ivan Delalande
2016-02-09  8:31               ` Petr Tesarik
2016-02-10  2:57                 ` Kexec on ARM? Rudici Cazeao
2016-02-10  3:21                 ` [PATCH] makedumpfile: readpage_elf: handle 0-pages not stored in the ELF file Ivan Delalande
2016-02-10  7:52                   ` Petr Tesarik
2016-02-10 18:06                 ` Kexec on ARM? Rudici Cazeao
2016-01-27 22:17   ` Ivan Delalande [this message]

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=20160127221700.GA31203@ycc.fr \
    --to=colona@arista.com \
    --cc=ats-kumagai@wm.jp.nec.com \
    --cc=dai-nishimura@rc.jp.nec.com \
    --cc=kexec@lists.infradead.org \
    --cc=mas-tachibana@vf.jp.nec.com \
    --cc=min-usui@ti.jp.nec.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