From patchwork Wed Feb 17 15:46:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: takasi-y@ops.dti.ne.jp X-Patchwork-Id: 45640 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A60DCB6EF4 for ; Thu, 18 Feb 2010 02:57:24 +1100 (EST) Received: from localhost ([127.0.0.1]:50150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NhmBH-00072s-Mq for incoming@patchwork.ozlabs.org; Wed, 17 Feb 2010 10:51:15 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Nhm73-0006Gc-8v for qemu-devel@nongnu.org; Wed, 17 Feb 2010 10:46:53 -0500 Received: from [199.232.76.173] (port=53471 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Nhm72-0006GJ-Kw for qemu-devel@nongnu.org; Wed, 17 Feb 2010 10:46:52 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1Nhm6z-0008T5-S3 for qemu-devel@nongnu.org; Wed, 17 Feb 2010 10:46:52 -0500 Received: from smtp09.dti.ne.jp ([202.216.231.184]:56544) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Nhm6z-0008Sz-5u for qemu-devel@nongnu.org; Wed, 17 Feb 2010 10:46:49 -0500 Received: from debian.lan (KHP059140016099.ppp-bb.dion.ne.jp [59.140.16.99]) by smtp09.dti.ne.jp (3.11s) with ESMTP AUTH id o1HFkjhW009910; Thu, 18 Feb 2010 00:46:45 +0900 (JST) Date: Thu, 18 Feb 2010 00:46:45 +0900 (JST) Message-Id: <201002171546.o1HFkjhW009910@smtp09.dti.ne.jp> From: takasi-y@ops.dti.ne.jp To: qemu-devel@nongnu.org X-Mailer: Sylpheed 2.5.0 (GTK+ 2.12.12; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-detected-operating-system: by monty-python.gnu.org: Solaris 9 Subject: [Qemu-devel] [PATCH] sh4 linux-user: Save/restore fpu registers to signal context. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org As "todo" comment in source code. And modify restore_sigcontext() to have three args as kernel's does. Signed-off-by: Takashi YOSHII --- linux-user/signal.c | 27 +++++++++++++++++++-------- 1 files changed, 19 insertions(+), 8 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index b0faf2e..8697511 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -2812,6 +2812,7 @@ static int setup_sigcontext(struct target_sigcontext *sc, CPUState *regs, unsigned long mask) { int err = 0; + int i; #define COPY(x) err |= __put_user(regs->x, &sc->sc_##x) COPY(gregs[0]); COPY(gregs[1]); @@ -2827,7 +2828,10 @@ static int setup_sigcontext(struct target_sigcontext *sc, COPY(sr); COPY(pc); #undef COPY - /* todo: save FPU registers here */ + for (i=0; i<16; i++) + err |= __put_user(regs->fregs[i], &sc->sc_fpregs[i]); + err |= __put_user(regs->fpscr, &sc->sc_fpscr); + err |= __put_user(regs->fpul, &sc->sc_fpul); /* non-iBCS2 extensions.. */ err |= __put_user(mask, &sc->oldmask); @@ -2835,10 +2839,11 @@ static int setup_sigcontext(struct target_sigcontext *sc, return err; } -static int restore_sigcontext(CPUState *regs, - struct target_sigcontext *sc) +static int restore_sigcontext(CPUState *regs, struct target_sigcontext *sc, + target_ulong *r0_p) { unsigned int err = 0; + int i; #define COPY(x) err |= __get_user(regs->x, &sc->sc_##x) COPY(gregs[1]); @@ -2854,9 +2859,13 @@ static int restore_sigcontext(CPUState *regs, COPY(sr); COPY(pc); #undef COPY - /* todo: restore FPU registers here */ + for (i=0; i<16; i++) + err |= __get_user(regs->fregs[i], &sc->sc_fpregs[i]); + err |= __get_user(regs->fpscr, &sc->sc_fpscr); + err |= __get_user(regs->fpul, &sc->sc_fpul); regs->tra = -1; /* disable syscall checks */ + err |= __get_user(*r0_p, &sc->sc_gregs[0]); return err; } @@ -2980,6 +2989,7 @@ long do_sigreturn(CPUState *regs) abi_ulong frame_addr; sigset_t blocked; target_sigset_t target_set; + target_ulong r0; int i; int err = 0; @@ -3001,11 +3011,11 @@ long do_sigreturn(CPUState *regs) target_to_host_sigset_internal(&blocked, &target_set); sigprocmask(SIG_SETMASK, &blocked, NULL); - if (restore_sigcontext(regs, &frame->sc)) + if (restore_sigcontext(regs, &frame->sc, &r0)) goto badframe; unlock_user_struct(frame, frame_addr, 0); - return regs->gregs[0]; + return r0; badframe: unlock_user_struct(frame, frame_addr, 0); @@ -3018,6 +3028,7 @@ long do_rt_sigreturn(CPUState *regs) struct target_rt_sigframe *frame; abi_ulong frame_addr; sigset_t blocked; + target_ulong r0; #if defined(DEBUG_SIGNAL) fprintf(stderr, "do_rt_sigreturn\n"); @@ -3029,7 +3040,7 @@ long do_rt_sigreturn(CPUState *regs) target_to_host_sigset(&blocked, &frame->uc.uc_sigmask); sigprocmask(SIG_SETMASK, &blocked, NULL); - if (restore_sigcontext(regs, &frame->uc.uc_mcontext)) + if (restore_sigcontext(regs, &frame->uc.uc_mcontext, &r0)) goto badframe; if (do_sigaltstack(frame_addr + @@ -3038,7 +3049,7 @@ long do_rt_sigreturn(CPUState *regs) goto badframe; unlock_user_struct(frame, frame_addr, 0); - return regs->gregs[0]; + return r0; badframe: unlock_user_struct(frame, frame_addr, 0);