aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/sh/kernel/ptrace_32.c38
-rw-r--r--arch/sh/kernel/ptrace_64.c19
2 files changed, 33 insertions, 24 deletions
diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c
index 34bf03745e8..90a15d29fee 100644
--- a/arch/sh/kernel/ptrace_32.c
+++ b/arch/sh/kernel/ptrace_32.c
@@ -368,7 +368,6 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)
368long arch_ptrace(struct task_struct *child, long request, 368long arch_ptrace(struct task_struct *child, long request,
369 unsigned long addr, unsigned long data) 369 unsigned long addr, unsigned long data)
370{ 370{
371 struct user * dummy = NULL;
372 unsigned long __user *datap = (unsigned long __user *)data; 371 unsigned long __user *datap = (unsigned long __user *)data;
373 int ret; 372 int ret;
374 373
@@ -384,17 +383,20 @@ long arch_ptrace(struct task_struct *child, long request,
384 383
385 if (addr < sizeof(struct pt_regs)) 384 if (addr < sizeof(struct pt_regs))
386 tmp = get_stack_long(child, addr); 385 tmp = get_stack_long(child, addr);
387 else if (addr >= (unsigned long) &dummy->fpu && 386 else if (addr >= offsetof(struct user, fpu) &&
388 addr < (unsigned long) &dummy->u_fpvalid) { 387 addr < offsetof(struct user, u_fpvalid)) {
389 if (!tsk_used_math(child)) { 388 if (!tsk_used_math(child)) {
390 if (addr == (unsigned long)&dummy->fpu.fpscr) 389 if (addr == offsetof(struct user, fpu.fpscr))
391 tmp = FPSCR_INIT; 390 tmp = FPSCR_INIT;
392 else 391 else
393 tmp = 0; 392 tmp = 0;
394 } else 393 } else {
394 unsigned long index;
395 index = addr - offsetof(struct user, fpu);
395 tmp = ((unsigned long *)child->thread.xstate) 396 tmp = ((unsigned long *)child->thread.xstate)
396 [(addr - (long)&dummy->fpu) >> 2]; 397 [index >> 2];
397 } else if (addr == (unsigned long) &dummy->u_fpvalid) 398 }
399 } else if (addr == offsetof(struct user, u_fpvalid))
398 tmp = !!tsk_used_math(child); 400 tmp = !!tsk_used_math(child);
399 else if (addr == PT_TEXT_ADDR) 401 else if (addr == PT_TEXT_ADDR)
400 tmp = child->mm->start_code; 402 tmp = child->mm->start_code;
@@ -418,13 +420,15 @@ long arch_ptrace(struct task_struct *child, long request,
418 420
419 if (addr < sizeof(struct pt_regs)) 421 if (addr < sizeof(struct pt_regs))
420 ret = put_stack_long(child, addr, data); 422 ret = put_stack_long(child, addr, data);
421 else if (addr >= (unsigned long) &dummy->fpu && 423 else if (addr >= offsetof(struct user, fpu) &&
422 addr < (unsigned long) &dummy->u_fpvalid) { 424 addr < offsetof(struct user, u_fpvalid)) {
425 unsigned long index;
426 index = addr - offsetof(struct user, fpu);
423 set_stopped_child_used_math(child); 427 set_stopped_child_used_math(child);
424 ((unsigned long *)child->thread.xstate) 428 ((unsigned long *)child->thread.xstate)
425 [(addr - (long)&dummy->fpu) >> 2] = data; 429 [index >> 2] = data;
426 ret = 0; 430 ret = 0;
427 } else if (addr == (unsigned long) &dummy->u_fpvalid) { 431 } else if (addr == offsetof(struct user, u_fpvalid)) {
428 conditional_stopped_child_used_math(data, child); 432 conditional_stopped_child_used_math(data, child);
429 ret = 0; 433 ret = 0;
430 } 434 }
@@ -434,35 +438,35 @@ long arch_ptrace(struct task_struct *child, long request,
434 return copy_regset_to_user(child, &user_sh_native_view, 438 return copy_regset_to_user(child, &user_sh_native_view,
435 REGSET_GENERAL, 439 REGSET_GENERAL,
436 0, sizeof(struct pt_regs), 440 0, sizeof(struct pt_regs),
437 (void __user *)data); 441 datap);
438 case PTRACE_SETREGS: 442 case PTRACE_SETREGS:
439 return copy_regset_from_user(child, &user_sh_native_view, 443 return copy_regset_from_user(child, &user_sh_native_view,
440 REGSET_GENERAL, 444 REGSET_GENERAL,
441 0, sizeof(struct pt_regs), 445 0, sizeof(struct pt_regs),
442 (const void __user *)data); 446 datap);
443#ifdef CONFIG_SH_FPU 447#ifdef CONFIG_SH_FPU
444 case PTRACE_GETFPREGS: 448 case PTRACE_GETFPREGS:
445 return copy_regset_to_user(child, &user_sh_native_view, 449 return copy_regset_to_user(child, &user_sh_native_view,
446 REGSET_FPU, 450 REGSET_FPU,
447 0, sizeof(struct user_fpu_struct), 451 0, sizeof(struct user_fpu_struct),
448 (void __user *)data); 452 datap);
449 case PTRACE_SETFPREGS: 453 case PTRACE_SETFPREGS:
450 return copy_regset_from_user(child, &user_sh_native_view, 454 return copy_regset_from_user(child, &user_sh_native_view,
451 REGSET_FPU, 455 REGSET_FPU,
452 0, sizeof(struct user_fpu_struct), 456 0, sizeof(struct user_fpu_struct),
453 (const void __user *)data); 457 datap);
454#endif 458#endif
455#ifdef CONFIG_SH_DSP 459#ifdef CONFIG_SH_DSP
456 case PTRACE_GETDSPREGS: 460 case PTRACE_GETDSPREGS:
457 return copy_regset_to_user(child, &user_sh_native_view, 461 return copy_regset_to_user(child, &user_sh_native_view,
458 REGSET_DSP, 462 REGSET_DSP,
459 0, sizeof(struct pt_dspregs), 463 0, sizeof(struct pt_dspregs),
460 (void __user *)data); 464 datap);
461 case PTRACE_SETDSPREGS: 465 case PTRACE_SETDSPREGS:
462 return copy_regset_from_user(child, &user_sh_native_view, 466 return copy_regset_from_user(child, &user_sh_native_view,
463 REGSET_DSP, 467 REGSET_DSP,
464 0, sizeof(struct pt_dspregs), 468 0, sizeof(struct pt_dspregs),
465 (const void __user *)data); 469 datap);
466#endif 470#endif
467 default: 471 default:
468 ret = ptrace_request(child, request, addr, data); 472 ret = ptrace_request(child, request, addr, data);
diff --git a/arch/sh/kernel/ptrace_64.c b/arch/sh/kernel/ptrace_64.c
index 4840716c196..4436eacddb1 100644
--- a/arch/sh/kernel/ptrace_64.c
+++ b/arch/sh/kernel/ptrace_64.c
@@ -387,6 +387,7 @@ long arch_ptrace(struct task_struct *child, long request,
387 unsigned long addr, unsigned long data) 387 unsigned long addr, unsigned long data)
388{ 388{
389 int ret; 389 int ret;
390 unsigned long __user *datap = (unsigned long __user *) data;
390 391
391 switch (request) { 392 switch (request) {
392 /* read the word at location addr in the USER area. */ 393 /* read the word at location addr in the USER area. */
@@ -401,13 +402,15 @@ long arch_ptrace(struct task_struct *child, long request,
401 tmp = get_stack_long(child, addr); 402 tmp = get_stack_long(child, addr);
402 else if ((addr >= offsetof(struct user, fpu)) && 403 else if ((addr >= offsetof(struct user, fpu)) &&
403 (addr < offsetof(struct user, u_fpvalid))) { 404 (addr < offsetof(struct user, u_fpvalid))) {
404 tmp = get_fpu_long(child, addr - offsetof(struct user, fpu)); 405 unsigned long index;
406 index = addr - offsetof(struct user, fpu);
407 tmp = get_fpu_long(child, index);
405 } else if (addr == offsetof(struct user, u_fpvalid)) { 408 } else if (addr == offsetof(struct user, u_fpvalid)) {
406 tmp = !!tsk_used_math(child); 409 tmp = !!tsk_used_math(child);
407 } else { 410 } else {
408 break; 411 break;
409 } 412 }
410 ret = put_user(tmp, (unsigned long *)data); 413 ret = put_user(tmp, datap);
411 break; 414 break;
412 } 415 }
413 416
@@ -438,7 +441,9 @@ long arch_ptrace(struct task_struct *child, long request,
438 } 441 }
439 else if ((addr >= offsetof(struct user, fpu)) && 442 else if ((addr >= offsetof(struct user, fpu)) &&
440 (addr < offsetof(struct user, u_fpvalid))) { 443 (addr < offsetof(struct user, u_fpvalid))) {
441 ret = put_fpu_long(child, addr - offsetof(struct user, fpu), data); 444 unsigned long index;
445 index = addr - offsetof(struct user, fpu);
446 ret = put_fpu_long(child, index, data);
442 } 447 }
443 break; 448 break;
444 449
@@ -446,23 +451,23 @@ long arch_ptrace(struct task_struct *child, long request,
446 return copy_regset_to_user(child, &user_sh64_native_view, 451 return copy_regset_to_user(child, &user_sh64_native_view,
447 REGSET_GENERAL, 452 REGSET_GENERAL,
448 0, sizeof(struct pt_regs), 453 0, sizeof(struct pt_regs),
449 (void __user *)data); 454 datap);
450 case PTRACE_SETREGS: 455 case PTRACE_SETREGS:
451 return copy_regset_from_user(child, &user_sh64_native_view, 456 return copy_regset_from_user(child, &user_sh64_native_view,
452 REGSET_GENERAL, 457 REGSET_GENERAL,
453 0, sizeof(struct pt_regs), 458 0, sizeof(struct pt_regs),
454 (const void __user *)data); 459 datap);
455#ifdef CONFIG_SH_FPU 460#ifdef CONFIG_SH_FPU
456 case PTRACE_GETFPREGS: 461 case PTRACE_GETFPREGS:
457 return copy_regset_to_user(child, &user_sh64_native_view, 462 return copy_regset_to_user(child, &user_sh64_native_view,
458 REGSET_FPU, 463 REGSET_FPU,
459 0, sizeof(struct user_fpu_struct), 464 0, sizeof(struct user_fpu_struct),
460 (void __user *)data); 465 datap);
461 case PTRACE_SETFPREGS: 466 case PTRACE_SETFPREGS:
462 return copy_regset_from_user(child, &user_sh64_native_view, 467 return copy_regset_from_user(child, &user_sh64_native_view,
463 REGSET_FPU, 468 REGSET_FPU,
464 0, sizeof(struct user_fpu_struct), 469 0, sizeof(struct user_fpu_struct),
465 (const void __user *)data); 470 datap);
466#endif 471#endif
467 default: 472 default:
468 ret = ptrace_request(child, request, addr, data); 473 ret = ptrace_request(child, request, addr, data);