From patchwork Tue Mar 24 11:28:28 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Trimarchi X-Patchwork-Id: 13961 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n2OCJfVl011677 for ; Tue, 24 Mar 2009 12:19:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752992AbZCXMTb (ORCPT ); Tue, 24 Mar 2009 08:19:31 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753225AbZCXMTa (ORCPT ); Tue, 24 Mar 2009 08:19:30 -0400 Received: from ms01.sssup.it ([193.205.80.99]:55621 "EHLO sssup.it" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752992AbZCXMT3 (ORCPT ); Tue, 24 Mar 2009 08:19:29 -0400 X-Greylist: delayed 3596 seconds by postgrey-1.27 at vger.kernel.org; Tue, 24 Mar 2009 08:19:29 EDT Received: from [193.205.82.7] (HELO gandalf.sssup.it) by sssup.it (CommuniGate Pro SMTP 4.1.8) with ESMTP-TLS id 49369380; Tue, 24 Mar 2009 12:13:00 +0100 Received: from smaug.retis (smaug.retis [10.30.3.72]) by gandalf.sssup.it (8.12.10/8.12.10) with ESMTP id n2OBJRYR023547; Tue, 24 Mar 2009 12:19:27 +0100 Received: by smaug.retis (Postfix, from userid 1006) id 82B2A538C3; Tue, 24 Mar 2009 12:28:28 +0100 (CET) Date: Tue, 24 Mar 2009 12:28:28 +0100 From: Michael Trimarchi To: linux-sh@vger.kernel.org Cc: lethal@linux-sh.org Subject: [RFC patch] Fix stack dsp offset Message-ID: <20090324112828.GA17344@gandalf.sssup.it> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org Compute correcly the offset of the registers on the stack when the CONFIG_SH_DSP is enabled. It add a thread depend information in the thread_struct. It was tested in the migor sh4a using a gdbserver application for a non dsp application. Signed-off-by: Michael Trimarchi --- -- To unsubscribe from this list: send the line "unsubscribe linux-sh" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/sh/include/asm/processor_32.h b/arch/sh/include/asm/processor_32.h index efdd78a..46e73b2 100644 --- a/arch/sh/include/asm/processor_32.h +++ b/arch/sh/include/asm/processor_32.h @@ -96,6 +96,9 @@ struct thread_struct { /* floating point info */ union sh_fpu_union fpu; + + /* Dsp status information */ + long dsp_status; }; /* Count of active tasks with UBC settings */ diff --git a/arch/sh/include/asm/ptrace.h b/arch/sh/include/asm/ptrace.h index 81c6568..3504f2d 100644 --- a/arch/sh/include/asm/ptrace.h +++ b/arch/sh/include/asm/ptrace.h @@ -120,11 +120,19 @@ extern void user_enable_single_step(struct task_struct *); extern void user_disable_single_step(struct task_struct *); #ifdef CONFIG_SH_DSP -#define task_pt_regs(task) \ - ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE \ - - sizeof(struct pt_dspregs)) - 1) +extern int is_dsp_enabled(struct task_struct *); + #define task_pt_dspregs(task) \ - ((struct pt_dspregs *) (task_stack_page(task) + THREAD_SIZE) - 1) + ((struct pt_dspregs *) (task_stack_page(task) + THREAD_SIZE \ + - sizeof(unsigned long)) - 1) + +#define task_pt_regs(task) \ + (is_dsp_enabled(task) ? \ + ((struct pt_regs *) (task_stack_page(task) + \ + THREAD_SIZE - sizeof(struct pt_dspregs) - \ + sizeof(unsigned long)) - 1): \ + ((struct pt_regs *) (task_stack_page(task) + \ + THREAD_SIZE - sizeof(unsigned long)) - 1)) #else #define task_pt_regs(task) \ ((struct pt_regs *) (task_stack_page(task) + THREAD_SIZE) - 1) diff --git a/arch/sh/kernel/ptrace_32.c b/arch/sh/kernel/ptrace_32.c index 29ca09d..4560637 100644 --- a/arch/sh/kernel/ptrace_32.c +++ b/arch/sh/kernel/ptrace_32.c @@ -195,6 +195,12 @@ static int fpregs_active(struct task_struct *target, #endif #ifdef CONFIG_SH_DSP + +int is_dsp_enabled(struct task_struct *task) +{ + return !!(task->thread.dsp_status & SR_DSP); +} + static int dspregs_get(struct task_struct *target, const struct user_regset *regset, unsigned int pos, unsigned int count, diff --git a/arch/sh/kernel/traps_32.c b/arch/sh/kernel/traps_32.c index 60dcf87..d97886d 100644 --- a/arch/sh/kernel/traps_32.c +++ b/arch/sh/kernel/traps_32.c @@ -664,6 +664,8 @@ asmlinkage void do_reserved_inst(unsigned long r4, unsigned long r5, if (is_dsp_inst(regs)) { /* Enable DSP mode, and restart instruction. */ regs->sr |= SR_DSP; + /* Save DSP mode */ + tsk->thread.dsp_status |= SR_DSP; return; } #endif