sh: Fix ptrace fpu state initialisation

Commit 0ea820cf introduced the PTRACE_GETFPREGS/SETFPREGS cmds,
but gdb-server still accesses the FPU state using the
PTRACE_PEEKUSR/POKEUSR commands. In this case, xstate was not
initialised.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Cc: stable@kernel.org
Signed-off-by: Paul Mundt <lethal@linux-sh.org>

authored by Phil Edworthy and committed by Paul Mundt c49b6ecf 3f4caa81

+12
+6
arch/sh/kernel/ptrace_32.c
··· 392 tmp = 0; 393 } else { 394 unsigned long index; 395 index = addr - offsetof(struct user, fpu); 396 tmp = ((unsigned long *)child->thread.xstate) 397 [index >> 2]; ··· 426 else if (addr >= offsetof(struct user, fpu) && 427 addr < offsetof(struct user, u_fpvalid)) { 428 unsigned long index; 429 index = addr - offsetof(struct user, fpu); 430 set_stopped_child_used_math(child); 431 ((unsigned long *)child->thread.xstate)
··· 392 tmp = 0; 393 } else { 394 unsigned long index; 395 + ret = init_fpu(child); 396 + if (ret) 397 + break; 398 index = addr - offsetof(struct user, fpu); 399 tmp = ((unsigned long *)child->thread.xstate) 400 [index >> 2]; ··· 423 else if (addr >= offsetof(struct user, fpu) && 424 addr < offsetof(struct user, u_fpvalid)) { 425 unsigned long index; 426 + ret = init_fpu(child); 427 + if (ret) 428 + break; 429 index = addr - offsetof(struct user, fpu); 430 set_stopped_child_used_math(child); 431 ((unsigned long *)child->thread.xstate)
+6
arch/sh/kernel/ptrace_64.c
··· 403 else if ((addr >= offsetof(struct user, fpu)) && 404 (addr < offsetof(struct user, u_fpvalid))) { 405 unsigned long index; 406 index = addr - offsetof(struct user, fpu); 407 tmp = get_fpu_long(child, index); 408 } else if (addr == offsetof(struct user, u_fpvalid)) { ··· 445 else if ((addr >= offsetof(struct user, fpu)) && 446 (addr < offsetof(struct user, u_fpvalid))) { 447 unsigned long index; 448 index = addr - offsetof(struct user, fpu); 449 ret = put_fpu_long(child, index, data); 450 }
··· 403 else if ((addr >= offsetof(struct user, fpu)) && 404 (addr < offsetof(struct user, u_fpvalid))) { 405 unsigned long index; 406 + ret = init_fpu(child); 407 + if (ret) 408 + break; 409 index = addr - offsetof(struct user, fpu); 410 tmp = get_fpu_long(child, index); 411 } else if (addr == offsetof(struct user, u_fpvalid)) { ··· 442 else if ((addr >= offsetof(struct user, fpu)) && 443 (addr < offsetof(struct user, u_fpvalid))) { 444 unsigned long index; 445 + ret = init_fpu(child); 446 + if (ret) 447 + break; 448 index = addr - offsetof(struct user, fpu); 449 ret = put_fpu_long(child, index, data); 450 }