Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: minyard@acm.org
To: Ralf Baechle <ralf@linux-mips.org>, Alex Smith <alex@alex-smith.me.uk>
Cc: linux-mips@linux-mips.org,
	David Daney <ddaney@caviumnetworks.com>,
	Corey Minyard <cminyard@mvista.com>
Subject: [PATCH] Partially revert "MIPS: Remove old core dump functions"
Date: Tue, 20 Jun 2017 15:39:25 -0500	[thread overview]
Message-ID: <1497991165-31361-1-git-send-email-minyard@acm.org> (raw)

From: Corey Minyard <cminyard@mvista.com>

This reverts part of commit 30852ad0039b4a54b5062efd66877125e519dc30,
which removed some ELF coredump functions from MIPS.  They are no
longer needed for normal coredumps, but they are still needed for
kdump.  The kernel crashes when doing a kdump shutdown because
elf_core_copy_kernel_regs() needs a MIPS-specific version and the
reverted commit removes it.

This change adds back in ELF_CORE_COPY_REGS() and the required
support for it.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
---
 arch/mips/include/asm/elf.h |  7 +++++++
 arch/mips/kernel/process.c  | 22 ++++++++++++++++++++++
 2 files changed, 29 insertions(+)

diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index 2b3dc29..600db7b 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -414,6 +414,13 @@ do {									\
 
 #endif /* CONFIG_64BIT */
 
+struct pt_regs;
+
+extern void elf_dump_regs(elf_greg_t *, struct pt_regs *regs);
+
+#define ELF_CORE_COPY_REGS(elf_regs, regs)                     \
+       elf_dump_regs((elf_greg_t *)&(elf_regs), regs);
+
 #define CORE_DUMP_USE_REGSET
 #define ELF_EXEC_PAGESIZE	PAGE_SIZE
 
diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
index fbbf5fc..0d63aa1 100644
--- a/arch/mips/kernel/process.c
+++ b/arch/mips/kernel/process.c
@@ -180,6 +180,28 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
 	return 0;
 }
 
+void elf_dump_regs(elf_greg_t *gp, struct pt_regs *regs)
+{
+	int i;
+
+	for (i = 0; i < EF_R0; i++)
+		gp[i] = 0;
+	gp[EF_R0] = 0;
+	for (i = 1; i <= 31; i++)
+		gp[EF_R0 + i] = regs->regs[i];
+	gp[EF_R26] = 0;
+	gp[EF_R27] = 0;
+	gp[EF_LO] = regs->lo;
+	gp[EF_HI] = regs->hi;
+	gp[EF_CP0_EPC] = regs->cp0_epc;
+	gp[EF_CP0_BADVADDR] = regs->cp0_badvaddr;
+	gp[EF_CP0_STATUS] = regs->cp0_status;
+	gp[EF_CP0_CAUSE] = regs->cp0_cause;
+#ifdef EF_UNUSED0
+	gp[EF_UNUSED0] = 0;
+#endif
+}
+
 #ifdef CONFIG_CC_STACKPROTECTOR
 #include <linux/stackprotector.h>
 unsigned long __stack_chk_guard __read_mostly;
-- 
2.7.4

             reply	other threads:[~2017-06-20 20:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20 20:39 minyard [this message]
2017-06-21  6:52 ` [PATCH] Partially revert "MIPS: Remove old core dump functions" Marcin Nowakowski
2017-06-21  6:52   ` Marcin Nowakowski

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=1497991165-31361-1-git-send-email-minyard@acm.org \
    --to=minyard@acm.org \
    --cc=alex@alex-smith.me.uk \
    --cc=cminyard@mvista.com \
    --cc=ddaney@caviumnetworks.com \
    --cc=linux-mips@linux-mips.org \
    --cc=ralf@linux-mips.org \
    /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