From nobody Sun Nov 24 06:58:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1725905260; cv=none; d=zohomail.com; s=zohoarc; b=DIg8x+Ouwz8nDTdgXr8JiiZebK9FQbD55rHs6xzC2MIe1djFk0I2qQBLB9J+cPWzStGJEwZrE8Q3zuRVLZs64BmPjzl7fWEAdoAoz/lSnmQSyBWzxg1PugQXbTFznSjtqmxnNxplKO6s/ZOAtNwzyoGnYOKYIiE9y7zbsz/47Ko= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725905260; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9bTU4NPeU0IiujACkK1L0VqKDZix8t/nL4Zz2A2ptJA=; b=iUJETj0KIHn0TH3N99YctJ9mk6cYni70wqbqAY21pMKsnEJYBNXYk8keNylE6HSOKwxCmLsiZb3abrK/6UJ3jNq3VtCU8JyoMV4IdZP1vktHA8M4cXf3rmUECYS9PHdu1lqr/sFO94A/qek1RP/eS0OfKwSK8IHJCJkxn+q7pCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725905260241211.40394029644858; Mon, 9 Sep 2024 11:07:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sninI-0003is-I9; Mon, 09 Sep 2024 14:07:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sninG-0003Sa-LC for qemu-devel@nongnu.org; Mon, 09 Sep 2024 14:07:18 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sninE-0001wV-M1 for qemu-devel@nongnu.org; Mon, 09 Sep 2024 14:07:18 -0400 Received: by mail-pf1-x429.google.com with SMTP id d2e1a72fcca58-717911ef035so3631499b3a.3 for ; Mon, 09 Sep 2024 11:07:16 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc84efsm25431b3a.8.2024.09.09.11.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 11:07:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725905235; x=1726510035; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9bTU4NPeU0IiujACkK1L0VqKDZix8t/nL4Zz2A2ptJA=; b=M17CQLGHfEit8ROPH0zp5HTW4R4S+g8AtOact8nr0aQlBooshd73njhDNxmu02PYP5 MYPUvXLPp01tWYThOZhASAzr5ea02bAbham1Oxyf1GG3/6zC9a/ycTNEXmK7LLTLHSZn BSL41VK7m/5MQkNdKx3be/MezKtDsXu9lo2QDFSnCjMoheumX35lp3/6bm78JgpqiORp Go1WPnZuvCQG9QLREQ0LGxFDxnNCiz9soBzqkKQ2x5w68FSHFU7N30DrcQW5yU9L8QQ7 GxKeC7BTB+BSMqpU/NysU1YSp5UW+774pV0MxJL2jJSH+lc2zgc4pgOIdwBIh5h+MtRw sNUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725905235; x=1726510035; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9bTU4NPeU0IiujACkK1L0VqKDZix8t/nL4Zz2A2ptJA=; b=i1n0r5iD7/YU6jbQizkawqaB69pzpEOh9V3xug6f3RJaYq/xaZ3tPbI7KPyJLw+06x mwTF9JDKOr96LzDtFo968guXlE+9ZPadWwf9rZexs0G2A8skiLuqGEEHcJ29+0/LuZ5T 75OMTHzTevM+W4sDG10xtBQ/ZekGZC1kuEOHsr/pdadBXK1hxq0v/8F2nciiWHb4EO/O 8oYhPKaeiGLQHsziOMfeQZ15vkalGZs1+bxFN0XRiU9aekwMTig4vVHn6BoAvMxGWFtM e5TmMWEZpW1m6r5oZe9I9nwr/PltCJ7oVfAHbB17nIytFCUkjy1LbTvyr1nF4pJHQM7v rTGQ== X-Gm-Message-State: AOJu0YyDYWnP4+TLUe45ba6ECa5aRYpk7g3TwG9ELM/w3QwndJEboIRR N7a0HBMRxzZNOhRVXsuHEZ9nYuGIPhfdHarJiDtCQb8FI9MwnG4HusKPTVIW9ypCSdLfnnBedIg s X-Google-Smtp-Source: AGHT+IGAvlLfeJH2JbEGSE4NK5FWHP0l1m2WbdpuBPA2zBC/k+T3mG7QfWdLxgF8GyzDmAX6o53G1g== X-Received: by 2002:a05:6a00:928a:b0:717:9897:1405 with SMTP id d2e1a72fcca58-718d5ee05c1mr12851544b3a.17.1725905234878; Mon, 09 Sep 2024 11:07:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, chauser@pullman.com, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v4 1/5] target/sparc: Add FQ and FSR.QNE Date: Mon, 9 Sep 2024 11:07:08 -0700 Message-ID: <20240909180712.651651-2-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240909180712.651651-1-richard.henderson@linaro.org> References: <20240909180712.651651-1-richard.henderson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2607:f8b0:4864:20::429; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x429.google.com 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1725905260641116600 From: Carl Hauser Add support for, and migrate, a single-entry fp instruction queue for sparc32. Signed-off-by: Carl Hauser [rth: Split from a larger patch; adjust representation with union; add migration state] Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 Acked-by: Mark Cave-Ayland --- target/sparc/cpu.h | 22 ++++++++++++++++++++++ target/sparc/fop_helper.c | 4 ++++ target/sparc/machine.c | 25 +++++++++++++++++++++++++ 3 files changed, 51 insertions(+) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index dfd9512a21..9f2bc44722 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -184,6 +184,8 @@ enum { #define FSR_FTT_SEQ_ERROR (4ULL << 14) #define FSR_FTT_INVAL_FPR (6ULL << 14) =20 +#define FSR_QNE (1ULL << 13) + #define FSR_FCC0_SHIFT 10 #define FSR_FCC1_SHIFT 32 #define FSR_FCC2_SHIFT 34 @@ -438,6 +440,26 @@ struct CPUArchState { uint32_t fsr_cexc_ftt; /* cexc, ftt */ uint32_t fcc[TARGET_FCCREGS]; /* fcc* */ =20 +#if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) + /* + * Single-element FPU fault queue, with address and insn, + * packaged into the double-word with which it is stored. + */ + uint32_t fsr_qne; /* qne */ + union { + uint64_t d; + struct { +#if HOST_BIG_ENDIAN + uint32_t addr; + uint32_t insn; +#else + uint32_t insn; + uint32_t addr; +#endif + } s; + } fq; +#endif + CPU_DoubleU fpr[TARGET_DPREGS]; /* floating point registers */ uint32_t cwp; /* index of current register window (extracted from PSR) */ diff --git a/target/sparc/fop_helper.c b/target/sparc/fop_helper.c index 0b30665b51..b6692382b3 100644 --- a/target/sparc/fop_helper.c +++ b/target/sparc/fop_helper.c @@ -545,6 +545,8 @@ target_ulong cpu_get_fsr(CPUSPARCState *env) fsr |=3D (uint64_t)env->fcc[1] << FSR_FCC1_SHIFT; fsr |=3D (uint64_t)env->fcc[2] << FSR_FCC2_SHIFT; fsr |=3D (uint64_t)env->fcc[3] << FSR_FCC3_SHIFT; +#elif !defined(CONFIG_USER_ONLY) + fsr |=3D env->fsr_qne; #endif =20 /* VER is kept completely separate until re-assembly. */ @@ -591,6 +593,8 @@ void cpu_put_fsr(CPUSPARCState *env, target_ulong fsr) env->fcc[1] =3D extract64(fsr, FSR_FCC1_SHIFT, 2); env->fcc[2] =3D extract64(fsr, FSR_FCC2_SHIFT, 2); env->fcc[3] =3D extract64(fsr, FSR_FCC3_SHIFT, 2); +#elif !defined(CONFIG_USER_ONLY) + env->fsr_qne =3D fsr & FSR_QNE; #endif =20 set_fsr_nonsplit(env, fsr); diff --git a/target/sparc/machine.c b/target/sparc/machine.c index 48e0cf22f3..222e5709c5 100644 --- a/target/sparc/machine.c +++ b/target/sparc/machine.c @@ -143,6 +143,24 @@ static const VMStateInfo vmstate_xcc =3D { .get =3D get_xcc, .put =3D put_xcc, }; +#else +static bool fq_needed(void *opaque) +{ + SPARCCPU *cpu =3D opaque; + return cpu->env.fsr_qne; +} + +static const VMStateDescription vmstate_fq =3D { + .name =3D "cpu/fq", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D fq_needed, + .fields =3D (const VMStateField[]) { + VMSTATE_UINT32(env.fq.s.addr, SPARCCPU), + VMSTATE_UINT32(env.fq.s.insn, SPARCCPU), + VMSTATE_END_OF_LIST() + }, +}; #endif =20 static int cpu_pre_save(void *opaque) @@ -265,4 +283,11 @@ const VMStateDescription vmstate_sparc_cpu =3D { #endif VMSTATE_END_OF_LIST() }, +#ifndef TARGET_SPARC64 + .subsections =3D (const VMStateDescription * const []) { + &vmstate_fq, + NULL + }, +#endif + }; --=20 2.43.0 From nobody Sun Nov 24 06:58:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1725905266; cv=none; d=zohomail.com; s=zohoarc; b=A2qYoprKh9h34xpTzWODABaKTkPItAOMxyDf4fiyjmw6NAn7+5/ASMNMa9khnV7LUpAMF2Vyp4iMxahH+4Nmfh6gq9Ee14LXZF9a7KFVaSYwUQFjZpPDIf0cCrOGuhtL6mh09GpowaVAUf8n9jvuR4UfsHwj3fzD824CpSaUGpg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725905266; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=bKKi0pMicJbraFe0EvfP4hRpwt+nXYvkFQlWAnrDKc0=; b=mpvnArf2d6FITt13m4cWKAU21nBZSlB9h7itviOrVuURZ4lb+UJm5p1B7hE8XPKdi8cQhIRScwX2oliqMflMZ/XnMe23vaNAwhQLh5OzsRlQv3hYgU4XwgsJUEvp4NdQYmWM/XE1hE7JugNtb3M+Z2/gjGz5vJs5mlLYaEVDVLo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172590526635393.35092597969219; Mon, 9 Sep 2024 11:07:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sninJ-0003r4-Fo; Mon, 09 Sep 2024 14:07:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sninI-0003gy-6E for qemu-devel@nongnu.org; Mon, 09 Sep 2024 14:07:20 -0400 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sninF-0001wd-OC for qemu-devel@nongnu.org; Mon, 09 Sep 2024 14:07:19 -0400 Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-656d8b346d2so2936553a12.2 for ; Mon, 09 Sep 2024 11:07:17 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc84efsm25431b3a.8.2024.09.09.11.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 11:07:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725905236; x=1726510036; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bKKi0pMicJbraFe0EvfP4hRpwt+nXYvkFQlWAnrDKc0=; b=akUttigd8EVsy6ByCyyfjFGudFoXT+6d3PaKCWyr/tLitlyHohOacXZX653VF2J7pW QqROtvbidu14tmj4wxCuX8ToybH5xhRnfuheCJlEfQbuxD1kLT+GnVxJFlu5OKwcN4wN aAUPh4NwUYWmt0GZ7l98+/DG2ckFqGDgop3TfG806PCOP2AWV9S0fo3u/B3ECESRwsEP URIsYyXwofz3NLYMgr3nq0ty/7/in3ya9QGdOQVSQmpVa+sHZdIlrf8zAuX4vOJ3p/vT rlyjtFqlEuijTFbNXyJiMzCAdyfoPRnqAxGHuXVYJ5eD2a5JSrXwEW511YzGj2IROOFM 57KA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725905236; x=1726510036; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bKKi0pMicJbraFe0EvfP4hRpwt+nXYvkFQlWAnrDKc0=; b=WVmKHRNc7LNYbNtgVM3hMGrYtBhLaj4JO3XKuNfk+2W+fKZla+mtHyLv4gOE9P7Scs HUhCxfnF2fB3JjWSSyGOlzNSDmdhEaLD+4jRgyTYMqjiM/sTnS8NcTygntVG31KhA1Jy QPS2QyfcL1ycLX4VkqiKXx10rUX0iUxf7HAwB7u4Dm/F/edPaXuXqGCXaEa3kcoXYPTr b8VaOLrmHxwK3ZRziKMfJ/2JHMiBNUa0Qk9SbTV0NU4Tzq2JK+fufESQvjpgXsQMLZA5 Hn5s+dZMH+aw+OKuah7gRRJFfeMHj98v1Ov2e5bNHacPlwSPMcUd1Y3tSR+wKz8lbCrU 16Pw== X-Gm-Message-State: AOJu0Ywdk2dUfWE/tEUMlW3EoMYgeu9yMEBPVXTwhhNzjYH4qssYOYrx PxHOYpXJbvShKywGWZ/GewyNPeN2zJyoGIsvyApEkSSXcxNXwMt59HjRKT1C2UjLJwobesWUmmf d X-Google-Smtp-Source: AGHT+IFsVeeZiS/sawRrbLTH9LqJb/j426q/xV7fUshPpfqBz8Bt2U0zif9hrBV6p6uw6sunm86Hng== X-Received: by 2002:a05:6a21:4d81:b0:1cf:43c6:d53f with SMTP id adf61e73a8af0-1cf43c6d637mr3376136637.19.1725905235888; Mon, 09 Sep 2024 11:07:15 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, chauser@pullman.com Subject: [PATCH v4 2/5] target/sparc: Populate sparc32 FQ when raising fp exception Date: Mon, 9 Sep 2024 11:07:09 -0700 Message-ID: <20240909180712.651651-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240909180712.651651-1-richard.henderson@linaro.org> References: <20240909180712.651651-1-richard.henderson@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=2607:f8b0:4864:20::52b; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x52b.google.com 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1725905266689116600 Content-Type: text/plain; charset="utf-8" From: Carl Hauser Implement a single instruction floating point queue, populated while delivering an fp exception. Signed-off-by: Carl Hauser [rth: Split from a larger patch] Signed-off-by: Richard Henderson Acked-by: Mark Cave-Ayland --- target/sparc/int32_helper.c | 40 +++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/target/sparc/int32_helper.c b/target/sparc/int32_helper.c index 6b7d65b031..f2dd8bcb2e 100644 --- a/target/sparc/int32_helper.c +++ b/target/sparc/int32_helper.c @@ -21,10 +21,10 @@ #include "qemu/main-loop.h" #include "cpu.h" #include "trace.h" +#include "exec/cpu_ldst.h" #include "exec/log.h" #include "sysemu/runstate.h" =20 - static const char * const excp_names[0x80] =3D { [TT_TFAULT] =3D "Instruction Access Fault", [TT_ILL_INSN] =3D "Illegal Instruction", @@ -116,22 +116,9 @@ void sparc_cpu_do_interrupt(CPUState *cs) =20 qemu_log("%6d: %s (v=3D%02x)\n", count, name, intno); log_cpu_state(cs, 0); -#if 0 - { - int i; - uint8_t *ptr; - - qemu_log(" code=3D"); - ptr =3D (uint8_t *)env->pc; - for (i =3D 0; i < 16; i++) { - qemu_log(" %02x", ldub(ptr + i)); - } - qemu_log("\n"); - } -#endif count++; } -#if !defined(CONFIG_USER_ONLY) +#ifndef CONFIG_USER_ONLY if (env->psret =3D=3D 0) { if (cs->exception_index =3D=3D 0x80 && env->def.features & CPU_FEATURE_TA0_SHUTDOWN) { @@ -143,6 +130,29 @@ void sparc_cpu_do_interrupt(CPUState *cs) } return; } + if (intno =3D=3D TT_FP_EXCP) { + /* + * The sparc32 fpu has three states related to exception handling. + * The FPop that signals an exception transitions from fp_execute + * to fp_exception_pending. A subsequent FPop transitions from + * fp_exception_pending to fp_exception, which forces the trap. + * + * If the queue is not empty, this trap is due to execution of an + * illegal FPop while in fp_exception state. Here we are to + * re-enter fp_exception_pending state without queuing the insn. + * + * We do not model the fp_exception_pending state, but instead + * skip directly to fp_exception state. We advance pc/npc to + * mimic delayed trap delivery as if by the subsequent insn. + */ + if (!env->fsr_qne) { + env->fsr_qne =3D FSR_QNE; + env->fq.s.addr =3D env->pc; + env->fq.s.insn =3D cpu_ldl_code(env, env->pc); + } + env->pc =3D env->npc; + env->npc =3D env->npc + 4; + } #endif env->psret =3D 0; cwp =3D cpu_cwp_dec(env, env->cwp - 1); --=20 2.43.0 From nobody Sun Nov 24 06:58:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1725905256; cv=none; d=zohomail.com; s=zohoarc; b=ROlFj9wFKX+to877fE0oKgD1wsJDR1QH7dKZMvEGbgZ0Q+kV7KRIivSedHhEGHrT5lc1n2PBsv+omVIHhsEOjtAXdpImus38E9vmMBcsC3AHpWMXF/Py9zfLgYDkrxirVgYTBLoWj/iJ6qnuZMXrDVkBTZqJ+FSj/d8D6sCg3Qw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725905256; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=K5QfoW0VwajlTQd3ELmUEuobbsHpYmua9JmMsJd9x1U=; b=OFyhAOzK3AKM7Wo4dH1AL9U/U3dnihY8TtMaSWocuFjDvItVf3gvqVn0DlZRPDQMG4tt+dc7CbYF6VOoV+VKSV0gqAv3gd9hgmteDU5wIhEfsF9oV/iwECMuG+h6OM2xoNDMWdDHv5vSfnhFZ9lsTOF96GqI8sorAAxE3jb9JtM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725905256489853.7081659554569; Mon, 9 Sep 2024 11:07:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sninJ-0003vM-RX; Mon, 09 Sep 2024 14:07:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sninI-0003jD-EM for qemu-devel@nongnu.org; Mon, 09 Sep 2024 14:07:20 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sninG-0001wj-8q for qemu-devel@nongnu.org; Mon, 09 Sep 2024 14:07:20 -0400 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-718d962ad64so3141489b3a.0 for ; Mon, 09 Sep 2024 11:07:17 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc84efsm25431b3a.8.2024.09.09.11.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 11:07:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725905237; x=1726510037; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K5QfoW0VwajlTQd3ELmUEuobbsHpYmua9JmMsJd9x1U=; b=xhVWo18AbbAe4y00+4ZdWfoYUEE1QQeGW5Y7EOtax6xOoUY/5RoI73LSdZ+AGaC4gf TVexuCeTSokLMnq+GGfUD8OaGQ+HYB4KgVRJlydmZLFAvOKuYzYl/0a+8P0BmBcaIrsT EKLQmFA13AGLU2IZOH4I6d73AMH+vphgP2qoGQzjfLvyNqc2kzjGANFFSTb6sHRIwO+2 n0HewXIbvuASucY4OQIDep8jQ/OLS4SVscq7WUYts8P1o0e4UtZHeOFRK/EJDjQeHNR5 Q4wdC8CsDVDjRf5mLm1D7Q3WT2P+JMVn1x3DbZhwqRr5hwWOiaLcNwO4qOz88AZqT1cr FKRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725905237; x=1726510037; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K5QfoW0VwajlTQd3ELmUEuobbsHpYmua9JmMsJd9x1U=; b=a+Fnzjs8vo3xY+tLJnSLPhyqu58OxDXgo1KUuZ3Am4qaWAMhKphBrBxDI6TBY6p7fZ nOOu+REN+RxLEPSjYngt3qpG6t5wXBpF8PIx5fm8kFm1KeMJb/NhmrhPUIk86K+o9rQe 7AduD8lybpIEiczxrZcbnP8ywQN+m1979v3W7dBy+j/6Yp7dN9S4sXgDfdkA41OUXLkf K1J/RlHZAhEvW4pXRECwTsm9ttQr88TIbHQ7K1LpRn0cKh+S1aTxxBqUAUCAhEtvPBGE igff4D1W70RPQFzF5euLRsMqwYQ27UsyvHsB0l2AUQHArOxhcSeAzcE/LRmAzqogxpf2 UhJQ== X-Gm-Message-State: AOJu0YwvBKrTtwsSBULGTe0sk9AQvRlSAEO3N1A7cVVkPam/SUOxw4ZC rKSXRjs75W1dH3HgZBezm7La+c7llLy/LuMsmbyNosaXNL7N01PAfuaBuFfpOaXnKOV33zUjIB3 + X-Google-Smtp-Source: AGHT+IFZ+++RZnyC73zGY5x8eYgcCbkH3dUP9WNDvLJNfFW++4MZKnixY9HpWFryJn8bO/BzIP92xg== X-Received: by 2002:a05:6a00:914c:b0:70d:2892:402b with SMTP id d2e1a72fcca58-718d5e0f22cmr15600522b3a.7.1725905236673; Mon, 09 Sep 2024 11:07:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, chauser@pullman.com Subject: [PATCH v4 3/5] target/sparc: Add FSR_QNE to tb_flags Date: Mon, 9 Sep 2024 11:07:10 -0700 Message-ID: <20240909180712.651651-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240909180712.651651-1-richard.henderson@linaro.org> References: <20240909180712.651651-1-richard.henderson@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=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.google.com 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1725905258702116600 Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Acked-by: Mark Cave-Ayland Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/sparc/cpu.h | 8 +++++++- target/sparc/translate.c | 10 +++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 9f2bc44722..f517e5a383 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -744,6 +744,7 @@ trap_state* cpu_tsptr(CPUSPARCState* env); #define TB_FLAG_AM_ENABLED (1 << 5) #define TB_FLAG_SUPER (1 << 6) #define TB_FLAG_HYPER (1 << 7) +#define TB_FLAG_FSR_QNE (1 << 8) #define TB_FLAG_ASI_SHIFT 24 =20 static inline void cpu_get_tb_cpu_state(CPUSPARCState *env, vaddr *pc, @@ -775,7 +776,12 @@ static inline void cpu_get_tb_cpu_state(CPUSPARCState = *env, vaddr *pc, if (env->psref) { flags |=3D TB_FLAG_FPU_ENABLED; } -#endif +#ifndef CONFIG_USER_ONLY + if (env->fsr_qne) { + flags |=3D TB_FLAG_FSR_QNE; + } +#endif /* !CONFIG_USER_ONLY */ +#endif /* TARGET_SPARC64 */ *pflags =3D flags; } =20 diff --git a/target/sparc/translate.c b/target/sparc/translate.c index c803e8d1ba..eb0158a11d 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -185,6 +185,8 @@ typedef struct DisasContext { bool supervisor; #ifdef TARGET_SPARC64 bool hypervisor; +#else + bool fsr_qne; #endif #endif =20 @@ -5596,13 +5598,15 @@ static void sparc_tr_init_disas_context(DisasContex= tBase *dcbase, CPUState *cs) dc->address_mask_32bit =3D tb_am_enabled(dc->base.tb->flags); #ifndef CONFIG_USER_ONLY dc->supervisor =3D (dc->base.tb->flags & TB_FLAG_SUPER) !=3D 0; +# ifdef TARGET_SPARC64 + dc->hypervisor =3D (dc->base.tb->flags & TB_FLAG_HYPER) !=3D 0; +# else + dc->fsr_qne =3D (dc->base.tb->flags & TB_FLAG_FSR_QNE) !=3D 0; +# endif #endif #ifdef TARGET_SPARC64 dc->fprs_dirty =3D 0; dc->asi =3D (dc->base.tb->flags >> TB_FLAG_ASI_SHIFT) & 0xff; -#ifndef CONFIG_USER_ONLY - dc->hypervisor =3D (dc->base.tb->flags & TB_FLAG_HYPER) !=3D 0; -#endif #endif /* * if we reach a page boundary, we stop generation so that the --=20 2.43.0 From nobody Sun Nov 24 06:58:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1725905271; cv=none; d=zohomail.com; s=zohoarc; b=C2R3Qb6WHGviI0XpF0sOuIYPQqjrFPvgJYUQMcsYiofl0kEFn2XFtfHsSjPfZRb+ZW79eGY0YPdQtD7Or+LCn+7cJFl2z2DlLvevg/97fWQW9PExKsw8QA0PgTLd3bi+je46jsLf4JJ6vOiEZYBccR98gePIpdh+zhXq0suFyhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725905271; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=ms6V/0srD/nMNjMgzm5FTu/ZmmO4rz8+JUXESCUp5U0=; b=iVTp0qcsH58pJQTaRff0YLh3ZE41K4sNeO3auP9Xf2Ya9eSxyXYaPUn64xXor0eqjv6ZHcqlCAvgetF2ez/4KJ433pgDWqJO6m7xwhksKO333nnY9zUC0YMShlpRcbTdlD7sNEncxF80LQHvY8a7LPFTf6Xzbs4G4Fo8Kdcmeg8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1725905271259247.8144880186477; Mon, 9 Sep 2024 11:07:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sninL-0004Bp-PO; Mon, 09 Sep 2024 14:07:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sninJ-0003pN-3t for qemu-devel@nongnu.org; Mon, 09 Sep 2024 14:07:21 -0400 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sninH-0001wt-4z for qemu-devel@nongnu.org; Mon, 09 Sep 2024 14:07:20 -0400 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-7c3d8f260easo2238172a12.1 for ; Mon, 09 Sep 2024 11:07:18 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc84efsm25431b3a.8.2024.09.09.11.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 11:07:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725905237; x=1726510037; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ms6V/0srD/nMNjMgzm5FTu/ZmmO4rz8+JUXESCUp5U0=; b=k5iD4GTdAdXAiiLPzAmkSWfMvci2c80ftkhjWu141LhbDiEvxZ8qWP3kZcmGRottcS I5veNyR4KF2Sbhvt/M6TJiJxaz6aTHPvpVNEjNpwpF1Gj6RTNNym1NPI5g159GQS4Pro FHld5wbJsfR3kNC8bfgkXolALE4IoX8araQJg7ZUqde76xm3ojA3sy6MNq92mxVGAHLm 3Lx0nXVbubFI7Otj+c24CkgL0bCan7YGMEigbLayblm0WvNsUIQwVmSMlo50UgJYK2Rp ttPWEqL0Vqt7olCgPrwHJje4NC++OpJXPLDcrSmPfI+eHsDUMt5vek/a0fxsg242bqdT C5FQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725905237; x=1726510037; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ms6V/0srD/nMNjMgzm5FTu/ZmmO4rz8+JUXESCUp5U0=; b=orqphFTLbFPId1oG8tCqYTuPnTDXRYXXZe+guWFtpllaLQh3VYSOpnQFwPu5oe8tRA FkxsukEz7kdK400Omy74oIYnlhZZF059hHRSYS7oM3J5Y+gda//rlS2zKq7Vzfbdcfp6 3l/kZjxpYyq+XaZW1MwNtbR4LNNmfddiZmyTmwWtZxcqmSN26J5TaBWdUZcbgdedERLW 8u98UCHVn3cYK4w4/kG56NMMDvOt4mTRKHA1/hfuevRvgwDKuRw1w+XyuxZDRNKA78K3 mWP9wm1msBJXZCQTPaaUPFgximnCpt/eOK76UL1wCb8jtnQ8XSBFUh7aHn7cr0cF7/Xv ySYg== X-Gm-Message-State: AOJu0YwRA7ac9FVBagRudAwsJwN1pol9euvlxHzuSy0NgEw3nnA8/9Dy 2k8f9N1bWre2EHFk9nTvepxACvFfnt4WRde1Zl0nHRAzfU6eRLfWqp9TVNvKzVWiskawdcUZEcW i X-Google-Smtp-Source: AGHT+IEaj6OGrZFMuKkDuRLaQkEn5HNHKgNINiktDbKu7QM6w+nZ3MD/OViKnXdVt7hTjaYjjsG7GQ== X-Received: by 2002:a05:6a21:7702:b0:1ca:cd6d:3a26 with SMTP id adf61e73a8af0-1cf2a047b7fmr7461115637.27.1725905237501; Mon, 09 Sep 2024 11:07:17 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, chauser@pullman.com Subject: [PATCH v4 4/5] target/sparc: Implement STDFQ Date: Mon, 9 Sep 2024 11:07:11 -0700 Message-ID: <20240909180712.651651-5-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240909180712.651651-1-richard.henderson@linaro.org> References: <20240909180712.651651-1-richard.henderson@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=2607:f8b0:4864:20::532; envelope-from=richard.henderson@linaro.org; helo=mail-pg1-x532.google.com 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1725905272736116600 Content-Type: text/plain; charset="utf-8" Invalid encoding of addr should raise TT_ILL_INSN, so check before supervisor, which might raise TT_PRIV_INSN. Clear QNE after execution. Signed-off-by: Richard Henderson Acked-by: Mark Cave-Ayland --- target/sparc/translate.c | 28 ++++++++++++++++++++++++++-- target/sparc/insns.decode | 2 +- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index eb0158a11d..b80f071533 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -4531,17 +4531,41 @@ TRANS(STQFA, 64, do_st_fpr, a, MO_128) =20 static bool trans_STDFQ(DisasContext *dc, arg_STDFQ *a) { + TCGv addr; + if (!avail_32(dc)) { return false; } + addr =3D gen_ldst_addr(dc, a->rs1, a->imm, a->rs2_or_imm); + if (addr =3D=3D NULL) { + return false; + } if (!supervisor(dc)) { return raise_priv(dc); } +#if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) if (gen_trap_ifnofpu(dc)) { return true; } - gen_op_fpexception_im(dc, FSR_FTT_SEQ_ERROR); - return true; + if (!dc->fsr_qne) { + gen_op_fpexception_im(dc, FSR_FTT_SEQ_ERROR); + return true; + } + + /* Store the single element from the queue. */ + TCGv_i64 fq =3D tcg_temp_new_i64(); + tcg_gen_ld_i64(fq, tcg_env, offsetof(CPUSPARCState, fq.d)); + tcg_gen_qemu_st_i64(fq, addr, dc->mem_idx, MO_TEUQ | MO_ALIGN_4); + + /* Mark the queue empty, transitioning to fp_execute state. */ + tcg_gen_st_i32(tcg_constant_i32(0), tcg_env, + offsetof(CPUSPARCState, fsr_qne)); + dc->fsr_qne =3D 0; + + return advance_pc(dc); +#else + qemu_build_not_reached(); +#endif } =20 static bool trans_LDFSR(DisasContext *dc, arg_r_r_ri *a) diff --git a/target/sparc/insns.decode b/target/sparc/insns.decode index 5fd478191a..923f348580 100644 --- a/target/sparc/insns.decode +++ b/target/sparc/insns.decode @@ -645,7 +645,7 @@ STFSR 11 00000 100101 ..... . ............. = @n_r_ri STXFSR 11 00001 100101 ..... . ............. @n_r_ri { STQF 11 ..... 100110 ..... . ............. @q_r_ri_na # v9 - STDFQ 11 ----- 100110 ----- - ------------- + STDFQ 11 ..... 100110 ..... . ............. @r_r_ri # v7= ,v8 } STDF 11 ..... 100111 ..... . ............. @d_r_ri_na =20 --=20 2.43.0 From nobody Sun Nov 24 06:58:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1725905247; cv=none; d=zohomail.com; s=zohoarc; b=KvEDkSoaansZVChkuQ/vKkvKqR7BbTL2k8UaGMCG/5cxLfbvx4L0pZbds155VV6tdLIe5+gcxG9VeVFN7j59Fnr4hn8ocLFX/JM/YB9XuquW5PWjrBHYJusqlnyV9bKmnex/ugGvSmmRrghxs6VIwMNXPJcUh5HM29kMkAlunHg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1725905247; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=NZ0Im01ChiVkI224aNYB6IdOScm3+XFT2X0U0HEizfM=; b=QAgqh9w613izPAay0eKM0/hYWaxOwyJ7VZ8bDnt22ZmstL/07bY61J14gtCwC2ZrH/c12f6u0C0cxoxEe3fszf+6h95REum1Xmx/rzO57YuuBIBYkuM90R0Be1+sm5Hqdc/CfgVXCe0/lsdEL41kQYcHOn15tCMhoyANxSQ4YdI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 172590524755069.06701193948174; Mon, 9 Sep 2024 11:07:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sninL-00048G-CS; Mon, 09 Sep 2024 14:07:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sninK-00041j-Dj for qemu-devel@nongnu.org; Mon, 09 Sep 2024 14:07:22 -0400 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sninI-0001x6-80 for qemu-devel@nongnu.org; Mon, 09 Sep 2024 14:07:22 -0400 Received: by mail-pf1-x436.google.com with SMTP id d2e1a72fcca58-71790ed8c2dso4030058b3a.3 for ; Mon, 09 Sep 2024 11:07:19 -0700 (PDT) Received: from stoup.. (174-21-81-121.tukw.qwest.net. [174.21.81.121]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71908fc84efsm25431b3a.8.2024.09.09.11.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 11:07:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1725905239; x=1726510039; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=NZ0Im01ChiVkI224aNYB6IdOScm3+XFT2X0U0HEizfM=; b=zqe8XYeUv1iEHtOWOoAGjS1wdqrGL4h6cg8u1/EPKIplwxYqOFTXrpIxOEh52ObewJ f7261LaoiLaCr0YQUuyU++3mO+OjPH21ekeNr7bUpFjHM9JUaSn8NnyQgMS1ArTmSHV1 UsXBqfUNpIsYVqU0ab9g8yIgfbB/uTS21fJV9uMW7Wi7InPAYyFN5RIGFFNO1UzZjztX onTTSuG4CuAXN+jDNSZpvaYkE9kUeVazdFt2HC9szOL0AMpC/MUIeGV9P1ofCgIL/4f1 NG2XE3n3RcltkkGfy4qu/yZeZ+Kvjsgw2+7VNOZTTpph06mKaUx5h6KdgHJTgOMz5KVA 7lgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725905239; x=1726510039; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NZ0Im01ChiVkI224aNYB6IdOScm3+XFT2X0U0HEizfM=; b=Q/MQa4HDwFKtOqz3bqrbdorjhHbmAtHkpCDDKWVRvz/iPAluW906UUzx6kYajdczJh Z4sofNSIVN4W8UY5Glfv8WrbKSm0PLOxx1iRNSqnwjtBcxfB81X0JpCQmT/QFuTGVChg zf23rycabWi1//sOyFKoyOeg4YRWwgHjmCS9tlFBziSYG9Jw3YCQutVfCB5SmbxY/Mpa 0gOIXzfRLEonN0grevw+QSea6RPDuEpqPIoPi+iF7wb6Hh0v5wP7MGHNa/Yd7yJU3/ST ZDqnYyoa9heDXWw6KMYjwwkebBlUU2T4fUqdNUpJ4vzGTVH7CRGHmt339M2twDEeUX3K KziQ== X-Gm-Message-State: AOJu0YymF0ByD8aDP6wWTbvzfr2p1cXj5BKZ46Jsx2wiNHUHk4312JfD zKTYgdL8lV2ndNG7hQlstbyVoK/6p0ZVgR5DDWsOACeDmi5y/VsT2NQponGmNcmDSQY/hQ0fukU p X-Google-Smtp-Source: AGHT+IFpfk9Y6uBYltpVm4D8gh8DAcS6Buw2HqEkzLQfQpJ3VXBzvUvobNxvPtG0hFoH2VLR2WFGyw== X-Received: by 2002:a05:6a00:139d:b0:706:6af8:e08a with SMTP id d2e1a72fcca58-718d5ded05emr19017290b3a.2.1725905238526; Mon, 09 Sep 2024 11:07:18 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: mark.cave-ayland@ilande.co.uk, chauser@pullman.com Subject: [PATCH v4 5/5] target/sparc: Add gen_trap_if_nofpu_fpexception Date: Mon, 9 Sep 2024 11:07:12 -0700 Message-ID: <20240909180712.651651-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240909180712.651651-1-richard.henderson@linaro.org> References: <20240909180712.651651-1-richard.henderson@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=2607:f8b0:4864:20::436; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x436.google.com 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1725905248749116600 Content-Type: text/plain; charset="utf-8" Model fp_exception state, in which only fp stores are allowed until such time as the FQ has been flushed. Signed-off-by: Richard Henderson Acked-by: Mark Cave-Ayland --- target/sparc/translate.c | 90 +++++++++++++++++++++++++++------------- 1 file changed, 61 insertions(+), 29 deletions(-) diff --git a/target/sparc/translate.c b/target/sparc/translate.c index b80f071533..cdd0a95c03 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -1465,15 +1465,48 @@ static void gen_op_fpexception_im(DisasContext *dc,= int ftt) gen_exception(dc, TT_FP_EXCP); } =20 -static int gen_trap_ifnofpu(DisasContext *dc) +static bool gen_trap_ifnofpu(DisasContext *dc) { #if !defined(CONFIG_USER_ONLY) if (!dc->fpu_enabled) { gen_exception(dc, TT_NFPU_INSN); - return 1; + return true; } #endif - return 0; + return false; +} + +static bool gen_trap_iffpexception(DisasContext *dc) +{ +#if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) + /* + * There are 3 states for the sparc32 fpu: + * Normally the fpu is in fp_execute, and all insns are allowed. + * When an exception is signaled, it moves to fp_exception_pending sta= te. + * Upon seeing the next FPop, the fpu moves to fp_exception state, + * populates the FQ, and generates an fp_exception trap. + * The fpu remains in fp_exception state until FQ becomes empty + * after execution of a STDFQ instruction. While the fpu is in + * fp_exception state, and FPop, fp load or fp branch insn will + * return to fp_exception_pending state, set FSR.FTT to sequence_error, + * and the insn will not be entered into the FQ. + * + * In QEMU, we do not model the fp_exception_pending state and + * instead populate FQ and raise the exception immediately. + * But we can still honor fp_exception state by noticing when + * the FQ is not empty. + */ + if (dc->fsr_qne) { + gen_op_fpexception_im(dc, FSR_FTT_SEQ_ERROR); + return true; + } +#endif + return false; +} + +static bool gen_trap_if_nofpu_fpexception(DisasContext *dc) +{ + return gen_trap_ifnofpu(dc) || gen_trap_iffpexception(dc); } =20 /* asi moves */ @@ -2643,7 +2676,7 @@ static bool do_fbpfcc(DisasContext *dc, arg_bcc *a) { DisasCompare cmp; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } gen_fcompare(&cmp, a->cc, a->cond); @@ -4482,7 +4515,7 @@ static bool do_ld_fpr(DisasContext *dc, arg_r_r_ri_as= i *a, MemOp sz) if (addr =3D=3D NULL) { return false; } - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } if (sz =3D=3D MO_128 && gen_trap_float128(dc)) { @@ -4510,6 +4543,7 @@ static bool do_st_fpr(DisasContext *dc, arg_r_r_ri_as= i *a, MemOp sz) if (addr =3D=3D NULL) { return false; } + /* Store insns are ok in fp_exception_pending state. */ if (gen_trap_ifnofpu(dc)) { return true; } @@ -4576,7 +4610,7 @@ static bool trans_LDFSR(DisasContext *dc, arg_r_r_ri = *a) if (addr =3D=3D NULL) { return false; } - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -4600,7 +4634,7 @@ static bool do_ldxfsr(DisasContext *dc, arg_r_r_ri *a= , bool entire) if (addr =3D=3D NULL) { return false; } - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -4637,6 +4671,7 @@ static bool do_stfsr(DisasContext *dc, arg_r_r_ri *a,= MemOp mop) if (addr =3D=3D NULL) { return false; } + /* Store insns are ok in fp_exception_pending state. */ if (gen_trap_ifnofpu(dc)) { return true; } @@ -4679,7 +4714,7 @@ static bool do_ff(DisasContext *dc, arg_r_r *a, { TCGv_i32 tmp; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -4720,7 +4755,7 @@ static bool do_env_ff(DisasContext *dc, arg_r_r *a, { TCGv_i32 tmp; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -4740,7 +4775,7 @@ static bool do_env_fd(DisasContext *dc, arg_r_r *a, TCGv_i32 dst; TCGv_i64 src; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -4760,7 +4795,7 @@ static bool do_dd(DisasContext *dc, arg_r_r *a, { TCGv_i64 dst, src; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -4782,7 +4817,7 @@ static bool do_env_dd(DisasContext *dc, arg_r_r *a, { TCGv_i64 dst, src; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -4822,7 +4857,7 @@ static bool do_env_df(DisasContext *dc, arg_r_r *a, TCGv_i64 dst; TCGv_i32 src; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -4865,7 +4900,7 @@ static bool do_env_qq(DisasContext *dc, arg_r_r *a, { TCGv_i128 t; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } if (gen_trap_float128(dc)) { @@ -4886,7 +4921,7 @@ static bool do_env_fq(DisasContext *dc, arg_r_r *a, TCGv_i128 src; TCGv_i32 dst; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } if (gen_trap_float128(dc)) { @@ -4909,7 +4944,7 @@ static bool do_env_dq(DisasContext *dc, arg_r_r *a, TCGv_i128 src; TCGv_i64 dst; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } if (gen_trap_float128(dc)) { @@ -4932,7 +4967,7 @@ static bool do_env_qf(DisasContext *dc, arg_r_r *a, TCGv_i32 src; TCGv_i128 dst; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } if (gen_trap_float128(dc)) { @@ -4955,10 +4990,7 @@ static bool do_env_qd(DisasContext *dc, arg_r_r *a, TCGv_i64 src; TCGv_i128 dst; =20 - if (gen_trap_ifnofpu(dc)) { - return true; - } - if (gen_trap_float128(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -5015,7 +5047,7 @@ static bool do_env_fff(DisasContext *dc, arg_r_r_r *a, { TCGv_i32 src1, src2; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -5224,7 +5256,7 @@ static bool do_env_ddd(DisasContext *dc, arg_r_r_r *a, { TCGv_i64 dst, src1, src2; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -5248,7 +5280,7 @@ static bool trans_FsMULd(DisasContext *dc, arg_r_r_r = *a) TCGv_i64 dst; TCGv_i32 src1, src2; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } if (!(dc->def->features & CPU_FEATURE_FSMULD)) { @@ -5357,7 +5389,7 @@ static bool do_env_qqq(DisasContext *dc, arg_r_r_r *a, { TCGv_i128 src1, src2; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } if (gen_trap_float128(dc)) { @@ -5381,7 +5413,7 @@ static bool trans_FdMULq(DisasContext *dc, arg_r_r_r = *a) TCGv_i64 src1, src2; TCGv_i128 dst; =20 - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } if (gen_trap_float128(dc)) { @@ -5471,7 +5503,7 @@ static bool do_fcmps(DisasContext *dc, arg_FCMPs *a, = bool e) if (avail_32(dc) && a->cc !=3D 0) { return false; } - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -5495,7 +5527,7 @@ static bool do_fcmpd(DisasContext *dc, arg_FCMPd *a, = bool e) if (avail_32(dc) && a->cc !=3D 0) { return false; } - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } =20 @@ -5519,7 +5551,7 @@ static bool do_fcmpq(DisasContext *dc, arg_FCMPq *a, = bool e) if (avail_32(dc) && a->cc !=3D 0) { return false; } - if (gen_trap_ifnofpu(dc)) { + if (gen_trap_if_nofpu_fpexception(dc)) { return true; } if (gen_trap_float128(dc)) { --=20 2.43.0