From patchwork Wed Jun 21 21:07:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 779120 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3wtHNt66rgz9s2G for ; Thu, 22 Jun 2017 07:07:58 +1000 (AEST) Received: from localhost ([::1]:55972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNmqy-0006Le-Qb for incoming@patchwork.ozlabs.org; Wed, 21 Jun 2017 17:07:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41939) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dNmqe-0006LK-Rv for qemu-devel@nongnu.org; Wed, 21 Jun 2017 17:07:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dNmqa-0000LZ-Ry for qemu-devel@nongnu.org; Wed, 21 Jun 2017 17:07:36 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:56839) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dNmqa-0000Kw-Fr for qemu-devel@nongnu.org; Wed, 21 Jun 2017 17:07:32 -0400 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue002 [212.227.15.167]) with ESMTPSA (Nemesis) id 0Mc5pe-1d6fxp2OjG-00JMl1; Wed, 21 Jun 2017 23:07:19 +0200 From: Laurent Vivier To: Riku Voipio Date: Wed, 21 Jun 2017 23:07:04 +0200 Message-Id: <20170621210704.24388-1-laurent@vivier.eu> X-Mailer: git-send-email 2.9.4 X-Provags-ID: V03:K0:M1R2PhvoTptknnvokXnhQ7ii1hPB3tY8Q+7O12u8rtPkPSertQM iUj0BQTBrtzzwyRC8tUFGOP6ZSe62S7Ejxvtaf9lZHGMlvr3dpGpcF/F2oHI0XIYUcsN0m4 jr3slF8xDco6M+QR1o7rP0iYx5jbZ+Olp5kNtuarKZzQGhePxB8PU+QoTrj0UaApwMr75mh K4HOodmEkob06QBTUf2Bw== X-UI-Out-Filterresults: notjunk:1; V01:K0:ro67yHocYhc=:2x2x9ReNfgYhL799DdNbXJ HW6M6d9HyL2yZiVHD5Y1cVi6rXSYu9Kq/nJ6OmdnfoRLdfwj0C0cyhbJpkz4YSlMqcUCcAdDX olJvv0KjeviGiin49ovduhWkx5XWV6166EP1stQlnor06UldNssR2nR/XO5qDTCPd9zxrnxPW 6HAbhIPJQDNolh/XylimsKzh4YnEcESVpcJiJEEpi5saiigTRoWgVb6e1X6Lp9VmKb47xjG7W ehIGnWxfDuYMwqeBJ+0bFk0rUFWPvksrm00fjj80ZKntggOVd3IYFSDDJPx1ICf1iO8nFtzYe QIhpOSV32RV0oIaAjL4/M6u4W/xMHT6PN3NCglS13ZkNCG2v+ScDYpHIvI1p6ZXx/Wp38zdaM 6uO0KukYTE+bKgm0wDHrZR+96QKWJXrCclmHx2KdlEYTJ8dr3MKC8iXqQ8OLFtKl0K6MazUDE DxFn0UgxUBpQSBM4Um+B2bleZOfNwxVaUayZlpiupE3m4BMu565bsrkWMJQIIHtq0nNrISDJ+ hV1AjMU6BxDPJUWUYs7hhH4arJa4P1P8jpqhcuqt3HOz9QHvUXcJ3NRb9X7v2MGdGraML5htI haSVoIS5ILQnp7oJNEA5alFo+oD472lt7RtYsjTTYYacZT6MmEuQEF39+MACPkxLgXl+Bcyzs NF4ncoMgfte4RaF0DpjlkdYiDuZbT+XyPVfv0D8WQxH3ZMacFcLTZxB8jydcbhgEDCJg= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.227.126.187 Subject: [Qemu-devel] [PATCH v2] target-m68k, linux-user: manage FP registers in ucontext X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , qemu-devel@nongnu.org, Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson --- v2: add missing cpu_m68k_set_fpcr() to update FPU internal state The v1 was in the v5 of the series "target-m68k: implement 680x0 FPU" linux-user/signal.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/linux-user/signal.c b/linux-user/signal.c index 3d18d1b..197e8d1 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -5673,6 +5673,24 @@ give_sigsegv: force_sigsegv(sig); } +static inline void target_rt_save_fpu_state(struct target_ucontext *uc, + CPUM68KState *env) +{ + int i; + target_fpregset_t *fpregs = &uc->tuc_mcontext.fpregs; + + __put_user(env->fpcr, &fpregs->f_fpcntl[0]); + __put_user(env->fpsr, &fpregs->f_fpcntl[1]); + /* fpiar is not emulated */ + + for (i = 0; i < 8; i++) { + uint32_t high = env->fregs[i].d.high << 16; + __put_user(high, &fpregs->f_fpregs[i * 3]); + __put_user(env->fregs[i].d.low, + (uint64_t *)&fpregs->f_fpregs[i * 3 + 1]); + } +} + static inline int target_rt_setup_ucontext(struct target_ucontext *uc, CPUM68KState *env) { @@ -5699,9 +5717,32 @@ static inline int target_rt_setup_ucontext(struct target_ucontext *uc, __put_user(env->pc, &gregs[16]); __put_user(sr, &gregs[17]); + target_rt_save_fpu_state(uc, env); + return 0; } +static inline void target_rt_restore_fpu_state(CPUM68KState *env, + struct target_ucontext *uc) +{ + int i; + target_fpregset_t *fpregs = &uc->tuc_mcontext.fpregs; + uint32_t fpcr; + + __get_user(fpcr, &fpregs->f_fpcntl[0]); + cpu_m68k_set_fpcr(env, fpcr); + __get_user(env->fpsr, &fpregs->f_fpcntl[1]); + /* fpiar is not emulated */ + + for (i = 0; i < 8; i++) { + uint32_t high; + __get_user(high, &fpregs->f_fpregs[i * 3]); + env->fregs[i].d.high = high >> 16; + __get_user(env->fregs[i].d.low, + (uint64_t *)&fpregs->f_fpregs[i * 3 + 1]); + } +} + static inline int target_rt_restore_ucontext(CPUM68KState *env, struct target_ucontext *uc) { @@ -5733,6 +5774,8 @@ static inline int target_rt_restore_ucontext(CPUM68KState *env, __get_user(temp, &gregs[17]); cpu_m68k_set_ccr(env, temp); + target_rt_restore_fpu_state(env, uc); + return 0; badframe: