* [PATCH] sh: Fix ptrace FPU state initialisation @ 2011-02-01 17:37 Phil Edworthy 2011-03-18 14:16 ` [PATCH] sh: Fix ptrace fpu " Phil Edworthy 2011-03-23 13:25 ` Paul Mundt 0 siblings, 2 replies; 3+ messages in thread From: Phil Edworthy @ 2011-02-01 17:37 UTC (permalink / raw) To: linux-sh RFC: 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. The patch below against 2.6.35 fixes this. I'll rework this for head if it's ok. However, should we still allow PEEKUSR/POKEUSR for FPU registers, or should we return an error? --- arch/sh/kernel/ptrace_32.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c index 6c4bbba..df0144c 100644 --- a/arch/sh/kernel/ptrace_32.c +++ b/arch/sh/kernel/ptrace_32.c @@ -363,9 +363,13 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) tmp = FPSCR_INIT; else tmp = 0; - } else + } else { + ret = init_fpu(child); + if (ret) + break; tmp = ((long *)child->thread.xstate) [(addr - (long)&dummy->fpu) >> 2]; + } } else if (addr = (long) &dummy->u_fpvalid) tmp = !!tsk_used_math(child); else if (addr = PT_TEXT_ADDR) @@ -392,6 +396,9 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data) ret = put_stack_long(child, addr, data); else if (addr >= (long) &dummy->fpu && addr < (long) &dummy->u_fpvalid) { + ret = init_fpu(child); + if (ret) + break; set_stopped_child_used_math(child); ((long *)child->thread.xstate) [(addr - (long)&dummy->fpu) >> 2] = data; -- 1.7.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH] sh: Fix ptrace fpu state initialisation 2011-02-01 17:37 [PATCH] sh: Fix ptrace FPU state initialisation Phil Edworthy @ 2011-03-18 14:16 ` Phil Edworthy 2011-03-23 13:25 ` Paul Mundt 1 sibling, 0 replies; 3+ messages in thread From: Phil Edworthy @ 2011-03-18 14:16 UTC (permalink / raw) To: linux-sh 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> --- arch/sh/kernel/ptrace_32.c | 6 ++++++ arch/sh/kernel/ptrace_64.c | 6 ++++++ 2 files changed, 12 insertions(+), 0 deletions(-) diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c index 90a15d2..b53664e 100644 --- a/arch/sh/kernel/ptrace_32.c +++ b/arch/sh/kernel/ptrace_32.c @@ -392,6 +392,9 @@ long arch_ptrace(struct task_struct *child, long request, tmp = 0; } else { unsigned long index; + ret = init_fpu(child); + if (ret) + break; index = addr - offsetof(struct user, fpu); tmp = ((unsigned long *)child->thread.xstate) [index >> 2]; @@ -423,6 +426,9 @@ long arch_ptrace(struct task_struct *child, long request, else if (addr >= offsetof(struct user, fpu) && addr < offsetof(struct user, u_fpvalid)) { unsigned long index; + ret = init_fpu(child); + if (ret) + break; index = addr - offsetof(struct user, fpu); set_stopped_child_used_math(child); ((unsigned long *)child->thread.xstate) diff --git a/arch/sh/kernel/ptrace_64.c b/arch/sh/kernel/ptrace_64.c index 4436eac..c8f9764 100644 --- a/arch/sh/kernel/ptrace_64.c +++ b/arch/sh/kernel/ptrace_64.c @@ -403,6 +403,9 @@ long arch_ptrace(struct task_struct *child, long request, else if ((addr >= offsetof(struct user, fpu)) && (addr < offsetof(struct user, u_fpvalid))) { unsigned long index; + ret = init_fpu(child); + if (ret) + break; index = addr - offsetof(struct user, fpu); tmp = get_fpu_long(child, index); } else if (addr = offsetof(struct user, u_fpvalid)) { @@ -442,6 +445,9 @@ long arch_ptrace(struct task_struct *child, long request, else if ((addr >= offsetof(struct user, fpu)) && (addr < offsetof(struct user, u_fpvalid))) { unsigned long index; + ret = init_fpu(child); + if (ret) + break; index = addr - offsetof(struct user, fpu); ret = put_fpu_long(child, index, data); } -- 1.7.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] sh: Fix ptrace fpu state initialisation 2011-02-01 17:37 [PATCH] sh: Fix ptrace FPU state initialisation Phil Edworthy 2011-03-18 14:16 ` [PATCH] sh: Fix ptrace fpu " Phil Edworthy @ 2011-03-23 13:25 ` Paul Mundt 1 sibling, 0 replies; 3+ messages in thread From: Paul Mundt @ 2011-03-23 13:25 UTC (permalink / raw) To: linux-sh On Fri, Mar 18, 2011 at 02:16:31PM +0000, Phil Edworthy wrote: > 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> Applied, thanks. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-23 13:25 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-02-01 17:37 [PATCH] sh: Fix ptrace FPU state initialisation Phil Edworthy 2011-03-18 14:16 ` [PATCH] sh: Fix ptrace fpu " Phil Edworthy 2011-03-23 13:25 ` Paul Mundt
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).