Skip to contentSkip to conversation

Partially revert "MIPS: Remove old core dump functions"

PATCH In review [email protected] 2 participants 2 messages Jun 20, 2017 – Jun 21, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Partially revert "MIPS: Remove old core dump functions"

From: Corey Minyard <[email protected]>

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.

---
 arch/mips/include/asm/elf.h |  7 +++++++
 arch/mips/kernel/process.c  | 22 ++++++++++++++++++++++
 2 files changed, 29 insertions(+)
arch/mips/include/asm/elf.h +7 -0
index 2b3dc29..600db7b 100644
@@ -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
 
arch/mips/kernel/process.c +22 -0
index fbbf5fc..0d63aa1 100644
@@ -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;
Signature · 1 line
2.7.4
#1 lore raw

Hi Corey,

Quoted 11 lines · On 20.06.2017 22:39, [email protected] wrote:

From: Corey Minyard <[email protected]>

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.

A similar fix has been merged some time ago already:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=39a3cb27c123df8e8461291cc9e86f1ac3f0ea06

Marcin

Quoted 58 lines
---
  arch/mips/include/asm/elf.h |  7 +++++++
  arch/mips/kernel/process.c  | 22 ++++++++++++++++++++++
  2 files changed, 29 insertions(+)
arch/mips/include/asm/elf.h +7 -0
index 2b3dc29..600db7b 100644
@@ -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
 
arch/mips/kernel/process.c +22 -0
index fbbf5fc..0d63aa1 100644
@@ -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;