X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fcris%2Farch-v10%2Fkernel%2Fptrace.c;h=da15db8ae482dda7f2ffd2d31dfaaf5ca7421183;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=3c7e0a51a28246ed8d81685ec31e81d04df7f940;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/arch/cris/arch-v10/kernel/ptrace.c b/arch/cris/arch-v10/kernel/ptrace.c index 3c7e0a51a..da15db8ae 100644 --- a/arch/cris/arch-v10/kernel/ptrace.c +++ b/arch/cris/arch-v10/kernel/ptrace.c @@ -23,8 +23,37 @@ */ #define DCCR_MASK 0x0000001f /* XNZVC */ -extern inline long get_reg(struct task_struct *, unsigned int); -extern inline long put_reg(struct task_struct *, unsigned int, unsigned long); +/* + * Get contents of register REGNO in task TASK. + */ +inline long get_reg(struct task_struct *task, unsigned int regno) +{ + /* USP is a special case, it's not in the pt_regs struct but + * in the tasks thread struct + */ + + if (regno == PT_USP) + return task->thread.usp; + else if (regno < PT_MAX) + return ((unsigned long *)user_regs(task->thread_info))[regno]; + else + return 0; +} + +/* + * Write contents of register REGNO in task TASK. + */ +inline int put_reg(struct task_struct *task, unsigned int regno, + unsigned long data) +{ + if (regno == PT_USP) + task->thread.usp = data; + else if (regno < PT_MAX) + ((unsigned long *)user_regs(task->thread_info))[regno] = data; + else + return -1; + return 0; +} /* * Called by kernel/ptrace.c when detaching. @@ -50,6 +79,7 @@ sys_ptrace(long request, long pid, long addr, long data) { struct task_struct *child; int ret; + unsigned long __user *datap = (unsigned long __user *)data; lock_kernel(); ret = -EPERM; @@ -102,7 +132,7 @@ sys_ptrace(long request, long pid, long addr, long data) if (copied != sizeof(tmp)) break; - ret = put_user(tmp,(unsigned long *) data); + ret = put_user(tmp,datap); break; } @@ -115,7 +145,7 @@ sys_ptrace(long request, long pid, long addr, long data) break; tmp = get_reg(child, addr >> 2); - ret = put_user(tmp, (unsigned long *)data); + ret = put_user(tmp, datap); break; } @@ -213,7 +243,7 @@ sys_ptrace(long request, long pid, long addr, long data) for (i = 0; i <= PT_MAX; i++) { tmp = get_reg(child, i); - if (put_user(tmp, (unsigned long *) data)) { + if (put_user(tmp, datap)) { ret = -EFAULT; goto out_tsk; } @@ -231,7 +261,7 @@ sys_ptrace(long request, long pid, long addr, long data) unsigned long tmp; for (i = 0; i <= PT_MAX; i++) { - if (get_user(tmp, (unsigned long *) data)) { + if (get_user(tmp, datap)) { ret = -EFAULT; goto out_tsk; }