Commit 86854297 authored by Paul Mackerras's avatar Paul Mackerras Committed by Linus Torvalds

[PATCH] Threaded core dumps for PPC32

At the moment, ppc32 kernels will oops if a threaded program tries to
dump core.  We call dump_fpu with a NULL regs pointer, which it tries
to dereference.

This fixes the issue by implementing the hooks used in doing threaded
core dumps properly.
parent dcf474f3
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include <asm/prom.h> #include <asm/prom.h>
#include <asm/hardirq.h> #include <asm/hardirq.h>
int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs);
extern unsigned long _get_SP(void); extern unsigned long _get_SP(void);
struct task_struct *last_task_used_math = NULL; struct task_struct *last_task_used_math = NULL;
...@@ -189,11 +188,11 @@ enable_kernel_fp(void) ...@@ -189,11 +188,11 @@ enable_kernel_fp(void)
} }
int int
dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs) dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs)
{ {
if (regs->msr & MSR_FP) if (tsk->thread.regs && tsk->thread.regs->msr & MSR_FP)
giveup_fpu(current); giveup_fpu(tsk);
memcpy(fpregs, &current->thread.fpr[0], sizeof(*fpregs)); memcpy(fpregs, &tsk->thread.fpr[0], sizeof(*fpregs));
return 1; return 1;
} }
......
...@@ -90,11 +90,17 @@ typedef elf_vrreg_t elf_vrregset_t[ELF_NVRREG]; ...@@ -90,11 +90,17 @@ typedef elf_vrreg_t elf_vrregset_t[ELF_NVRREG];
#define USE_ELF_CORE_DUMP #define USE_ELF_CORE_DUMP
#define ELF_EXEC_PAGESIZE 4096 #define ELF_EXEC_PAGESIZE 4096
#define ELF_CORE_COPY_REGS(gregs, regs) \ #define ELF_CORE_COPY_REGS(gregs, regs) \
memcpy(gregs, regs, \ memcpy((gregs), (regs), sizeof(struct pt_regs)); \
sizeof(struct pt_regs) < sizeof(elf_gregset_t)? \ memset((char *)(gregs) + sizeof(struct pt_regs), 0, \
sizeof(struct pt_regs): sizeof(elf_gregset_t)); sizeof(elf_gregset_t) - sizeof(struct pt_regs));
#define ELF_CORE_COPY_TASK_REGS(t, elfregs) \
((t)->thread.regs? \
({ ELF_CORE_COPY_REGS((elfregs), (t)->thread.regs); 1; }): 0)
extern int dump_task_fpu(struct task_struct *t, elf_fpregset_t *fpu);
#define ELF_CORE_COPY_FPREGS(t, fpu) dump_task_fpu((t), (fpu))
/* This yields a mask that user programs can use to figure out what /* This yields a mask that user programs can use to figure out what
instruction set this cpu supports. This could be done in userspace, instruction set this cpu supports. This could be done in userspace,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment