aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2011-09-14 19:21:37 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2011-09-14 21:09:37 -0400
commitf2833aef6a0517e933992c8007f330d0df5d9317 (patch)
treeb1f664d138b897a5d3f28bfc5e242089a4435916
parent01599cdc2f891415387aed9921909b3e9f27c801 (diff)
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>
-rw-r--r--arch/um/include/asm/ptrace-generic.h4
-rw-r--r--arch/um/kernel/ptrace.c28
-rw-r--r--arch/um/sys-i386/asm/ptrace.h5
-rw-r--r--arch/um/sys-i386/ptrace.c18
-rw-r--r--arch/um/sys-x86_64/ptrace.c22
5 files changed, 31 insertions, 46 deletions
diff --git a/arch/um/include/asm/ptrace-generic.h b/arch/um/include/asm/ptrace-generic.h
index ae084ad1a3a0..1a7d2757fe05 100644
--- a/arch/um/include/asm/ptrace-generic.h
+++ b/arch/um/include/asm/ptrace-generic.h
@@ -42,10 +42,6 @@ extern long subarch_ptrace(struct task_struct *child, long request,
42 unsigned long addr, unsigned long data); 42 unsigned long addr, unsigned long data);
43extern unsigned long getreg(struct task_struct *child, int regno); 43extern unsigned long getreg(struct task_struct *child, int regno);
44extern int putreg(struct task_struct *child, int regno, unsigned long value); 44extern int putreg(struct task_struct *child, int regno, unsigned long value);
45extern int get_fpregs(struct user_i387_struct __user *buf,
46 struct task_struct *child);
47extern int set_fpregs(struct user_i387_struct __user *buf,
48 struct task_struct *child);
49 45
50extern int arch_copy_tls(struct task_struct *new); 46extern int arch_copy_tls(struct task_struct *new);
51extern void clear_flushed_tls(struct task_struct *task); 47extern void clear_flushed_tls(struct task_struct *task);
diff --git a/arch/um/kernel/ptrace.c b/arch/um/kernel/ptrace.c
index 701b672c1122..c9da32b0c707 100644
--- a/arch/um/kernel/ptrace.c
+++ b/arch/um/kernel/ptrace.c
@@ -50,23 +50,11 @@ long arch_ptrace(struct task_struct *child, long request,
50 void __user *vp = p; 50 void __user *vp = p;
51 51
52 switch (request) { 52 switch (request) {
53 /* read word at location addr. */
54 case PTRACE_PEEKTEXT:
55 case PTRACE_PEEKDATA:
56 ret = generic_ptrace_peekdata(child, addr, data);
57 break;
58
59 /* read the word at location addr in the USER area. */ 53 /* read the word at location addr in the USER area. */
60 case PTRACE_PEEKUSR: 54 case PTRACE_PEEKUSR:
61 ret = peek_user(child, addr, data); 55 ret = peek_user(child, addr, data);
62 break; 56 break;
63 57
64 /* write the word at location addr. */
65 case PTRACE_POKETEXT:
66 case PTRACE_POKEDATA:
67 ret = generic_ptrace_pokedata(child, addr, data);
68 break;
69
70 /* write the word at location addr in the USER area */ 58 /* write the word at location addr in the USER area */
71 case PTRACE_POKEUSR: 59 case PTRACE_POKEUSR:
72 ret = poke_user(child, addr, data); 60 ret = poke_user(child, addr, data);
@@ -107,16 +95,6 @@ long arch_ptrace(struct task_struct *child, long request,
107 break; 95 break;
108 } 96 }
109#endif 97#endif
110#ifdef PTRACE_GETFPREGS
111 case PTRACE_GETFPREGS: /* Get the child FPU state. */
112 ret = get_fpregs(vp, child);
113 break;
114#endif
115#ifdef PTRACE_SETFPREGS
116 case PTRACE_SETFPREGS: /* Set the child FPU state. */
117 ret = set_fpregs(vp, child);
118 break;
119#endif
120 case PTRACE_GET_THREAD_AREA: 98 case PTRACE_GET_THREAD_AREA:
121 ret = ptrace_get_thread_area(child, addr, vp); 99 ret = ptrace_get_thread_area(child, addr, vp);
122 break; 100 break;
@@ -154,12 +132,6 @@ long arch_ptrace(struct task_struct *child, long request,
154 break; 132 break;
155 } 133 }
156#endif 134#endif
157#ifdef PTRACE_ARCH_PRCTL
158 case PTRACE_ARCH_PRCTL:
159 /* XXX Calls ptrace on the host - needs some SMP thinking */
160 ret = arch_prctl(child, data, (void __user *) addr);
161 break;
162#endif
163 default: 135 default:
164 ret = ptrace_request(child, request, addr, data); 136 ret = ptrace_request(child, request, addr, data);
165 if (ret == -EIO) 137 if (ret == -EIO)
diff --git a/arch/um/sys-i386/asm/ptrace.h b/arch/um/sys-i386/asm/ptrace.h
index 0273e4d09af7..5d2a59112537 100644
--- a/arch/um/sys-i386/asm/ptrace.h
+++ b/arch/um/sys-i386/asm/ptrace.h
@@ -42,11 +42,6 @@
42 */ 42 */
43struct user_desc; 43struct user_desc;
44 44
45extern int get_fpxregs(struct user_fxsr_struct __user *buf,
46 struct task_struct *child);
47extern int set_fpxregs(struct user_fxsr_struct __user *buf,
48 struct task_struct *tsk);
49
50extern int ptrace_get_thread_area(struct task_struct *child, int idx, 45extern int ptrace_get_thread_area(struct task_struct *child, int idx,
51 struct user_desc __user *user_desc); 46 struct user_desc __user *user_desc);
52 47
diff --git a/arch/um/sys-i386/ptrace.c b/arch/um/sys-i386/ptrace.c
index 49fd25a5f206..3375c2717851 100644
--- a/arch/um/sys-i386/ptrace.c
+++ b/arch/um/sys-i386/ptrace.c
@@ -145,7 +145,7 @@ int peek_user(struct task_struct *child, long addr, long data)
145 return put_user(tmp, (unsigned long __user *) data); 145 return put_user(tmp, (unsigned long __user *) data);
146} 146}
147 147
148int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) 148static int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
149{ 149{
150 int err, n, cpu = ((struct thread_info *) child->stack)->cpu; 150 int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
151 struct user_i387_struct fpregs; 151 struct user_i387_struct fpregs;
@@ -161,7 +161,7 @@ int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
161 return n; 161 return n;
162} 162}
163 163
164int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) 164static int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
165{ 165{
166 int n, cpu = ((struct thread_info *) child->stack)->cpu; 166 int n, cpu = ((struct thread_info *) child->stack)->cpu;
167 struct user_i387_struct fpregs; 167 struct user_i387_struct fpregs;
@@ -174,7 +174,7 @@ int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
174 (unsigned long *) &fpregs); 174 (unsigned long *) &fpregs);
175} 175}
176 176
177int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) 177static int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
178{ 178{
179 int err, n, cpu = ((struct thread_info *) child->stack)->cpu; 179 int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
180 struct user_fxsr_struct fpregs; 180 struct user_fxsr_struct fpregs;
@@ -190,7 +190,7 @@ int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
190 return n; 190 return n;
191} 191}
192 192
193int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) 193static int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
194{ 194{
195 int n, cpu = ((struct thread_info *) child->stack)->cpu; 195 int n, cpu = ((struct thread_info *) child->stack)->cpu;
196 struct user_fxsr_struct fpregs; 196 struct user_fxsr_struct fpregs;
@@ -208,15 +208,21 @@ long subarch_ptrace(struct task_struct *child, long request,
208{ 208{
209 int ret = -EIO; 209 int ret = -EIO;
210 void __user *datap = (void __user *) data; 210 void __user *datap = (void __user *) data;
211
212 switch (request) { 211 switch (request) {
212 case PTRACE_GETFPREGS: /* Get the child FPU state. */
213 ret = get_fpregs(datap, child);
214 break;
215 case PTRACE_SETFPREGS: /* Set the child FPU state. */
216 ret = set_fpregs(datap, child);
217 break;
213 case PTRACE_GETFPXREGS: /* Get the child FPU state. */ 218 case PTRACE_GETFPXREGS: /* Get the child FPU state. */
214 ret = get_fpxregs(datap, child); 219 ret = get_fpxregs(datap, child);
215 break; 220 break;
216 case PTRACE_SETFPXREGS: /* Set the child FPU state. */ 221 case PTRACE_SETFPXREGS: /* Set the child FPU state. */
217 ret = set_fpxregs(datap, child); 222 ret = set_fpxregs(datap, child);
218 break; 223 break;
224 default:
225 ret = -EIO;
219 } 226 }
220
221 return ret; 227 return ret;
222} 228}
diff --git a/arch/um/sys-x86_64/ptrace.c b/arch/um/sys-x86_64/ptrace.c
index 7ed49ac78f88..4005506834fd 100644
--- a/arch/um/sys-x86_64/ptrace.c
+++ b/arch/um/sys-x86_64/ptrace.c
@@ -145,7 +145,7 @@ int is_syscall(unsigned long addr)
145 return instr == 0x050f; 145 return instr == 0x050f;
146} 146}
147 147
148int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) 148static int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
149{ 149{
150 int err, n, cpu = ((struct thread_info *) child->stack)->cpu; 150 int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
151 long fpregs[HOST_FP_SIZE]; 151 long fpregs[HOST_FP_SIZE];
@@ -162,7 +162,7 @@ int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
162 return n; 162 return n;
163} 163}
164 164
165int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) 165static int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
166{ 166{
167 int n, cpu = ((struct thread_info *) child->stack)->cpu; 167 int n, cpu = ((struct thread_info *) child->stack)->cpu;
168 long fpregs[HOST_FP_SIZE]; 168 long fpregs[HOST_FP_SIZE];
@@ -178,5 +178,21 @@ int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
178long subarch_ptrace(struct task_struct *child, long request, 178long subarch_ptrace(struct task_struct *child, long request,
179 unsigned long addr, unsigned long data) 179 unsigned long addr, unsigned long data)
180{ 180{
181 return -EIO; 181 int ret = -EIO;
182 void __user *datap = (void __user *) data;
183
184 switch (request) {
185 case PTRACE_GETFPREGS: /* Get the child FPU state. */
186 ret = get_fpregs(datap, child);
187 break;
188 case PTRACE_SETFPREGS: /* Set the child FPU state. */
189 ret = set_fpregs(datap, child);
190 break;
191 case PTRACE_ARCH_PRCTL:
192 /* XXX Calls ptrace on the host - needs some SMP thinking */
193 ret = arch_prctl(child, data, (void __user *) addr);
194 break;
195 }
196
197 return ret;
182} 198}