powerpc: Add macros to access floating point registers in thread_struct.
[safe/jmp/linux-2.6] / arch / powerpc / kernel / ptrace.c
index 2c1ee2c..59ff087 100644 (file)
@@ -218,7 +218,7 @@ static int fpr_get(struct task_struct *target, const struct user_regset *regset,
        flush_fp_to_thread(target);
 
        BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) !=
-                    offsetof(struct thread_struct, fpr[32]));
+                    offsetof(struct thread_struct, TS_FPR(32)));
 
        return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
                                   &target->thread.fpr, 0, -1);
@@ -231,7 +231,7 @@ static int fpr_set(struct task_struct *target, const struct user_regset *regset,
        flush_fp_to_thread(target);
 
        BUILD_BUG_ON(offsetof(struct thread_struct, fpscr) !=
-                    offsetof(struct thread_struct, fpr[32]));
+                    offsetof(struct thread_struct, TS_FPR(32)));
 
        return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
                                  &target->thread.fpr, 0, -1);
@@ -530,15 +530,21 @@ static int gpr32_set(struct task_struct *target,
                --count;
        }
 
-       if (kbuf)
+       if (kbuf) {
                for (; count > 0 && pos <= PT_MAX_PUT_REG; --count)
                        regs[pos++] = *k++;
-       else
+               for (; count > 0 && pos < PT_TRAP; --count, ++pos)
+                       ++k;
+       } else {
                for (; count > 0 && pos <= PT_MAX_PUT_REG; --count) {
                        if (__get_user(reg, u++))
                                return -EFAULT;
                        regs[pos++] = reg;
                }
+               for (; count > 0 && pos < PT_TRAP; --count, ++pos)
+                       if (__get_user(reg, u++))
+                               return -EFAULT;
+       }
 
        if (count > 0 && pos == PT_TRAP) {
                if (kbuf)
@@ -581,7 +587,7 @@ static const struct user_regset compat_regsets[] = {
 #endif
 #ifdef CONFIG_SPE
        [REGSET_SPE] = {
-               .n = 35,
+               .core_note_type = NT_PPC_SPE, .n = 35,
                .size = sizeof(u32), .align = sizeof(u32),
                .active = evr_active, .get = evr_get, .set = evr_set
        },
@@ -701,12 +707,6 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
        int ret = -EPERM;
 
        switch (request) {
-       /* when I and D space are separate, these will need to be fixed. */
-       case PTRACE_PEEKTEXT: /* read word at location addr. */
-       case PTRACE_PEEKDATA:
-               ret = generic_ptrace_peekdata(child, addr, data);
-               break;
-
        /* read the word at location addr in the USER area. */
        case PTRACE_PEEKUSR: {
                unsigned long index, tmp;
@@ -728,18 +728,13 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                        tmp = ptrace_get_reg(child, (int) index);
                } else {
                        flush_fp_to_thread(child);
-                       tmp = ((unsigned long *)child->thread.fpr)[index - PT_FPR0];
+                       tmp = ((unsigned long *)child->thread.fpr)
+                               [TS_FPRWIDTH * (index - PT_FPR0)];
                }
                ret = put_user(tmp,(unsigned long __user *) data);
                break;
        }
 
-       /* If I and D space are separate, this will have to be fixed. */
-       case PTRACE_POKETEXT: /* write the word at location addr. */
-       case PTRACE_POKEDATA:
-               ret = generic_ptrace_pokedata(child, addr, data);
-               break;
-
        /* write the word at location addr in the USER area */
        case PTRACE_POKEUSR: {
                unsigned long index;
@@ -761,7 +756,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
                        ret = ptrace_put_reg(child, index, data);
                } else {
                        flush_fp_to_thread(child);
-                       ((unsigned long *)child->thread.fpr)[index - PT_FPR0] = data;
+                       ((unsigned long *)child->thread.fpr)
+                               [TS_FPRWIDTH * (index - PT_FPR0)] = data;
                        ret = 0;
                }
                break;