um: clean arch_ptrace() up a bit

1) take subarch-specific stuff to subarch_ptrace()
2) PTRACE_{PEEK,POKE}{TEXT,DATA} is handled by ptrace_request() just fine...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Al Viro 2011-09-14 16:21:37 -07:00 committed by Linus Torvalds
parent 01599cdc2f
commit f2833aef6a
5 changed files with 31 additions and 46 deletions

View File

@ -42,10 +42,6 @@ extern long subarch_ptrace(struct task_struct *child, long request,
unsigned long addr, unsigned long data); unsigned long addr, unsigned long data);
extern unsigned long getreg(struct task_struct *child, int regno); extern unsigned long getreg(struct task_struct *child, int regno);
extern int putreg(struct task_struct *child, int regno, unsigned long value); extern int putreg(struct task_struct *child, int regno, unsigned long value);
extern int get_fpregs(struct user_i387_struct __user *buf,
struct task_struct *child);
extern int set_fpregs(struct user_i387_struct __user *buf,
struct task_struct *child);
extern int arch_copy_tls(struct task_struct *new); extern int arch_copy_tls(struct task_struct *new);
extern void clear_flushed_tls(struct task_struct *task); extern void clear_flushed_tls(struct task_struct *task);

View File

@ -50,23 +50,11 @@ long arch_ptrace(struct task_struct *child, long request,
void __user *vp = p; void __user *vp = p;
switch (request) { switch (request) {
/* read word at location addr. */
case PTRACE_PEEKTEXT:
case PTRACE_PEEKDATA:
ret = generic_ptrace_peekdata(child, addr, data);
break;
/* read the word at location addr in the USER area. */ /* read the word at location addr in the USER area. */
case PTRACE_PEEKUSR: case PTRACE_PEEKUSR:
ret = peek_user(child, addr, data); ret = peek_user(child, addr, data);
break; break;
/* write the word at location addr. */
case PTRACE_POKETEXT:
case PTRACE_POKEDATA:
ret = generic_ptrace_pokedata(child, addr, data);
break;
/* write the word at location addr in the USER area */ /* write the word at location addr in the USER area */
case PTRACE_POKEUSR: case PTRACE_POKEUSR:
ret = poke_user(child, addr, data); ret = poke_user(child, addr, data);
@ -106,16 +94,6 @@ long arch_ptrace(struct task_struct *child, long request,
ret = 0; ret = 0;
break; break;
} }
#endif
#ifdef PTRACE_GETFPREGS
case PTRACE_GETFPREGS: /* Get the child FPU state. */
ret = get_fpregs(vp, child);
break;
#endif
#ifdef PTRACE_SETFPREGS
case PTRACE_SETFPREGS: /* Set the child FPU state. */
ret = set_fpregs(vp, child);
break;
#endif #endif
case PTRACE_GET_THREAD_AREA: case PTRACE_GET_THREAD_AREA:
ret = ptrace_get_thread_area(child, addr, vp); ret = ptrace_get_thread_area(child, addr, vp);
@ -153,12 +131,6 @@ long arch_ptrace(struct task_struct *child, long request,
ret = -EIO; ret = -EIO;
break; break;
} }
#endif
#ifdef PTRACE_ARCH_PRCTL
case PTRACE_ARCH_PRCTL:
/* XXX Calls ptrace on the host - needs some SMP thinking */
ret = arch_prctl(child, data, (void __user *) addr);
break;
#endif #endif
default: default:
ret = ptrace_request(child, request, addr, data); ret = ptrace_request(child, request, addr, data);

View File

@ -42,11 +42,6 @@
*/ */
struct user_desc; struct user_desc;
extern int get_fpxregs(struct user_fxsr_struct __user *buf,
struct task_struct *child);
extern int set_fpxregs(struct user_fxsr_struct __user *buf,
struct task_struct *tsk);
extern int ptrace_get_thread_area(struct task_struct *child, int idx, extern int ptrace_get_thread_area(struct task_struct *child, int idx,
struct user_desc __user *user_desc); struct user_desc __user *user_desc);

View File

@ -145,7 +145,7 @@ int peek_user(struct task_struct *child, long addr, long data)
return put_user(tmp, (unsigned long __user *) data); return put_user(tmp, (unsigned long __user *) data);
} }
int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) static int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
{ {
int err, n, cpu = ((struct thread_info *) child->stack)->cpu; int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
struct user_i387_struct fpregs; struct user_i387_struct fpregs;
@ -161,7 +161,7 @@ int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
return n; return n;
} }
int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) static int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
{ {
int n, cpu = ((struct thread_info *) child->stack)->cpu; int n, cpu = ((struct thread_info *) child->stack)->cpu;
struct user_i387_struct fpregs; struct user_i387_struct fpregs;
@ -174,7 +174,7 @@ int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
(unsigned long *) &fpregs); (unsigned long *) &fpregs);
} }
int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) static int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
{ {
int err, n, cpu = ((struct thread_info *) child->stack)->cpu; int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
struct user_fxsr_struct fpregs; struct user_fxsr_struct fpregs;
@ -190,7 +190,7 @@ int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
return n; return n;
} }
int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) static int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
{ {
int n, cpu = ((struct thread_info *) child->stack)->cpu; int n, cpu = ((struct thread_info *) child->stack)->cpu;
struct user_fxsr_struct fpregs; struct user_fxsr_struct fpregs;
@ -208,15 +208,21 @@ long subarch_ptrace(struct task_struct *child, long request,
{ {
int ret = -EIO; int ret = -EIO;
void __user *datap = (void __user *) data; void __user *datap = (void __user *) data;
switch (request) { switch (request) {
case PTRACE_GETFPREGS: /* Get the child FPU state. */
ret = get_fpregs(datap, child);
break;
case PTRACE_SETFPREGS: /* Set the child FPU state. */
ret = set_fpregs(datap, child);
break;
case PTRACE_GETFPXREGS: /* Get the child FPU state. */ case PTRACE_GETFPXREGS: /* Get the child FPU state. */
ret = get_fpxregs(datap, child); ret = get_fpxregs(datap, child);
break; break;
case PTRACE_SETFPXREGS: /* Set the child FPU state. */ case PTRACE_SETFPXREGS: /* Set the child FPU state. */
ret = set_fpxregs(datap, child); ret = set_fpxregs(datap, child);
break; break;
default:
ret = -EIO;
} }
return ret; return ret;
} }

View File

@ -145,7 +145,7 @@ int is_syscall(unsigned long addr)
return instr == 0x050f; return instr == 0x050f;
} }
int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) static int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
{ {
int err, n, cpu = ((struct thread_info *) child->stack)->cpu; int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
long fpregs[HOST_FP_SIZE]; long fpregs[HOST_FP_SIZE];
@ -162,7 +162,7 @@ int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
return n; return n;
} }
int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) static int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
{ {
int n, cpu = ((struct thread_info *) child->stack)->cpu; int n, cpu = ((struct thread_info *) child->stack)->cpu;
long fpregs[HOST_FP_SIZE]; long fpregs[HOST_FP_SIZE];
@ -178,5 +178,21 @@ int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
long subarch_ptrace(struct task_struct *child, long request, long subarch_ptrace(struct task_struct *child, long request,
unsigned long addr, unsigned long data) unsigned long addr, unsigned long data)
{ {
return -EIO; int ret = -EIO;
void __user *datap = (void __user *) data;
switch (request) {
case PTRACE_GETFPREGS: /* Get the child FPU state. */
ret = get_fpregs(datap, child);
break;
case PTRACE_SETFPREGS: /* Set the child FPU state. */
ret = set_fpregs(datap, child);
break;
case PTRACE_ARCH_PRCTL:
/* XXX Calls ptrace on the host - needs some SMP thinking */
ret = arch_prctl(child, data, (void __user *) addr);
break;
}
return ret;
} }