Commit a9384e23 authored by Namhyung Kim's avatar Namhyung Kim Committed by Linus Torvalds

ptrace: cleanup arch_ptrace() on sparc

Factor out struct fps and remove redundant castings.
Signed-off-by: default avatarNamhyung Kim <namhyung@gmail.com>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 9e1cb206
...@@ -323,19 +323,35 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task) ...@@ -323,19 +323,35 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
return &user_sparc32_view; return &user_sparc32_view;
} }
struct fps {
unsigned long regs[32];
unsigned long fsr;
unsigned long flags;
unsigned long extra;
unsigned long fpqd;
struct fq {
unsigned long *insnaddr;
unsigned long insn;
} fpq[16];
};
long arch_ptrace(struct task_struct *child, long request, long arch_ptrace(struct task_struct *child, long request,
unsigned long addr, unsigned long data) unsigned long addr, unsigned long data)
{ {
unsigned long addr2 = current->thread.kregs->u_regs[UREG_I4]; unsigned long addr2 = current->thread.kregs->u_regs[UREG_I4];
void __user *addr2p;
const struct user_regset_view *view; const struct user_regset_view *view;
struct pt_regs __user *pregs;
struct fps __user *fps;
int ret; int ret;
view = task_user_regset_view(current); view = task_user_regset_view(current);
addr2p = (void __user *) addr2;
pregs = (struct pt_regs __user *) addr;
fps = (struct fps __user *) addr;
switch(request) { switch(request) {
case PTRACE_GETREGS: { case PTRACE_GETREGS: {
struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
ret = copy_regset_to_user(child, view, REGSET_GENERAL, ret = copy_regset_to_user(child, view, REGSET_GENERAL,
32 * sizeof(u32), 32 * sizeof(u32),
4 * sizeof(u32), 4 * sizeof(u32),
...@@ -349,8 +365,6 @@ long arch_ptrace(struct task_struct *child, long request, ...@@ -349,8 +365,6 @@ long arch_ptrace(struct task_struct *child, long request,
} }
case PTRACE_SETREGS: { case PTRACE_SETREGS: {
struct pt_regs __user *pregs = (struct pt_regs __user *) addr;
ret = copy_regset_from_user(child, view, REGSET_GENERAL, ret = copy_regset_from_user(child, view, REGSET_GENERAL,
32 * sizeof(u32), 32 * sizeof(u32),
4 * sizeof(u32), 4 * sizeof(u32),
...@@ -364,19 +378,6 @@ long arch_ptrace(struct task_struct *child, long request, ...@@ -364,19 +378,6 @@ long arch_ptrace(struct task_struct *child, long request,
} }
case PTRACE_GETFPREGS: { case PTRACE_GETFPREGS: {
struct fps {
unsigned long regs[32];
unsigned long fsr;
unsigned long flags;
unsigned long extra;
unsigned long fpqd;
struct fq {
unsigned long *insnaddr;
unsigned long insn;
} fpq[16];
};
struct fps __user *fps = (struct fps __user *) addr;
ret = copy_regset_to_user(child, view, REGSET_FP, ret = copy_regset_to_user(child, view, REGSET_FP,
0 * sizeof(u32), 0 * sizeof(u32),
32 * sizeof(u32), 32 * sizeof(u32),
...@@ -398,19 +399,6 @@ long arch_ptrace(struct task_struct *child, long request, ...@@ -398,19 +399,6 @@ long arch_ptrace(struct task_struct *child, long request,
} }
case PTRACE_SETFPREGS: { case PTRACE_SETFPREGS: {
struct fps {
unsigned long regs[32];
unsigned long fsr;
unsigned long flags;
unsigned long extra;
unsigned long fpqd;
struct fq {
unsigned long *insnaddr;
unsigned long insn;
} fpq[16];
};
struct fps __user *fps = (struct fps __user *) addr;
ret = copy_regset_from_user(child, view, REGSET_FP, ret = copy_regset_from_user(child, view, REGSET_FP,
0 * sizeof(u32), 0 * sizeof(u32),
32 * sizeof(u32), 32 * sizeof(u32),
...@@ -425,8 +413,7 @@ long arch_ptrace(struct task_struct *child, long request, ...@@ -425,8 +413,7 @@ long arch_ptrace(struct task_struct *child, long request,
case PTRACE_READTEXT: case PTRACE_READTEXT:
case PTRACE_READDATA: case PTRACE_READDATA:
ret = ptrace_readdata(child, addr, ret = ptrace_readdata(child, addr, addr2p, data);
(void __user *) addr2, data);
if (ret == data) if (ret == data)
ret = 0; ret = 0;
...@@ -436,8 +423,7 @@ long arch_ptrace(struct task_struct *child, long request, ...@@ -436,8 +423,7 @@ long arch_ptrace(struct task_struct *child, long request,
case PTRACE_WRITETEXT: case PTRACE_WRITETEXT:
case PTRACE_WRITEDATA: case PTRACE_WRITEDATA:
ret = ptrace_writedata(child, (void __user *) addr2, ret = ptrace_writedata(child, addr2p, addr, data);
addr, data);
if (ret == data) if (ret == data)
ret = 0; ret = 0;
......
...@@ -976,10 +976,12 @@ long arch_ptrace(struct task_struct *child, long request, ...@@ -976,10 +976,12 @@ long arch_ptrace(struct task_struct *child, long request,
unsigned long addr2 = task_pt_regs(current)->u_regs[UREG_I4]; unsigned long addr2 = task_pt_regs(current)->u_regs[UREG_I4];
struct pt_regs __user *pregs; struct pt_regs __user *pregs;
struct fps __user *fps; struct fps __user *fps;
void __user *addr2p;
int ret; int ret;
pregs = (struct pt_regs __user *) addr; pregs = (struct pt_regs __user *) addr;
fps = (struct fps __user *) addr; fps = (struct fps __user *) addr;
addr2p = (void __user *) addr2;
switch (request) { switch (request) {
case PTRACE_PEEKUSR: case PTRACE_PEEKUSR:
...@@ -1030,8 +1032,7 @@ long arch_ptrace(struct task_struct *child, long request, ...@@ -1030,8 +1032,7 @@ long arch_ptrace(struct task_struct *child, long request,
case PTRACE_READTEXT: case PTRACE_READTEXT:
case PTRACE_READDATA: case PTRACE_READDATA:
ret = ptrace_readdata(child, addr, ret = ptrace_readdata(child, addr, addr2p, data);
(char __user *)addr2, data);
if (ret == data) if (ret == data)
ret = 0; ret = 0;
else if (ret >= 0) else if (ret >= 0)
...@@ -1040,8 +1041,7 @@ long arch_ptrace(struct task_struct *child, long request, ...@@ -1040,8 +1041,7 @@ long arch_ptrace(struct task_struct *child, long request,
case PTRACE_WRITETEXT: case PTRACE_WRITETEXT:
case PTRACE_WRITEDATA: case PTRACE_WRITEDATA:
ret = ptrace_writedata(child, (char __user *) addr2, ret = ptrace_writedata(child, addr2p, addr, data);
addr, data);
if (ret == data) if (ret == data)
ret = 0; ret = 0;
else if (ret >= 0) else if (ret >= 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment