Gitweb:     
http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=f65255e8d51ecbc6c9eef20d39e0377d19b658ca
Commit:     f65255e8d51ecbc6c9eef20d39e0377d19b658ca
Parent:     5ab3e84f66321579ca36b63a13bf78decba65121
Author:     Roland McGrath <[EMAIL PROTECTED]>
AuthorDate: Thu Dec 20 03:57:34 2007 -0800
Committer:  Paul Mackerras <[EMAIL PROTECTED]>
CommitDate: Thu Feb 7 20:38:56 2008 +1100

    [POWERPC] Use user_regset accessors for FP regs
    
    This implements user_regset-style accessors for the powerpc FPU data,
    and rewrites the existing ptrace code in terms of those calls.
    
    Signed-off-by: Roland McGrath <[EMAIL PROTECTED]>
    Signed-off-by: Paul Mackerras <[EMAIL PROTECTED]>
---
 arch/powerpc/kernel/ptrace.c |   37 +++++++++++++++++++++++++++++++------
 1 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
index 8b056d2..f1ce646 100644
--- a/arch/powerpc/kernel/ptrace.c
+++ b/arch/powerpc/kernel/ptrace.c
@@ -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);
 }
 
 
-
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to