diff options
author | Namhyung Kim <namhyung@gmail.com> | 2010-10-27 18:34:03 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-10-27 21:03:12 -0400 |
commit | a9384e23ab19eba0dedb861ebcba805b98a3b7a5 (patch) | |
tree | 306969d7845d13bbc16dad4c668f14cb58e3024f /arch/sparc | |
parent | 9e1cb20619d8037248b6a776f777600c3584a8d5 (diff) |
ptrace: cleanup arch_ptrace() on sparc
Factor out struct fps and remove redundant castings.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/sparc')
-rw-r--r-- | arch/sparc/kernel/ptrace_32.c | 54 | ||||
-rw-r--r-- | arch/sparc/kernel/ptrace_64.c | 8 |
2 files changed, 24 insertions, 38 deletions
diff --git a/arch/sparc/kernel/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c index e08ba4a46acd..27b9e93d0121 100644 --- a/arch/sparc/kernel/ptrace_32.c +++ b/arch/sparc/kernel/ptrace_32.c | |||
@@ -323,19 +323,35 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task) | |||
323 | return &user_sparc32_view; | 323 | return &user_sparc32_view; |
324 | } | 324 | } |
325 | 325 | ||
326 | struct fps { | ||
327 | unsigned long regs[32]; | ||
328 | unsigned long fsr; | ||
329 | unsigned long flags; | ||
330 | unsigned long extra; | ||
331 | unsigned long fpqd; | ||
332 | struct fq { | ||
333 | unsigned long *insnaddr; | ||
334 | unsigned long insn; | ||
335 | } fpq[16]; | ||
336 | }; | ||
337 | |||
326 | long arch_ptrace(struct task_struct *child, long request, | 338 | long arch_ptrace(struct task_struct *child, long request, |
327 | unsigned long addr, unsigned long data) | 339 | unsigned long addr, unsigned long data) |
328 | { | 340 | { |
329 | unsigned long addr2 = current->thread.kregs->u_regs[UREG_I4]; | 341 | unsigned long addr2 = current->thread.kregs->u_regs[UREG_I4]; |
342 | void __user *addr2p; | ||
330 | const struct user_regset_view *view; | 343 | const struct user_regset_view *view; |
344 | struct pt_regs __user *pregs; | ||
345 | struct fps __user *fps; | ||
331 | int ret; | 346 | int ret; |
332 | 347 | ||
333 | view = task_user_regset_view(current); | 348 | view = task_user_regset_view(current); |
349 | addr2p = (void __user *) addr2; | ||
350 | pregs = (struct pt_regs __user *) addr; | ||
351 | fps = (struct fps __user *) addr; | ||
334 | 352 | ||
335 | switch(request) { | 353 | switch(request) { |
336 | case PTRACE_GETREGS: { | 354 | case PTRACE_GETREGS: { |
337 | struct pt_regs __user *pregs = (struct pt_regs __user *) addr; | ||
338 | |||
339 | ret = copy_regset_to_user(child, view, REGSET_GENERAL, | 355 | ret = copy_regset_to_user(child, view, REGSET_GENERAL, |
340 | 32 * sizeof(u32), | 356 | 32 * sizeof(u32), |
341 | 4 * sizeof(u32), | 357 | 4 * sizeof(u32), |
@@ -349,8 +365,6 @@ long arch_ptrace(struct task_struct *child, long request, | |||
349 | } | 365 | } |
350 | 366 | ||
351 | case PTRACE_SETREGS: { | 367 | case PTRACE_SETREGS: { |
352 | struct pt_regs __user *pregs = (struct pt_regs __user *) addr; | ||
353 | |||
354 | ret = copy_regset_from_user(child, view, REGSET_GENERAL, | 368 | ret = copy_regset_from_user(child, view, REGSET_GENERAL, |
355 | 32 * sizeof(u32), | 369 | 32 * sizeof(u32), |
356 | 4 * sizeof(u32), | 370 | 4 * sizeof(u32), |
@@ -364,19 +378,6 @@ long arch_ptrace(struct task_struct *child, long request, | |||
364 | } | 378 | } |
365 | 379 | ||
366 | case PTRACE_GETFPREGS: { | 380 | case PTRACE_GETFPREGS: { |
367 | struct fps { | ||
368 | unsigned long regs[32]; | ||
369 | unsigned long fsr; | ||
370 | unsigned long flags; | ||
371 | unsigned long extra; | ||
372 | unsigned long fpqd; | ||
373 | struct fq { | ||
374 | unsigned long *insnaddr; | ||
375 | unsigned long insn; | ||
376 | } fpq[16]; | ||
377 | }; | ||
378 | struct fps __user *fps = (struct fps __user *) addr; | ||
379 | |||
380 | ret = copy_regset_to_user(child, view, REGSET_FP, | 381 | ret = copy_regset_to_user(child, view, REGSET_FP, |
381 | 0 * sizeof(u32), | 382 | 0 * sizeof(u32), |
382 | 32 * sizeof(u32), | 383 | 32 * sizeof(u32), |
@@ -398,19 +399,6 @@ long arch_ptrace(struct task_struct *child, long request, | |||
398 | } | 399 | } |
399 | 400 | ||
400 | case PTRACE_SETFPREGS: { | 401 | case PTRACE_SETFPREGS: { |
401 | struct fps { | ||
402 | unsigned long regs[32]; | ||
403 | unsigned long fsr; | ||
404 | unsigned long flags; | ||
405 | unsigned long extra; | ||
406 | unsigned long fpqd; | ||
407 | struct fq { | ||
408 | unsigned long *insnaddr; | ||
409 | unsigned long insn; | ||
410 | } fpq[16]; | ||
411 | }; | ||
412 | struct fps __user *fps = (struct fps __user *) addr; | ||
413 | |||
414 | ret = copy_regset_from_user(child, view, REGSET_FP, | 402 | ret = copy_regset_from_user(child, view, REGSET_FP, |
415 | 0 * sizeof(u32), | 403 | 0 * sizeof(u32), |
416 | 32 * sizeof(u32), | 404 | 32 * sizeof(u32), |
@@ -425,8 +413,7 @@ long arch_ptrace(struct task_struct *child, long request, | |||
425 | 413 | ||
426 | case PTRACE_READTEXT: | 414 | case PTRACE_READTEXT: |
427 | case PTRACE_READDATA: | 415 | case PTRACE_READDATA: |
428 | ret = ptrace_readdata(child, addr, | 416 | ret = ptrace_readdata(child, addr, addr2p, data); |
429 | (void __user *) addr2, data); | ||
430 | 417 | ||
431 | if (ret == data) | 418 | if (ret == data) |
432 | ret = 0; | 419 | ret = 0; |
@@ -436,8 +423,7 @@ long arch_ptrace(struct task_struct *child, long request, | |||
436 | 423 | ||
437 | case PTRACE_WRITETEXT: | 424 | case PTRACE_WRITETEXT: |
438 | case PTRACE_WRITEDATA: | 425 | case PTRACE_WRITEDATA: |
439 | ret = ptrace_writedata(child, (void __user *) addr2, | 426 | ret = ptrace_writedata(child, addr2p, addr, data); |
440 | addr, data); | ||
441 | 427 | ||
442 | if (ret == data) | 428 | if (ret == data) |
443 | ret = 0; | 429 | ret = 0; |
diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c index d9db5a4dfef9..9ccc812bc09e 100644 --- a/arch/sparc/kernel/ptrace_64.c +++ b/arch/sparc/kernel/ptrace_64.c | |||
@@ -976,10 +976,12 @@ long arch_ptrace(struct task_struct *child, long request, | |||
976 | unsigned long addr2 = task_pt_regs(current)->u_regs[UREG_I4]; | 976 | unsigned long addr2 = task_pt_regs(current)->u_regs[UREG_I4]; |
977 | struct pt_regs __user *pregs; | 977 | struct pt_regs __user *pregs; |
978 | struct fps __user *fps; | 978 | struct fps __user *fps; |
979 | void __user *addr2p; | ||
979 | int ret; | 980 | int ret; |
980 | 981 | ||
981 | pregs = (struct pt_regs __user *) addr; | 982 | pregs = (struct pt_regs __user *) addr; |
982 | fps = (struct fps __user *) addr; | 983 | fps = (struct fps __user *) addr; |
984 | addr2p = (void __user *) addr2; | ||
983 | 985 | ||
984 | switch (request) { | 986 | switch (request) { |
985 | case PTRACE_PEEKUSR: | 987 | case PTRACE_PEEKUSR: |
@@ -1030,8 +1032,7 @@ long arch_ptrace(struct task_struct *child, long request, | |||
1030 | 1032 | ||
1031 | case PTRACE_READTEXT: | 1033 | case PTRACE_READTEXT: |
1032 | case PTRACE_READDATA: | 1034 | case PTRACE_READDATA: |
1033 | ret = ptrace_readdata(child, addr, | 1035 | ret = ptrace_readdata(child, addr, addr2p, data); |
1034 | (char __user *)addr2, data); | ||
1035 | if (ret == data) | 1036 | if (ret == data) |
1036 | ret = 0; | 1037 | ret = 0; |
1037 | else if (ret >= 0) | 1038 | else if (ret >= 0) |
@@ -1040,8 +1041,7 @@ long arch_ptrace(struct task_struct *child, long request, | |||
1040 | 1041 | ||
1041 | case PTRACE_WRITETEXT: | 1042 | case PTRACE_WRITETEXT: |
1042 | case PTRACE_WRITEDATA: | 1043 | case PTRACE_WRITEDATA: |
1043 | ret = ptrace_writedata(child, (char __user *) addr2, | 1044 | ret = ptrace_writedata(child, addr2p, addr, data); |
1044 | addr, data); | ||
1045 | if (ret == data) | 1045 | if (ret == data) |
1046 | ret = 0; | 1046 | ret = 0; |
1047 | else if (ret >= 0) | 1047 | else if (ret >= 0) |