]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
sh: Add FPU registers to regset interface.
authorPaul Mundt <lethal@linux-sh.org>
Sun, 21 Sep 2008 10:04:55 +0000 (19:04 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Sun, 21 Sep 2008 10:04:55 +0000 (19:04 +0900)
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
arch/sh/Kconfig
arch/sh/include/asm/elf.h
arch/sh/include/asm/fpu.h
arch/sh/kernel/process_32.c
arch/sh/kernel/ptrace_32.c

index 38a5a9edb677e933cab3ce8fece83302ab62bedc..71be7ff5c771c62cfb7a0118765b3cf148a627dd 100644 (file)
@@ -23,7 +23,7 @@ config SUPERH32
        def_bool !SUPERH64
        select HAVE_KPROBES
        select HAVE_KRETPROBES
-       select HAVE_ARCH_TRACEHOOK if !SH_FPU
+       select HAVE_ARCH_TRACEHOOK
        select HAVE_FTRACE
 
 config SUPERH64
index 6b2cec80fd155763e6986e2aa94268ecc10cb12b..4da3a0b109119f3bc9259595272b3fb296b0e410 100644 (file)
@@ -108,10 +108,10 @@ typedef struct user_fpu_struct elf_fpregset_t;
 #define elf_check_fdpic(x)             ((x)->e_flags & EF_SH_FDPIC)
 #define elf_check_const_displacement(x)        ((x)->e_flags & EF_SH_PIC)
 
-#if defined(CONFIG_SUPERH32) && !defined(CONFIG_SH_FPU)
+#ifdef CONFIG_SUPERH32
 /*
- * Enable dump using regset for general purpose registers, use this as
- * the default once the FPU registers are moved over also.
+ * Enable dump using regset.
+ * This covers all of general/DSP/FPU regs.
  */
 #define CORE_DUMP_USE_REGSET
 #endif
index 91462fea1507c69af30d42a8e2315e8730ced5b0..1d3aee04b5ccc4c3c0181ead9ca3401733a6ece2 100644 (file)
@@ -30,8 +30,15 @@ static inline void save_fpu(struct task_struct *tsk, struct pt_regs *regs)
 }
 #endif
 
+struct user_regset;
+
 extern int do_fpu_inst(unsigned short, struct pt_regs *);
 
+extern int fpregs_get(struct task_struct *target,
+                     const struct user_regset *regset,
+                     unsigned int pos, unsigned int count,
+                     void *kbuf, void __user *ubuf);
+
 static inline void unlazy_fpu(struct task_struct *tsk, struct pt_regs *regs)
 {
        preempt_disable();
@@ -50,6 +57,18 @@ static inline void clear_fpu(struct task_struct *tsk, struct pt_regs *regs)
        preempt_enable();
 }
 
+static inline int init_fpu(struct task_struct *tsk)
+{
+       if (tsk_used_math(tsk)) {
+               if ((boot_cpu_data.flags & CPU_HAS_FPU) && tsk == current)
+                       unlazy_fpu(tsk, task_pt_regs(tsk));
+               return 0;
+       }
+
+       set_stopped_child_used_math(tsk);
+       return 0;
+}
+
 #endif /* __ASSEMBLY__ */
 
 #endif /* __ASM_SH_FPU_H */
index 7b013aa8c43f0f343b6b3daf98404664ccb1842f..b965f0282c7dab650ec30fa1b02d532ed6674be5 100644 (file)
@@ -7,7 +7,11 @@
  *
  *  SuperH version:  Copyright (C) 1999, 2000  Niibe Yutaka & Kaz Kojima
  *                  Copyright (C) 2006 Lineo Solutions Inc. support SH4A UBC
- *                  Copyright (C) 2002 - 2007  Paul Mundt
+ *                  Copyright (C) 2002 - 2008  Paul Mundt
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
  */
 #include <linux/module.h>
 #include <linux/mm.h>
@@ -222,10 +226,10 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu)
        struct task_struct *tsk = current;
 
        fpvalid = !!tsk_used_math(tsk);
-       if (fpvalid) {
-               unlazy_fpu(tsk, regs);
-               memcpy(fpu, &tsk->thread.fpu.hard, sizeof(*fpu));
-       }
+       if (fpvalid)
+               fpvalid = !fpregs_get(tsk, NULL, 0,
+                                     sizeof(struct user_fpu_struct),
+                                     fpu, NULL);
 #endif
 
        return fpvalid;
index 0f44f2b51a60562bcd5468e341d0c7e9d5a567a3..29ca09d24ef855b54c5e6bd431a01fd83e96cd0b 100644 (file)
@@ -32,6 +32,7 @@
 #include <asm/processor.h>
 #include <asm/mmu_context.h>
 #include <asm/syscalls.h>
+#include <asm/fpu.h>
 
 /*
  * This routine will get a word off of the process kernel stack.
@@ -145,6 +146,54 @@ static int genregs_set(struct task_struct *target,
        return ret;
 }
 
+#ifdef CONFIG_SH_FPU
+int fpregs_get(struct task_struct *target,
+              const struct user_regset *regset,
+              unsigned int pos, unsigned int count,
+              void *kbuf, void __user *ubuf)
+{
+       int ret;
+
+       ret = init_fpu(target);
+       if (ret)
+               return ret;
+
+       if ((boot_cpu_data.flags & CPU_HAS_FPU))
+               return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
+                                          &target->thread.fpu.hard, 0, -1);
+
+       return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
+                                  &target->thread.fpu.soft, 0, -1);
+}
+
+static int fpregs_set(struct task_struct *target,
+                      const struct user_regset *regset,
+                      unsigned int pos, unsigned int count,
+                      const void *kbuf, const void __user *ubuf)
+{
+       int ret;
+
+       ret = init_fpu(target);
+       if (ret)
+               return ret;
+
+       set_stopped_child_used_math(target);
+
+       if ((boot_cpu_data.flags & CPU_HAS_FPU))
+               return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
+                                         &target->thread.fpu.hard, 0, -1);
+
+       return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
+                                 &target->thread.fpu.soft, 0, -1);
+}
+
+static int fpregs_active(struct task_struct *target,
+                        const struct user_regset *regset)
+{
+       return tsk_used_math(target) ? regset->n : 0;
+}
+#endif
+
 #ifdef CONFIG_SH_DSP
 static int dspregs_get(struct task_struct *target,
                       const struct user_regset *regset,
@@ -194,6 +243,9 @@ static int dspregs_active(struct task_struct *target,
  */
 enum sh_regset {
        REGSET_GENERAL,
+#ifdef CONFIG_SH_FPU
+       REGSET_FPU,
+#endif
 #ifdef CONFIG_SH_DSP
        REGSET_DSP,
 #endif
@@ -214,6 +266,18 @@ static const struct user_regset sh_regsets[] = {
                .set            = genregs_set,
        },
 
+#ifdef CONFIG_SH_FPU
+       [REGSET_FPU] = {
+               .core_note_type = NT_PRFPREG,
+               .n              = sizeof(struct user_fpu_struct) / sizeof(long),
+               .size           = sizeof(long),
+               .align          = sizeof(long),
+               .get            = fpregs_get,
+               .set            = fpregs_set,
+               .active         = fpregs_active,
+       },
+#endif
+
 #ifdef CONFIG_SH_DSP
        [REGSET_DSP] = {
                .n              = sizeof(struct pt_dspregs) / sizeof(long),
@@ -304,6 +368,18 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                                             REGSET_GENERAL,
                                             0, sizeof(struct pt_regs),
                                             (const void __user *)data);
+#ifdef CONFIG_SH_FPU
+       case PTRACE_GETFPREGS:
+               return copy_regset_to_user(child, &user_sh_native_view,
+                                          REGSET_FPU,
+                                          0, sizeof(struct user_fpu_struct),
+                                          (void __user *)data);
+       case PTRACE_SETFPREGS:
+               return copy_regset_from_user(child, &user_sh_native_view,
+                                            REGSET_FPU,
+                                            0, sizeof(struct user_fpu_struct),
+                                            (const void __user *)data);
+#endif
 #ifdef CONFIG_SH_DSP
        case PTRACE_GETDSPREGS:
                return copy_regset_to_user(child, &user_sh_native_view,