From nobody Mon May 6 03:36:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1604676551; cv=none; d=zohomail.com; s=zohoarc; b=hPf2rQgI5g9MQ8ejiW4+TVxEnOuy4Bs6jK7TiFM74PZulKkQzPcPHWcq+LYofWQQ0HHZLGoTEu7eef9HECuiFBBJ0di10RVwTuFfB7W+B6iz1RzzSU+okV1tH6CJVmXcETOx+cG+IogIRC2VA6AlxoAS62Hh98NG9/GzoD4H5VM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604676551; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=r8tx3kzrnnukFrD0hkvRYpxfc/p9hgOCDrl4XseNEZY=; b=gEQvpHnfgNK9DO3tsR823m7FGq7h8WHj4f2W2kIkq7XXsjDmia4F2StKfHr5eh2/0mLGHGdjUUUrPNnhAk9pBx9LjfXN8QPAvKIPQNk34isgUPomOkPSxis/awh4PuHBJFFIFhR6q2Haqf1DGA1KGVzZVQMA12iPFO7Dg5zsBXk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604676551458451.91605351917315; Fri, 6 Nov 2020 07:29:11 -0800 (PST) Received: from localhost ([::1]:41242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kb3fp-0004zZ-Ot for importer@patchew.org; Fri, 06 Nov 2020 10:29:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38064) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kb3eU-0003Q7-Ml for qemu-devel@nongnu.org; Fri, 06 Nov 2020 10:27:46 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:43799) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kb3eS-0001H6-51 for qemu-devel@nongnu.org; Fri, 06 Nov 2020 10:27:46 -0500 Received: by mail-wr1-x442.google.com with SMTP id g12so1723202wrp.10 for ; Fri, 06 Nov 2020 07:27:43 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 109sm2723462wra.29.2020.11.06.07.27.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 07:27:41 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=r8tx3kzrnnukFrD0hkvRYpxfc/p9hgOCDrl4XseNEZY=; b=O70VBhbRoIoWRqHOsU6iDEeg3OePISMX7xc+h0nCtsIzNDolThMZWjVJAo+4bXAwGF 0XzAXXpPxH1dmGjoidy2QKnhTqE0M2ogtx3MCxYALzBSO+V000g+a2P6WkBvmaGb/fFh YGqrvGWxSdopGSb2eJKao0AZNhYqNZm0hhgDC+LqV+GWk653iPiZOnXAU317pryBHzDQ y0U5hSY+0lf9z9KBd9CnbO/vMC4q82VDP5IEafq4MVfX4spolx1V6VGwgatLXAr7kVX6 8yrgJ/236dMj1bacz2jGKdurkMdyDUfQQlEcysItga/Bs1WQPXgf4UKmGFHmyV63V1Eh A7dA== 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:mime-version:content-transfer-encoding; bh=r8tx3kzrnnukFrD0hkvRYpxfc/p9hgOCDrl4XseNEZY=; b=ilMG9+Ie2O/7OMBBvEiC26SwPrKz8pROWNXc1TifvHTZdOqzCs9DyFFc9MKOqA+49M DpYpHL4sTneODtS56ck2cvHJ+rONpsvrrsPQGg7slCo9zbeTCfliYO4dS053eHgFDDft 7I0v31fIov/NtK+nXcRHyjefl/Aw0Uywepao4fkVRYIjGuehYdKxUkQZpOp20WrE47Aj eOCGwyFWwVxdpou8fkyHibfmFxZXI8Rp7mR5xZcbTgWum3HZTkL2hdEy/tOCY9Xu0JTM qTBfHd6wlWIAjvaj8GUqn+R3ZOn8s4fU6PAN99HOenlqLwhhe1QOn4BhqqiOvDKhWvIb CDbA== X-Gm-Message-State: AOAM532NyFOWrQw857alZbstUkGsCWeig3GQ9fkChSZemFmij6Zqv7Hf gMe6jdWcBZb4lXQWSO8/J4E0UtdH3p2eLA== X-Google-Smtp-Source: ABdhPJyOj+FS4e4eJhnhs3R7uTqcV4PpnMHqaefb+FJLj/msqQXgCW2MeqOI0gTLkITRrcUSshfwEQ== X-Received: by 2002:adf:e950:: with SMTP id m16mr2967236wrn.0.1604676462005; Fri, 06 Nov 2020 07:27:42 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v2 1/4] linux-user/sparc: Correct sparc64_get/set_context() FPU handling Date: Fri, 6 Nov 2020 15:27:35 +0000 Message-Id: <20201106152738.26026-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201106152738.26026-1-peter.maydell@linaro.org> References: <20201106152738.26026-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Giuseppe Musacchio , Mark Cave-Ayland , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The handling of the FPU state in sparc64_get_context() and sparc64_set_context() is not the same as what the kernel actually does: we unconditionally read and write the FP registers and the FSR, GSR and FPRS, but the kernel logic is more complicated: * in get_context the kernel has code for saving FPU registers, but it is hidden inside an "if (fenab) condition and the fenab flag is always set to 0 (inside an "#if 1" which has been in the kernel for over 15 years). So the effect is that the FPU state part is always written as zeroes. * in set_context the kernel looks at the fenab field in the structure from the guest, and only restores the state if it is set; it also looks at the structure's FPRS to see whether either the upper or lower or both halves of the register file have valid data. Bring our implementations into line with the kernel: * in get_context: - clear the entire target_ucontext at the top of the function (as the kernel does) - then don't write the FPU state, so those fields remain zero - this fixes Coverity issue CID 1432305 by deleting the code it was complaining about * in set_context: - check the fenab and the fpsr to decide which parts of the FPU data to restore, if any - instead of setting the FPU registers by doing two 32-bit loads and filling in the .upper and .lower parts of the CPU_Double union separately, just do a 64-bit load of the whole register at once. This fixes Coverity issue CID 1432303 because we now access the dregs[] part of the mcfpu_fregs union rather than the sregs[] part (which is not large enough to actually cover the whole of the data, so we were accessing off the end of sregs[]) We change both functions in a single commit to avoid potentially breaking bisection. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/sparc/cpu.h | 4 ++- linux-user/sparc/signal.c | 74 +++++++++++++++++++++++---------------- 2 files changed, 46 insertions(+), 32 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index b9369398f24..277254732b9 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -156,7 +156,9 @@ enum { #define PS_IE (1<<1) #define PS_AG (1<<0) /* v9, zero on UA2007 */ =20 -#define FPRS_FEF (1<<2) +#define FPRS_DL (1 << 0) +#define FPRS_DU (1 << 1) +#define FPRS_FEF (1 << 2) =20 #define HS_PRIV (1<<2) #endif diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index d12adc8e6ff..e661a769cb1 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -402,8 +402,10 @@ void sparc64_set_context(CPUSPARCState *env) abi_ulong ucp_addr; struct target_ucontext *ucp; target_mc_gregset_t *grp; + target_mc_fpu_t *fpup; abi_ulong pc, npc, tstate; unsigned int i; + unsigned char fenab; =20 ucp_addr =3D env->regwptr[WREG_O0]; if (!lock_user_struct(VERIFY_READ, ucp, ucp_addr, 1)) { @@ -467,26 +469,42 @@ void sparc64_set_context(CPUSPARCState *env) __get_user(env->regwptr[WREG_FP], &(ucp->tuc_mcontext.mc_fp)); __get_user(env->regwptr[WREG_I7], &(ucp->tuc_mcontext.mc_i7)); =20 - /* FIXME this does not match how the kernel handles the FPU in - * its sparc64_set_context implementation. In particular the FPU - * is only restored if fenab is non-zero in: - * __get_user(fenab, &(ucp->tuc_mcontext.mc_fpregs.mcfpu_enab)); - */ - __get_user(env->fprs, &(ucp->tuc_mcontext.mc_fpregs.mcfpu_fprs)); - { - uint32_t *src =3D ucp->tuc_mcontext.mc_fpregs.mcfpu_fregs.sregs; - for (i =3D 0; i < 64; i++, src++) { - if (i & 1) { - __get_user(env->fpr[i/2].l.lower, src); - } else { - __get_user(env->fpr[i/2].l.upper, src); + fpup =3D &ucp->tuc_mcontext.mc_fpregs; + + __get_user(fenab, &(fpup->mcfpu_enab)); + if (fenab) { + abi_ulong fprs; + + /* + * We use the FPRS from the guest only in deciding whether + * to restore the upper, lower, or both banks of the FPU regs. + * The kernel here writes the FPU register data into the + * process's current_thread_info state and unconditionally + * clears FPRS and TSTATE_PEF: this disables the FPU so that the + * next FPU-disabled trap will copy the data out of + * current_thread_info and into the real FPU registers. + * QEMU doesn't need to handle lazy-FPU-state-restoring like that, + * so we always load the data directly into the FPU registers + * and leave FPRS and TSTATE_PEF alone (so the FPU stays enabled). + * Note that because we (and the kernel) always write zeroes for + * the fenab and fprs in sparc64_get_context() none of this code + * will execute unless the guest manually constructed or changed + * the context structure. + */ + __get_user(fprs, &(fpup->mcfpu_fprs)); + if (fprs & FPRS_DL) { + for (i =3D 0; i < 16; i++) { + __get_user(env->fpr[i].ll, &(fpup->mcfpu_fregs.dregs[i])); } } + if (fprs & FPRS_DU) { + for (i =3D 16; i < 31; i++) { + __get_user(env->fpr[i].ll, &(fpup->mcfpu_fregs.dregs[i])); + } + } + __get_user(env->fsr, &(fpup->mcfpu_fsr)); + __get_user(env->gsr, &(fpup->mcfpu_gsr)); } - __get_user(env->fsr, - &(ucp->tuc_mcontext.mc_fpregs.mcfpu_fsr)); - __get_user(env->gsr, - &(ucp->tuc_mcontext.mc_fpregs.mcfpu_gsr)); unlock_user_struct(ucp, ucp_addr, 0); return; do_sigsegv: @@ -509,7 +527,9 @@ void sparc64_get_context(CPUSPARCState *env) if (!lock_user_struct(VERIFY_WRITE, ucp, ucp_addr, 0)) { goto do_sigsegv; } - =20 + + memset(ucp, 0, sizeof(*ucp)); + mcp =3D &ucp->tuc_mcontext; grp =3D &mcp->mc_gregs; =20 @@ -572,19 +592,11 @@ void sparc64_get_context(CPUSPARCState *env) __put_user(env->regwptr[WREG_FP], &(mcp->mc_fp)); __put_user(env->regwptr[WREG_I7], &(mcp->mc_i7)); =20 - { - uint32_t *dst =3D ucp->tuc_mcontext.mc_fpregs.mcfpu_fregs.sregs; - for (i =3D 0; i < 64; i++, dst++) { - if (i & 1) { - __put_user(env->fpr[i/2].l.lower, dst); - } else { - __put_user(env->fpr[i/2].l.upper, dst); - } - } - } - __put_user(env->fsr, &(mcp->mc_fpregs.mcfpu_fsr)); - __put_user(env->gsr, &(mcp->mc_fpregs.mcfpu_gsr)); - __put_user(env->fprs, &(mcp->mc_fpregs.mcfpu_fprs)); + /* + * We don't write out the FPU state. This matches the kernel's + * implementation (which has the code for doing this but + * hidden behind an "if (fenab)" where fenab is always 0). + */ =20 if (err) goto do_sigsegv; --=20 2.20.1 From nobody Mon May 6 03:36:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1604676657; cv=none; d=zohomail.com; s=zohoarc; b=IUABX766BaF09McK70xbm9s1rtH/ySK8bVswr85MlWlKnaZ/0Y5AkNmwVU2BHnXY6SkF9P/g46ZDqQXakcAj3QJn+O+ewZ2iRGUwyf/CIa3qkfYMNIhI5bF1+6IPN+Mc1SWkAI+TM0jiJ5UV4XJdezHKtqCJWEoBzrQiQnQ+XDw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604676657; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=V0VNebrgohv9IYYKN87N6YOfgqI0isAkODJyfYTaOuA=; b=EUV468ofaqjiNbPoIJJKaamCGDZcRgg8T2dlzb0tFZkvbGpc0ZenWjwfbjbk0dFz2C4ibSKkIug5YtjLshAfVO/xV9HC55L4csJd65E0+POrJRjULit891yITLYtUOsLu9FE9GcIEeUC26fQ+qBDOZk6vD66WqHpR8xN/r3ts1o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604676657723886.0517407929257; Fri, 6 Nov 2020 07:30:57 -0800 (PST) Received: from localhost ([::1]:47716 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kb3hY-00080M-Gh for importer@patchew.org; Fri, 06 Nov 2020 10:30:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kb3eV-0003QH-J9 for qemu-devel@nongnu.org; Fri, 06 Nov 2020 10:27:47 -0500 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:36923) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kb3eS-0001HF-T8 for qemu-devel@nongnu.org; Fri, 06 Nov 2020 10:27:47 -0500 Received: by mail-wr1-x443.google.com with SMTP id w1so1736244wrm.4 for ; Fri, 06 Nov 2020 07:27:44 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 109sm2723462wra.29.2020.11.06.07.27.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 07:27:42 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=V0VNebrgohv9IYYKN87N6YOfgqI0isAkODJyfYTaOuA=; b=oRnc/kG/USrld8T6l8ev+0XBp8k1MhWvamOVi8CuEOPTRGuFG4EtZHe9bsjFQuC71H eHYh/7AFZjbalw4FD1Y4QaEaidDdAlwyRqKW5cBZK19+vQh35iASCnNOOy9/4pPxa+rb bfU8qvXYNmRBqLG1XsEtmmREj+ZYVx5opUBFHgbueqUTxuk8Wh+uh0JFe5ndYdbMkZhx cWSDv26K8ipyyXy7rBKwItSSbc8oe66twiF0q/H/Pdy+4ASf4rg53x+uthDZg5aImms8 f1YXsFOg7eYRn8ZEL5iTCsa1IaGgLECDrdxjtiVybWocKS5BdWuZe+AArIicPCdu2Vde ufFA== 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:mime-version:content-transfer-encoding; bh=V0VNebrgohv9IYYKN87N6YOfgqI0isAkODJyfYTaOuA=; b=g879kSE92DgZEtxbL7uqSEox7SuijVJenh9ZGwsY0E1LLr10icTTCGwmxs3IWsnUie ZUpqiS9c1wTN3LqomcyqHDCHrVdYgxdapgIYRZplM4mKHdPffg/rcKzJKw2jaTejcaIK b501DquoGjFuNQFuL8voWraXgPktJA57Ow9nZzD3Kdp9TfVt1bKRPuURtmwpnTtRzFPt gzsKa9pQw4kKenDb1b3Dx8Dw8ZtOfEs8zkdBvNZfF5fXt3ImMubqtrVaw0SlMP+YduZB 0CQfwxya/dW9ebhSNX05yi8/gRwQiNdXGS4B3372NrCNmUwRHDh3Fo8UB5lXMAWYBwJY Qslg== X-Gm-Message-State: AOAM532LORIiyVXWe/PDGtiEuX92HwRq7xPDBQrpr0KqCohZKHiBAabq m9mbbkvj0rXnjpy8qbyMvLxGb1rPpAMv9g== X-Google-Smtp-Source: ABdhPJy3hcRBUhQ0MxF7oFIZ9exCJC4oxmH4uv0Tztrfs+3fZrDWW5mzE7Oqtcu0LM6dHqIIXHMulg== X-Received: by 2002:a5d:6681:: with SMTP id l1mr3316614wru.356.1604676463318; Fri, 06 Nov 2020 07:27:43 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v2 2/4] linux-user/sparc: Remove unneeded checks of 'err' from sparc64_get_context() Date: Fri, 6 Nov 2020 15:27:36 +0000 Message-Id: <20201106152738.26026-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201106152738.26026-1-peter.maydell@linaro.org> References: <20201106152738.26026-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Giuseppe Musacchio , Mark Cave-Ayland , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Unlike the kernel macros, our __get_user() and __put_user() do not return a failure code. Kernel code typically has a style of err |=3D __get_user(...); err |=3D __get_user(...); and then checking err at the end. In sparc64_get_context() our version of the code dropped the accumulating into err but left the "if (err) goto do_sigsegv" checks, which will never be taken. Delete unnecessary if()s. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- linux-user/sparc/signal.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index e661a769cb1..43dcd137f51 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -555,8 +555,6 @@ void sparc64_get_context(CPUSPARCState *env) for (i =3D 0; i < TARGET_NSIG_WORDS; i++, dst++, src++) { __put_user(*src, dst); } - if (err) - goto do_sigsegv; } =20 /* XXX: tstate must be saved properly */ @@ -598,8 +596,6 @@ void sparc64_get_context(CPUSPARCState *env) * hidden behind an "if (fenab)" where fenab is always 0). */ =20 - if (err) - goto do_sigsegv; unlock_user_struct(ucp, ucp_addr, 1); return; do_sigsegv: --=20 2.20.1 From nobody Mon May 6 03:36:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1604676657; cv=none; d=zohomail.com; s=zohoarc; b=iV7wECO+aY/UoVggbCNciCezCG0gkck7hmUs+8kssEhwx4VTabZMp8GtumhBvAmIZ0yeQzniDGelc+P3+H8EShqwVtB4QBNS1t4WvXgdjyQHhXIitBmswiyws0Kqivrwd9+hhSdz95xEod1EQiYOPakfBaZkg3OHRp9i4wMeoCs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604676657; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3Ni7G05pYt+LDiFpxH3YOkSYrcyuPHp1dU/RFuicYYM=; b=KmT/HHSI6+FAiN+FrHgirqD4mDcoU6mKZ/o3nScimqyjoDIGwGFTxDBGs9SQbHmCF+mJzlD+sh9PifDb0xIzHOzgX5+YiHwGVfQVOC6r5lfh5LpToPTAstvhs9ZHz2vnOqf4sZkYzi9Of9U+cVBGBhecGwRnmEG60Ubd7EzOSiw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604676657764124.28603586254371; Fri, 6 Nov 2020 07:30:57 -0800 (PST) Received: from localhost ([::1]:47754 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kb3hY-000818-MN for importer@patchew.org; Fri, 06 Nov 2020 10:30:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kb3eW-0003QQ-07 for qemu-devel@nongnu.org; Fri, 06 Nov 2020 10:27:48 -0500 Received: from mail-wr1-x441.google.com ([2a00:1450:4864:20::441]:42545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kb3eU-0001HT-A1 for qemu-devel@nongnu.org; Fri, 06 Nov 2020 10:27:47 -0500 Received: by mail-wr1-x441.google.com with SMTP id w14so1721542wrs.9 for ; Fri, 06 Nov 2020 07:27:45 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 109sm2723462wra.29.2020.11.06.07.27.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 07:27:43 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=3Ni7G05pYt+LDiFpxH3YOkSYrcyuPHp1dU/RFuicYYM=; b=MTA/9uMDNy6n54NxO4HhuW6vGMh09HVoT21yeMuELxCYc9sSRijJpwqLOBPqFG9YdK 7jSGQ9UzGQFngD09+5n7cKH3VT7WsN2VxReqUGKM69dNMjT80/FGivjDvflP9lhw7QGa BLMp5RDEAYHn7E8w1RbbkM0Q7bT/DpkVyNSgPNOi2659SgYYL3+sKjWymaQDG7WHQsvl vBkSEYBjHj3LRXdsd74qpjgpjkBkW/QlysMjzLABv2aQ1hft+kqBV05P7JISiAdKjF9L X996zvdNFImEG/cEcHryeYg/OBn4dgTQTcOjCWVkc6iPOCz4BhYFAY5x0muOEn38JVnW NvTw== 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:mime-version:content-transfer-encoding; bh=3Ni7G05pYt+LDiFpxH3YOkSYrcyuPHp1dU/RFuicYYM=; b=Fhf4ZJ66dzRbLbrh45tJOMTPrdlWFUBvHr3NTPAucu+YlFoKJXIuTUm9SslGNnb59c OX4pUmq7Eoj1mdE8/VSeLsHh18s3iR8qNeDOEMqwk2tDLx1aQ1whl9+HARFXFn3SRR78 s0K7QFFbO8AcmMdJK/vifcF/yEOpIr+3wm9qofYwJd67k9Rwjs+dzmfvsfv59GhwGeDz fbqPwPbxrGX5jCco5TCvX6vYR27m0ul5NV6ZP1mwPModzBzrfcCsfaZhEgdYb6B8Iff6 5z3QJdOAmgJw8dY975uXUbeolFFaoZrRIA2gfOYFFwpurFGlzWqcsaTbnejWAYDWur44 gPDA== X-Gm-Message-State: AOAM530kF3ZumitMuH04F0EAEk5wm1QjMXyh/tyVt74as4igHIOZl4F9 oTQmA0C0lmLr2Wd4fCb29emAzkZyb/V3pw== X-Google-Smtp-Source: ABdhPJwcRR1PUyzN7pLI8m5qKO67y5khiRt/RgTsjiS7cSahFAIJPWJ9+6h5qMDD28mzMx0suCjYoA== X-Received: by 2002:adf:9e08:: with SMTP id u8mr3206856wre.282.1604676464540; Fri, 06 Nov 2020 07:27:44 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v2 3/4] linux-user/sparc: Don't restore %g7 in sparc64_set_context() Date: Fri, 6 Nov 2020 15:27:37 +0000 Message-Id: <20201106152738.26026-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201106152738.26026-1-peter.maydell@linaro.org> References: <20201106152738.26026-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::441; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x441.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Giuseppe Musacchio , Mark Cave-Ayland , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" The kernel does not restore the g7 register in sparc64_set_context(); neither should we. (We still save it in sparc64_get_context().) Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- linux-user/sparc/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index 43dcd137f51..ed32c7abd17 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -447,7 +447,7 @@ void sparc64_set_context(CPUSPARCState *env) __get_user(env->gregs[4], (&(*grp)[SPARC_MC_G4])); __get_user(env->gregs[5], (&(*grp)[SPARC_MC_G5])); __get_user(env->gregs[6], (&(*grp)[SPARC_MC_G6])); - __get_user(env->gregs[7], (&(*grp)[SPARC_MC_G7])); + /* Skip g7 as that's the thread register in userspace */ =20 /* * Note that unlike the kernel, we didn't need to mess with the --=20 2.20.1 From nobody Mon May 6 03:36:54 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1604676553; cv=none; d=zohomail.com; s=zohoarc; b=S24Y9Lkk/7pzJWltw2geKrOdi7dzvvglwIO4+CwMsPBZHtijFGbL1xWPthDTMb0oIxPLeQtcEmgUVQytMX0oIhEdNSTYQn5ZZ3ZF2ykM+599bhbQF+pFaXHW/fke3cr0uKpsVOQ218IjSX11ciZG40jVjRDb9MmG6y4Ag9LJrhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1604676553; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eM8x5tgPhhwtpKk11UYKbf2bCBwlq92NBJB9ED/iCiI=; b=QZRu/zst7swi46L9KdMe47FqEnSZx2PjdniU1IWI8jA561bazqIcmBymjsDniNHXRwWra+z3aAGNqXkRK7hE+AmMWXWy1IcdMxIPgoYmjPZXoyRAMJaQ9XtpWG6gWnmTuCAASCWaMpd9TeimEhtnGUfmzYH8ropWkTaoBoNJyr4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1604676553291140.30296798316658; Fri, 6 Nov 2020 07:29:13 -0800 (PST) Received: from localhost ([::1]:41428 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kb3fs-000554-5C for importer@patchew.org; Fri, 06 Nov 2020 10:29:12 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38118) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kb3eX-0003RS-5x for qemu-devel@nongnu.org; Fri, 06 Nov 2020 10:27:49 -0500 Received: from mail-wr1-x442.google.com ([2a00:1450:4864:20::442]:33751) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kb3eV-0001IO-BU for qemu-devel@nongnu.org; Fri, 06 Nov 2020 10:27:48 -0500 Received: by mail-wr1-x442.google.com with SMTP id b8so1751577wrn.0 for ; Fri, 06 Nov 2020 07:27:46 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id 109sm2723462wra.29.2020.11.06.07.27.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Nov 2020 07:27:45 -0800 (PST) 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 :mime-version:content-transfer-encoding; bh=eM8x5tgPhhwtpKk11UYKbf2bCBwlq92NBJB9ED/iCiI=; b=qVOykowXcnFt3XDdXBfLj5qVwOxHqvzr0YpxBQuGii688VyRqxvozj8Q6xb1RTYOiK wRtwyhPxaZQf44+9zMf4BKZ8P2cX8Ueq7JrxPEu1xzQEVsMnLlMJLT39LomA3EbRGTGK o4XRLRqwAgC+UPRPQWXWg84+gxMnq9kl1qKwLR8Km9PUh/tx2Wko1B27zPhBKdOOODR/ 3rlfdDdj6c2jyJYBMWDel4LWzR7V+O55V+557Im3BkRuK9XYmjyGErfCFcYgugiRmEVk g4LGUIyM/stAr8Eun5vuOBY0Ex8Reu0Ys43GhneSSfCg5QJJa0VPH7Ezp7VCYD4B8Lq2 Ondg== 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:mime-version:content-transfer-encoding; bh=eM8x5tgPhhwtpKk11UYKbf2bCBwlq92NBJB9ED/iCiI=; b=ALDqRDUecb6S8RVUfN8qgABfcgrdR9wGvU0Lt7nO56kgjfityEhbCAjUcdIDjuy0rw elKdJOtFKTX1WN4AcuS4D+3KOS7LyiWRrqDGR8hrFI1gU20kErwnz6NAN1/Vnu/9ebEF 4DLga/CoYlAl/hIMyHKr9Edc+j9A3qMybMA4O6B29j9TAXS97PhrhabzCBQ1Q4eR3A7w bOaxBtYxn/o/2UGVfIDPjpJ5T0WwgeS+iIzyvtL0h9PslsE3O3/gEfqlzOpYD2jOifPW qhJwLqiT6ueA6KQNWQRtIR3T6I51Xyn1Sor6JQSv85SG4Ln0XGlToDC6QObs3uaUpkMB PjwQ== X-Gm-Message-State: AOAM532lvm1S0RX8oNoMHFP190o8GV1wxB31WHA4ZYkrA7OD8nPBDHYs Cp17tgjeQ1Txb0KEiZP2RqNxeMuuBNdELQ== X-Google-Smtp-Source: ABdhPJzXNrJPR+9Yl/QBzKIu6WIk2BEY0s4Rhxwlvv4Sh5prpg0SOlQVjbr1Fp/plC4y+0gQAZ8Yyg== X-Received: by 2002:adf:8bcc:: with SMTP id w12mr3555152wra.157.1604676465794; Fri, 06 Nov 2020 07:27:45 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PATCH v2 4/4] linux-user/sparc: Handle tstate in sparc64_get/set_context() Date: Fri, 6 Nov 2020 15:27:38 +0000 Message-Id: <20201106152738.26026-5-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201106152738.26026-1-peter.maydell@linaro.org> References: <20201106152738.26026-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::442; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x442.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Giuseppe Musacchio , Mark Cave-Ayland , Richard Henderson , Laurent Vivier Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Correctly implement save/restore of the tstate field in sparc64_get_context() and sparc64_set_context(): * Don't use the CWP value from the guest in set_context * Construct and save a tstate value rather than leaving it as zero in get_context To do this we factor out the "calculate TSTATE value from CPU state" code from sparc_cpu_do_interrupt() into its own sparc64_tstate() function; that in turn requires us to move some of the function prototypes out from inside a CPU_NO_IO_DEFS ifdef guard. Signed-off-by: Peter Maydell Reviewed-by: Richard Henderson --- target/sparc/cpu.h | 24 ++++++++++++++++++++---- linux-user/sparc/signal.c | 7 +++---- target/sparc/int64_helper.c | 5 +---- 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 277254732b9..4b2290650be 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -608,10 +608,6 @@ target_ulong cpu_get_psr(CPUSPARCState *env1); void cpu_put_psr(CPUSPARCState *env1, target_ulong val); void cpu_put_psr_raw(CPUSPARCState *env1, target_ulong val); #ifdef TARGET_SPARC64 -target_ulong cpu_get_ccr(CPUSPARCState *env1); -void cpu_put_ccr(CPUSPARCState *env1, target_ulong val); -target_ulong cpu_get_cwp64(CPUSPARCState *env1); -void cpu_put_cwp64(CPUSPARCState *env1, int cwp); void cpu_change_pstate(CPUSPARCState *env1, uint32_t new_pstate); void cpu_gl_switch_gregs(CPUSPARCState *env, uint32_t new_gl); #endif @@ -829,4 +825,24 @@ static inline bool tb_am_enabled(int tb_flags) #endif } =20 +#ifdef TARGET_SPARC64 +/* win_helper.c */ +target_ulong cpu_get_ccr(CPUSPARCState *env1); +void cpu_put_ccr(CPUSPARCState *env1, target_ulong val); +target_ulong cpu_get_cwp64(CPUSPARCState *env1); +void cpu_put_cwp64(CPUSPARCState *env1, int cwp); + +static inline uint64_t sparc64_tstate(CPUSPARCState *env) +{ + uint64_t tstate =3D (cpu_get_ccr(env) << 32) | + ((env->asi & 0xff) << 24) | ((env->pstate & 0xf3f) << 8) | + cpu_get_cwp64(env); + + if (env->def.features & CPU_FEATURE_GL) { + tstate |=3D (env->gl & 7ULL) << 40; + } + return tstate; +} +#endif + #endif diff --git a/linux-user/sparc/signal.c b/linux-user/sparc/signal.c index ed32c7abd17..a6c7c7664a2 100644 --- a/linux-user/sparc/signal.c +++ b/linux-user/sparc/signal.c @@ -438,9 +438,9 @@ void sparc64_set_context(CPUSPARCState *env) env->npc =3D npc; __get_user(env->y, &((*grp)[SPARC_MC_Y])); __get_user(tstate, &((*grp)[SPARC_MC_TSTATE])); + /* Honour TSTATE_ASI, TSTATE_ICC and TSTATE_XCC only */ env->asi =3D (tstate >> 24) & 0xff; - cpu_put_ccr(env, tstate >> 32); - cpu_put_cwp64(env, tstate & 0x1f); + cpu_put_ccr(env, (tstate >> 32) & 0xff); __get_user(env->gregs[1], (&(*grp)[SPARC_MC_G1])); __get_user(env->gregs[2], (&(*grp)[SPARC_MC_G2])); __get_user(env->gregs[3], (&(*grp)[SPARC_MC_G3])); @@ -557,8 +557,7 @@ void sparc64_get_context(CPUSPARCState *env) } } =20 - /* XXX: tstate must be saved properly */ - // __put_user(env->tstate, &((*grp)[SPARC_MC_TSTATE])); + __put_user(sparc64_tstate(env), &((*grp)[SPARC_MC_TSTATE])); __put_user(env->pc, &((*grp)[SPARC_MC_PC])); __put_user(env->npc, &((*grp)[SPARC_MC_NPC])); __put_user(env->y, &((*grp)[SPARC_MC_Y])); diff --git a/target/sparc/int64_helper.c b/target/sparc/int64_helper.c index f3e7f32de61..735668f5006 100644 --- a/target/sparc/int64_helper.c +++ b/target/sparc/int64_helper.c @@ -131,9 +131,7 @@ void sparc_cpu_do_interrupt(CPUState *cs) } tsptr =3D cpu_tsptr(env); =20 - tsptr->tstate =3D (cpu_get_ccr(env) << 32) | - ((env->asi & 0xff) << 24) | ((env->pstate & 0xf3f) << 8) | - cpu_get_cwp64(env); + tsptr->tstate =3D sparc64_tstate(env); tsptr->tpc =3D env->pc; tsptr->tnpc =3D env->npc; tsptr->tt =3D intno; @@ -148,7 +146,6 @@ void sparc_cpu_do_interrupt(CPUState *cs) } =20 if (env->def.features & CPU_FEATURE_GL) { - tsptr->tstate |=3D (env->gl & 7ULL) << 40; cpu_gl_switch_gregs(env, env->gl + 1); env->gl++; } --=20 2.20.1