From patchwork Wed Oct 18 12:33:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 116282 Delivered-To: patch@linaro.org Received: by 10.140.22.163 with SMTP id 32csp6015324qgn; Wed, 18 Oct 2017 05:36:58 -0700 (PDT) X-Received: by 10.237.34.201 with SMTP id q9mr2774112qtc.198.1508330218724; Wed, 18 Oct 2017 05:36:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508330218; cv=none; d=google.com; s=arc-20160816; b=lFpoy0J+cVEQ/AXty1+qIYDCvMJNtDQNlPEr2GVXfVhi/kzfvMsw3Og+yLGAGJGiup Zf8xZuHcQOvzf6oUsC0HFn+p4ZxE3qmW9mGZXDJ8u9hjh0L3DjyK8k2rrThHfRkhE/zT O1HavPVhDt8l12SZud+0Qs2D0aSD8iadlhSwoNtTTE3q84DkmQZzWZXyLU8pAwq7JfHb QexIcMJNA9WQCsd5Ex/u38Jrzp0tNYook/lahILHujcq67qKq2tFKeCOmlXYyQRDLpbP nHOmf7dJhcdVBYdj8atmMb32uXE0F+tPTVp9W85SeHyruZ4Xj5MpcV5MQ7z8PWLWe/B2 z7xw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=bUXOiLG8Tv+ZHWbTyJCUj0N5aeCUWKqiqSz0cVZvEfs=; b=Yk+BRBI81QGn38n8G6ftfW4+sO8DSUaASljWkFL+KvoHBa3R8LrNmDfKI556a6F37a 2riesHTuczyrIWqUdsnbdhGyuj9IW9Mu1dE8r7ZNvzUFpqJJi3BAKRDzgH7v+rICYGy6 E9zlWe88rAVskownhmaUZGzishZbEYRL4BuyIsC7koiAG6VdSL0bBjZKI9/xmK1eOjYu pDcvNBjedM2Nve8g9Wng+gYtCZhQP8iLUL2sSnghbLRAH8vY2lOf+1O23fQAt2QX9MV4 dAWMPysFWNa3k3HL5j6pCYdhQ9dJfgJ1RV8XxqGeMXKyHfKW6AtTJK5ko3YpUrri7yVt IKDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QkktoTJn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x28si4189810qtx.41.2017.10.18.05.36.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 18 Oct 2017 05:36:58 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QkktoTJn; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44441 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4nai-0007Gq-Lf for patch@linaro.org; Wed, 18 Oct 2017 08:36:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4nXU-0005C7-Hb for qemu-devel@nongnu.org; Wed, 18 Oct 2017 08:33:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4nXQ-0003tU-6S for qemu-devel@nongnu.org; Wed, 18 Oct 2017 08:33:35 -0400 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]:49430) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1e4nXP-0003t2-Uv for qemu-devel@nongnu.org; Wed, 18 Oct 2017 08:33:32 -0400 Received: by mail-lf0-x243.google.com with SMTP id w21so5625554lfc.6 for ; Wed, 18 Oct 2017 05:33:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bUXOiLG8Tv+ZHWbTyJCUj0N5aeCUWKqiqSz0cVZvEfs=; b=QkktoTJnsPxjdn619RDOksfDL4kYXwawZHriGHiv3RbGLEq9NipaaglUZJqzqdJBAa Lap2n6wx0hwk94jZwWD+qxMGhPLk585Ivi6tEghus4SELuv6mWMmeE42S4dMpkuvtuJn w+h/nndeoSS93IMXx+lJKSYQ5257Nli6cSH6c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bUXOiLG8Tv+ZHWbTyJCUj0N5aeCUWKqiqSz0cVZvEfs=; b=emjMJPia0UGvNQQiUa3MUBJ9k4ZbyHeGYcJpnrkZ97B+v69s6XMt8qOwTZDn1Dtm8s ARWviZGB0o4SIn5V6lCeOi45jFcIecauCd71qSa/tsKeSns5pz8a7JlxIr/BPGXG12SA /W5nCja9HfV9qLoN7pbiS0xGYYQcrmJVez3gIyRKEaXAbpFhS5mbyDl4V6iuBfXOScED +92lgszKts0jNDQfh1dfkzlxDsCbrx38Do5j+6l0nT2ov+Jr6QDenZH09XFz9QMvd8Y3 SYgdZtjo87Xnw6Ay+ZW191TsjwgI7I0eBUAqN8j7MO1B30OM/w2WHSOLtlMB0JOBVP4O i9Gw== X-Gm-Message-State: AMCzsaVIlFbsi2TIcj7FNAhWT04BWL6LrYG35htxXIKgwcECf9TniHbB b4bcjymUQ6ficcxnpL15Az0oHFc3yMg= X-Google-Smtp-Source: ABhQp+Qb5A4VCx6afPqRAaGjQ7FjzOEELCRQ9YVL4Uola/qVJ5twDeRGyAfRPFcVTEy6x9vVMakngw== X-Received: by 10.46.69.6 with SMTP id s6mr2327366lja.76.1508330010399; Wed, 18 Oct 2017 05:33:30 -0700 (PDT) Received: from berserk.kos.to (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id j71sm2590718lfk.6.2017.10.18.05.33.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Oct 2017 05:33:29 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 18 Oct 2017 15:33:16 +0300 Message-Id: X-Mailer: git-send-email 2.14.2 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4010:c07::243 Subject: [Qemu-devel] [PULL 02/10] 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier Signed-off-by: Laurent Vivier Reviewed-by: Richard Henderson Signed-off-by: Riku Voipio --- linux-user/signal.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) -- 2.14.2 diff --git a/linux-user/signal.c b/linux-user/signal.c index cc0c3fcee9..7a238aaea1 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -5704,6 +5704,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) { @@ -5730,9 +5748,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) { @@ -5764,6 +5805,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: