public inbox for kexec@lists.infradead.org
 help / color / mirror / Atom feed
From: Michael Holzheu <holzheu@linux.vnet.ibm.com>
To: Vivek Goyal <vgoyal@redhat.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>,
	kexec@lists.infradead.org, Jan Willeke <willeke@de.ibm.com>,
	linux-kernel@vger.kernel.org,
	HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>,
	Martin Schwidefsky <schwidefsky@de.ibm.com>
Subject: [PATCH v5 2/5] s390/vmcore: Use ELF header in new memory feature
Date: Fri,  7 Jun 2013 18:55:58 +0200	[thread overview]
Message-ID: <1370624161-2298-3-git-send-email-holzheu@linux.vnet.ibm.com> (raw)
In-Reply-To: <1370624161-2298-1-git-send-email-holzheu@linux.vnet.ibm.com>

This patch now exchanges the old relocate mechanism with the new
arch function call override mechanism that allows to create the ELF
core header in the 2nd kernel.

Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com>
---
 arch/s390/kernel/crash_dump.c | 70 ++++++++++++++++++++++++++-----------------
 1 file changed, 43 insertions(+), 27 deletions(-)

diff --git a/arch/s390/kernel/crash_dump.c b/arch/s390/kernel/crash_dump.c
index f703d91..a17f8d4 100644
--- a/arch/s390/kernel/crash_dump.c
+++ b/arch/s390/kernel/crash_dump.c
@@ -22,6 +22,11 @@
 #define PTR_DIFF(x, y) ((unsigned long)(((char *) (x)) - ((unsigned long) (y))))
 
 /*
+ * Pointer to ELF header in new kernel
+ */
+static void *elfcorehdr_newmem;
+
+/*
  * Copy one page from "oldmem"
  *
  * For the kdump reserved memory this functions performs a swap operation:
@@ -325,14 +330,6 @@ static int get_mem_chunk_cnt(void)
 }
 
 /*
- * Relocate pointer in order to allow vmcore code access the data
- */
-static inline unsigned long relocate(unsigned long addr)
-{
-	return OLDMEM_BASE + addr;
-}
-
-/*
  * Initialize ELF loads (new kernel)
  */
 static int loads_init(Elf64_Phdr *phdr, u64 loads_offset)
@@ -383,7 +380,7 @@ static void *notes_init(Elf64_Phdr *phdr, void *ptr, u64 notes_offset)
 	ptr = nt_vmcoreinfo(ptr);
 	memset(phdr, 0, sizeof(*phdr));
 	phdr->p_type = PT_NOTE;
-	phdr->p_offset = relocate(notes_offset);
+	phdr->p_offset = notes_offset;
 	phdr->p_filesz = (unsigned long) PTR_SUB(ptr, ptr_start);
 	phdr->p_memsz = phdr->p_filesz;
 	return ptr;
@@ -392,7 +389,7 @@ static void *notes_init(Elf64_Phdr *phdr, void *ptr, u64 notes_offset)
 /*
  * Create ELF core header (new kernel)
  */
-static void s390_elf_corehdr_create(char **elfcorebuf, size_t *elfcorebuf_sz)
+int elfcorehdr_alloc(void)
 {
 	Elf64_Phdr *phdr_notes, *phdr_loads;
 	int mem_chunk_cnt;
@@ -400,6 +397,8 @@ static void s390_elf_corehdr_create(char **elfcorebuf, size_t *elfcorebuf_sz)
 	u32 alloc_size;
 	u64 hdr_off;
 
+	if (!OLDMEM_BASE)
+		return -ENOENT;
 	mem_chunk_cnt = get_mem_chunk_cnt();
 
 	alloc_size = 0x1000 + get_cpu_cnt() * 0x300 +
@@ -417,27 +416,44 @@ static void s390_elf_corehdr_create(char **elfcorebuf, size_t *elfcorebuf_sz)
 	ptr = notes_init(phdr_notes, ptr, ((unsigned long) hdr) + hdr_off);
 	/* Init loads */
 	hdr_off = PTR_DIFF(ptr, hdr);
-	loads_init(phdr_loads, ((unsigned long) hdr) + hdr_off);
-	*elfcorebuf_sz = hdr_off;
-	*elfcorebuf = (void *) relocate((unsigned long) hdr);
-	BUG_ON(*elfcorebuf_sz > alloc_size);
+	loads_init(phdr_loads, hdr_off);
+	elfcorehdr_addr = (unsigned long long) hdr;
+	elfcorehdr_size = (unsigned long long) hdr_off;
+	elfcorehdr_newmem = hdr;
+	BUG_ON(elfcorehdr_size > alloc_size);
+	return 0;
 }
 
 /*
- * Create kdump ELF core header in new kernel, if it has not been passed via
- * the "elfcorehdr" kernel parameter
+ * Free ELF core header (new kernel)
  */
-static int setup_kdump_elfcorehdr(void)
+void elfcorehdr_free(void)
 {
-	size_t elfcorebuf_sz;
-	char *elfcorebuf;
-
-	if (!OLDMEM_BASE || is_kdump_kernel())
-		return -EINVAL;
-	s390_elf_corehdr_create(&elfcorebuf, &elfcorebuf_sz);
-	elfcorehdr_addr = (unsigned long long) elfcorebuf;
-	elfcorehdr_size = elfcorebuf_sz;
-	return 0;
+	if (!elfcorehdr_newmem)
+		return;
+	vfree(elfcorehdr_newmem);
+	elfcorehdr_newmem = NULL;
 }
 
-subsys_initcall(setup_kdump_elfcorehdr);
+/*
+ * Read from ELF header
+ */
+ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos)
+{
+	void *src = (void *)(unsigned long)*ppos;
+
+	if (elfcorehdr_newmem)
+		memcpy(buf, src, count);
+	else
+		copy_from_oldmem(buf, src, count);
+	*ppos += count;
+	return count;
+}
+
+/*
+ * Read from ELF notes data
+ */
+ssize_t elfcorehdr_read_notes(char *buf, size_t count, u64 *ppos)
+{
+	return elfcorehdr_read(buf, count, ppos);
+}
-- 
1.8.1.6


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

  parent reply	other threads:[~2013-06-07 16:56 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-07 16:55 [PATCH v5 0/5] kdump: Allow ELF header creation in new kernel Michael Holzheu
2013-06-07 16:55 ` [PATCH v5 1/5] vmcore: Introduce ELF header in new memory feature Michael Holzheu
2013-06-10 13:35   ` HATAYAMA Daisuke
2013-06-10 13:53     ` Michael Holzheu
2013-06-14 18:54   ` Vivek Goyal
2013-06-21 14:17     ` Michael Holzheu
2013-06-27 19:32       ` Vivek Goyal
2013-06-27 20:10         ` Cliff Wickman
2013-06-27 20:23         ` Vivek Goyal
2013-06-28  8:15           ` Michael Holzheu
2013-07-01 17:37             ` Vivek Goyal
2013-07-01 18:29               ` Michael Holzheu
2013-06-07 16:55 ` Michael Holzheu [this message]
2013-06-10 13:36   ` [PATCH v5 2/5] s390/vmcore: Use " HATAYAMA Daisuke
2013-06-10 13:48     ` Michael Holzheu
2013-06-14 19:16   ` Vivek Goyal
2013-06-07 16:55 ` [PATCH v5 3/5] vmcore: Introduce remap_oldmem_pfn_range() Michael Holzheu
     [not found]   ` <CAJGZr0+_W0dp2f9VtVAiUT2fqiwe91gHXd9zYzfMMzBZSZogww@mail.gmail.com>
2013-06-10  8:00     ` Michael Holzheu
2013-06-10 13:40   ` HATAYAMA Daisuke
2013-06-10 14:03     ` Michael Holzheu
2013-06-10 15:37     ` Michael Holzheu
2013-06-11 12:42       ` HATAYAMA Daisuke
2013-06-12  9:13         ` Michael Holzheu
2013-06-13  1:32           ` HATAYAMA Daisuke
2013-06-13  8:54             ` Michael Holzheu
2013-06-13  4:00           ` HATAYAMA Daisuke
2013-06-11 13:20       ` HATAYAMA Daisuke
2013-06-07 16:56 ` [PATCH v5 4/5] s390/vmcore: Implement remap_oldmem_pfn_range for s390 Michael Holzheu
2013-06-14 20:08   ` Vivek Goyal
2013-06-07 16:56 ` [PATCH v5 5/5] s390/vmcore: Use vmcore for zfcpdump Michael Holzheu
2013-06-11 23:47   ` HATAYAMA Daisuke
2013-06-12  9:14     ` Michael Holzheu
2013-06-14 18:54 ` [PATCH v5 0/5] kdump: Allow ELF header creation in new kernel Vivek Goyal
2013-06-21 13:39   ` Michael Holzheu

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=1370624161-2298-3-git-send-email-holzheu@linux.vnet.ibm.com \
    --to=holzheu@linux.vnet.ibm.com \
    --cc=d.hatayama@jp.fujitsu.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kexec@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwidefsky@de.ibm.com \
    --cc=vgoyal@redhat.com \
    --cc=willeke@de.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