public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Greg Weeks <greg.weeks@timesys.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH} PPC 32 multithreaded core dumps
Date: Wed, 25 Feb 2004 15:25:56 -0500	[thread overview]
Message-ID: <403D04D4.3020502@timesys.com> (raw)

This code fixes the register dumps for 32 bit ppc multi threaded core 
dumps. It's largely based on the ppc64 code. It was tested on an 8260 
processor with the TimeSys modified 2.6.1 kernel. The patch is for 
2.6.3. Let me know if there are any problems with it. If anyone can tell 
me why arch/ppc/boot/simple/misc.c was including elf.h in the first 
place I'd appreciate it. It doesn't appear to need it and it doesn't 
like task_struct now.

Greg Weeks



diff -uprN linux-2.6.3.orig/arch/ppc/boot/simple/misc.c 
linux-2.6.3.change/arch/ppc/boot/simple/misc.c
--- linux-2.6.3.orig/arch/ppc/boot/simple/misc.c    2004-02-17 
22:59:11.000000000 -0500
+++ linux-2.6.3.change/arch/ppc/boot/simple/misc.c    2004-02-25 
14:10:30.000000000 -0500
@@ -17,7 +17,6 @@
  */
 
 #include <linux/types.h>
-#include <linux/elf.h>
 #include <linux/config.h>
 #include <linux/string.h>
 
diff -uprN linux-2.6.3.orig/arch/ppc/kernel/process.c 
linux-2.6.3.change/arch/ppc/kernel/process.c
--- linux-2.6.3.orig/arch/ppc/kernel/process.c    2004-02-17 
22:57:53.000000000 -0500
+++ linux-2.6.3.change/arch/ppc/kernel/process.c    2004-02-25 
14:12:13.000000000 -0500
@@ -45,7 +45,6 @@
 #include <asm/prom.h>
 #include <asm/hardirq.h>
 
-int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs);
 extern unsigned long _get_SP(void);
 
 struct task_struct *last_task_used_math = NULL;
@@ -188,12 +187,17 @@ enable_kernel_fp(void)
 #endif /* CONFIG_SMP */
 }
 
-int
-dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpregs)
+int dump_task_fpu(struct task_struct *tsk, elf_fpregset_t *fpregs)
 {
-    if (regs->msr & MSR_FP)
+    struct pt_regs *regs = tsk->thread.regs;
+
+    if (!regs)
+        return 0;
+    if (tsk == current && (regs->msr & MSR_FP))
         giveup_fpu(current);
-    memcpy(fpregs, &current->thread.fpr[0], sizeof(*fpregs));
+
+    memcpy(fpregs, &tsk->thread.fpr[0], sizeof(*fpregs));
+
     return 1;
 }
 
diff -uprN linux-2.6.3.orig/include/asm-ppc/elf.h 
linux-2.6.3.change/include/asm-ppc/elf.h
--- linux-2.6.3.orig/include/asm-ppc/elf.h    2004-02-17 
22:57:11.000000000 -0500
+++ linux-2.6.3.change/include/asm-ppc/elf.h    2004-02-25 
14:14:21.000000000 -0500
@@ -90,11 +90,33 @@ typedef elf_vrreg_t elf_vrregset_t[ELF_N
 #define USE_ELF_CORE_DUMP
 #define ELF_EXEC_PAGESIZE    4096
 
-#define ELF_CORE_COPY_REGS(gregs, regs) \
-    memcpy(gregs, regs, \
-           sizeof(struct pt_regs) < sizeof(elf_gregset_t)? \
-           sizeof(struct pt_regs): sizeof(elf_gregset_t));
+static inline void ppc_elf_core_copy_regs(elf_gregset_t elf_regs,
+                        struct pt_regs *regs)
+{
+    int i;
+    int gprs = sizeof(struct pt_regs)/sizeof(elf_greg_t);
+
+    if (gprs > ELF_NGREG)
+        gprs = ELF_NGREG;
+
+    for (i=0; i < gprs; i++)
+        elf_regs[i] = (elf_greg_t)((elf_greg_t *)regs)[i];
+}
+#define ELF_CORE_COPY_REGS(gregs, regs) ppc_elf_core_copy_regs(gregs, 
regs);
+
+static inline int dump_task_regs(struct task_struct *tsk,
+                 elf_gregset_t *elf_regs)
+{
+    struct pt_regs *regs = tsk->thread.regs;
+    if (regs)
+        ppc_elf_core_copy_regs(*elf_regs, regs);
+
+    return 1;
+}
+#define ELF_CORE_COPY_TASK_REGS(tsk, elf_regs) dump_task_regs(tsk, 
elf_regs)
 
+extern int dump_task_fpu(struct task_struct *, elf_fpregset_t *);
+#define ELF_CORE_COPY_FPREGS(tsk, elf_fpregs) dump_task_fpu(tsk, 
elf_fpregs)
 
 /* This yields a mask that user programs can use to figure out what
    instruction set this cpu supports.  This could be done in userspace,


             reply	other threads:[~2004-02-25 20:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-02-25 20:25 Greg Weeks [this message]
2004-02-25 21:13 ` [PATCH} PPC 32 multithreaded core dumps Tom Rini
2004-03-04 13:05   ` Greg Weeks
2004-03-04 15:31     ` Tom Rini

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=403D04D4.3020502@timesys.com \
    --to=greg.weeks@timesys.com \
    --cc=linux-kernel@vger.kernel.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