]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/powerpc/kernel/ptrace.c
[POWERPC] Use user_regset accessors for FP regs
[linux-2.6-omap-h63xx.git] / arch / powerpc / kernel / ptrace.c
index cf7732cdd6c7e1ef65df511297dceac941e54ef5..f1ce64649256cc491c7e1852cbbad28773fbb52a 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/smp.h>
 #include <linux/errno.h>
 #include <linux/ptrace.h>
+#include <linux/regset.h>
 #include <linux/user.h>
 #include <linux/security.h>
 #include <linux/signal.h>
@@ -103,24 +104,48 @@ int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data)
 }
 
 
+static int fpr_get(struct task_struct *target, const struct user_regset *regset,
+                  unsigned int pos, unsigned int count,
+                  void *kbuf, void __user *ubuf)
+{
+       flush_fp_to_thread(target);
+
+       BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) !=
+                    offsetof(struct thread_struct, fpr[32]));
+
+       return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
+                                  &target->thread.fpr, 0, -1);
+}
+
+static int fpr_set(struct task_struct *target, const struct user_regset *regset,
+                  unsigned int pos, unsigned int count,
+                  const void *kbuf, const void __user *ubuf)
+{
+       flush_fp_to_thread(target);
+
+       BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) !=
+                    offsetof(struct thread_struct, fpr[32]));
+
+       return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
+                                 &target->thread.fpr, 0, -1);
+}
+
 static int get_fpregs(void __user *data, struct task_struct *task,
                      int has_fpscr)
 {
        unsigned int count = has_fpscr ? 33 : 32;
-
-       if (copy_to_user(data, task->thread.fpr, count * sizeof(double)))
+       if (!access_ok(VERIFY_WRITE, data, count * sizeof(double)))
                return -EFAULT;
-       return 0;
+       return fpr_get(task, NULL, 0, count * sizeof(double), NULL, data);
 }
 
 static int set_fpregs(void __user *data, struct task_struct *task,
                      int has_fpscr)
 {
        unsigned int count = has_fpscr ? 33 : 32;
-
-       if (copy_from_user(task->thread.fpr, data, count * sizeof(double)))
+       if (!access_ok(VERIFY_READ, data, count * sizeof(double)))
                return -EFAULT;
-       return 0;
+       return fpr_set(task, NULL, 0, count * sizeof(double), NULL, data);
 }
 
 
@@ -256,7 +281,7 @@ static int set_evrregs(struct task_struct *task, unsigned long *data)
 #endif /* CONFIG_SPE */
 
 
-static void set_single_step(struct task_struct *task)
+void user_enable_single_step(struct task_struct *task)
 {
        struct pt_regs *regs = task->thread.regs;
 
@@ -271,7 +296,7 @@ static void set_single_step(struct task_struct *task)
        set_tsk_thread_flag(task, TIF_SINGLESTEP);
 }
 
-static void clear_single_step(struct task_struct *task)
+void user_disable_single_step(struct task_struct *task)
 {
        struct pt_regs *regs = task->thread.regs;
 
@@ -313,7 +338,7 @@ static int ptrace_set_debugreg(struct task_struct *task, unsigned long addr,
 void ptrace_disable(struct task_struct *child)
 {
        /* make sure the single step bit is not set. */
-       clear_single_step(child);
+       user_disable_single_step(child);
 }
 
 /*
@@ -445,52 +470,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                break;
        }
 
-       case PTRACE_SYSCALL: /* continue and stop at next (return from) syscall */
-       case PTRACE_CONT: { /* restart after signal. */
-               ret = -EIO;
-               if (!valid_signal(data))
-                       break;
-               if (request == PTRACE_SYSCALL)
-                       set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
-               else
-                       clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
-               child->exit_code = data;
-               /* make sure the single step bit is not set. */
-               clear_single_step(child);
-               wake_up_process(child);
-               ret = 0;
-               break;
-       }
-
-/*
- * make the child exit.  Best I can do is send it a sigkill.
- * perhaps it should be put in the status that it wants to
- * exit.
- */
-       case PTRACE_KILL: {
-               ret = 0;
-               if (child->exit_state == EXIT_ZOMBIE)   /* already dead */
-                       break;
-               child->exit_code = SIGKILL;
-               /* make sure the single step bit is not set. */
-               clear_single_step(child);
-               wake_up_process(child);
-               break;
-       }
-
-       case PTRACE_SINGLESTEP: {  /* set the trap flag. */
-               ret = -EIO;
-               if (!valid_signal(data))
-                       break;
-               clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
-               set_single_step(child);
-               child->exit_code = data;
-               /* give it a chance to run. */
-               wake_up_process(child);
-               ret = 0;
-               break;
-       }
-
        case PTRACE_GET_DEBUGREG: {
                ret = -EINVAL;
                /* We only support one DABR and no IABRS at the moment */
@@ -505,10 +484,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                ret = ptrace_set_debugreg(child, addr, data);
                break;
 
-       case PTRACE_DETACH:
-               ret = ptrace_detach(child, data);
-               break;
-
 #ifdef CONFIG_PPC64
        case PTRACE_GETREGS64:
 #endif