From nobody Fri Nov 1 05:39:55 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 ARC-Seal: i=1; a=rsa-sha256; t=1708082960; cv=none; d=zohomail.com; s=zohoarc; b=B5Hpym3YG5Y/nDlmn8IbcrCDj2HE1CFThQfMciRH1/cUNi2zhsjhjF5xWnt9mbhUDh9lvaP1oojAC2kx0jGAZ7ab2Z8Jbgn1r1X+3LVBrlmfJ+XzpV9t44gZpMe+KNW8EQrQoubasK3Xr5+RV2lzDBkhPgkichOrO4YMvRoJl3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708082960; 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=1pILAc4QGfEWQVoqeGm6TwPW8gXNmDL3KNUvGgdYo3Y=; b=FQ2mb7cC9MHHGwJO5nBSc/z3EM2c5vxBzT261zugR/BOHlCjN03clZhwFCvIyy2tK2bwS8itfCUxgjky8DKqsG6LlhpCtXdwXMeFQPJRTaysOSnfu9DJe0uxVmwqK+l4/xvtsIBLlx01xy46z9Dw96zN5RyK1AItELVI3d1zLPQ= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708082959574809.1575731895027; Fri, 16 Feb 2024 03:29:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rawOG-0006Sq-JA; Fri, 16 Feb 2024 06:28:24 -0500 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 1rawOE-0006RS-9k for qemu-devel@nongnu.org; Fri, 16 Feb 2024 06:28:22 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rawOB-0005pp-8n for qemu-devel@nongnu.org; Fri, 16 Feb 2024 06:28:21 -0500 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1db51e55023so12239055ad.1 for ; Fri, 16 Feb 2024 03:28:18 -0800 (PST) Received: from grind.. ([177.94.15.159]) by smtp.gmail.com with ESMTPSA id z10-20020a1709028f8a00b001db7709b322sm2774053plo.298.2024.02.16.03.28.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:28:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1708082896; x=1708687696; 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=1pILAc4QGfEWQVoqeGm6TwPW8gXNmDL3KNUvGgdYo3Y=; b=FpnUkGKf2DJkY+1eK9gurS5bw2ifmeY4Wh2Cppnhcc4hpZx+Q28a2jhd/6qE25whEH UlxN7R+XW37vIsHfGhyPeC4L8XwJHRuhqSTJu19/jcU1PshinK+VWwycKL+TJWYU1mzF ldBJMaYwo5d6I1/ILv4ELzTtxWsVkU8n+/qYSnmsckieQ7FnYkUUvK6o+uSX/h8qV9Di 2F2K+r7ipXjAhvbG03rjCby3Xd/C7XNAYxUeHsNpMvcq0SfaJsQ5iTA0pvGHZEDsayd7 pm7MiEj89vh44NfajYCyFGEkiPKIX0hXoLiPoZxamUZTUgq3sAzEfmk1T6BOjRjAyvL5 G0eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708082896; x=1708687696; 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=1pILAc4QGfEWQVoqeGm6TwPW8gXNmDL3KNUvGgdYo3Y=; b=R/Qj3q5gIaGBZO/ZBGj0dnHY28wzT2cQ82qL9icRZspcNkZG9oqDQ60b9cUv6iOx4M 4jveOrm8vSeoZyrv6N9F9LbxMDIRoCAKbV3+CFD+0/2u94wEJRerlO43llcQ2IoYvwEh qSbRBDD2u1UVHlBCsJo9MZsYyXg26IWM8lJ8EhKJlOyh9+bL9k99ThO7ZNNx0yI2IwYX Zr1jn37HfBmekOUfKtjczvdNEQZt7jiPb4+vcxx2hUQkRDzWwi2XD4BwNL6qf6UnvEGW 6XGImtDRx8gvqoON61WlisEe5nhtyWtogEUXOej2aJ0i8PhTi4j0/+e2qpJcurgDbhSP f6fQ== X-Gm-Message-State: AOJu0YxYhifqrkUvbdfZMHL1MfJlAlHn/RJUWWs8g8Y6MKkyysLU3ANZ 3AEHtnAcDIm1BXR8EUXBCw5YAiSZG+SZtZOmIgg2HrJ3Zkif7JKjofFBfzAUgrSCFqpTcOEAIJ2 b X-Google-Smtp-Source: AGHT+IFUOdi96sWmIdFQJxadU+Qz8USlZNxaF4IIWOGNOXWCP5VIHmHpn+jvtbvyxF7C0ewPdxM3hA== X-Received: by 2002:a17:902:d4c8:b0:1d9:dfa1:e4ee with SMTP id o8-20020a170902d4c800b001d9dfa1e4eemr6055960plg.25.1708082896568; Fri, 16 Feb 2024 03:28:16 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, richard.henderson@linaro.org, max.chou@sifive.com, Daniel Henrique Barboza Subject: [PATCH 1/3] trans_rvv.c.inc: write CSRs must call mark_vs_dirty() too Date: Fri, 16 Feb 2024 08:28:04 -0300 Message-ID: <20240216112806.997948-2-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240216112806.997948-1-dbarboza@ventanamicro.com> References: <20240216112806.997948-1-dbarboza@ventanamicro.com> 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::630; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x630.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, T_SCC_BODY_TEXT_LINE=-0.01 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 @ventanamicro.com) X-ZM-MESSAGEID: 1708082962830100006 Content-Type: text/plain; charset="utf-8" In the Vector spec section 3.2 [1]: "When mstatus.VS is set to Initial or Clean, executing any instruction that changes vector state, including the vector CSRs, will change mstatus.VS to Dirty." ldst_us_trans(), ldst_stride_trans(), ldst_index_trans() and ldst_whole_trans() will change vector state regardless of being a store op or not. Stores will set env->vstart to zero after execution (see vext_ldst_us() in vector_helper.c), and this is vector CSR state change. [1] https://github.com/riscv/riscv-v-spec/blob/master/v-spec.adoc#vector-st= art-index-csr-vstart Fixes: 8e1ee1fb57 ("target/riscv: rvv-1.0: add translation-time vector cont= ext status") Signed-off-by: Daniel Henrique Barboza --- target/riscv/insn_trans/trans_rvv.c.inc | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_tr= ans/trans_rvv.c.inc index 9e101ab434..044c9c903e 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -638,10 +638,7 @@ static bool ldst_us_trans(uint32_t vd, uint32_t rs1, u= int32_t data, =20 fn(dest, mask, base, tcg_env, desc); =20 - if (!is_store) { - mark_vs_dirty(s); - } - + mark_vs_dirty(s); gen_set_label(over); return true; } @@ -799,10 +796,7 @@ static bool ldst_stride_trans(uint32_t vd, uint32_t rs= 1, uint32_t rs2, =20 fn(dest, mask, base, stride, tcg_env, desc); =20 - if (!is_store) { - mark_vs_dirty(s); - } - + mark_vs_dirty(s); gen_set_label(over); return true; } @@ -906,10 +900,7 @@ static bool ldst_index_trans(uint32_t vd, uint32_t rs1= , uint32_t vs2, =20 fn(dest, mask, base, index, tcg_env, desc); =20 - if (!is_store) { - mark_vs_dirty(s); - } - + mark_vs_dirty(s); gen_set_label(over); return true; } @@ -1104,9 +1095,7 @@ static bool ldst_whole_trans(uint32_t vd, uint32_t rs= 1, uint32_t nf, =20 fn(dest, base, tcg_env, desc); =20 - if (!is_store) { - mark_vs_dirty(s); - } + mark_vs_dirty(s); gen_set_label(over); =20 return true; --=20 2.43.0 From nobody Fri Nov 1 05:39:55 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 ARC-Seal: i=1; a=rsa-sha256; t=1708082978; cv=none; d=zohomail.com; s=zohoarc; b=LDNjQkX+XRTv4m49ZGF5uoBKZ7udXbTNHLncZRBkwMnqvaie1TE4gPsO0W0+vDUQGvNA3MurF7BuxiNh38Fh8rmYhKiNkNrzaMLiZwz+fQpZv71GhejJQuZRoCnqtG5Tz58fC9YckKOd8oyuyM4rbpYM21MAr9Un1EuZ0iJX6Oo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708082978; 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=9OrXw+6O3YfHBgx/rcrbMpH4N4DiM1hCF2q4fYF8Wxg=; b=ZPQWMchMabz4enVCGX9ojuLSC9YzoawUiFkIBBuJIFKAlURAaBk6D9yH4J/k+JyvJ2fNioR5FfIFwODVqYoAUaE1tK8j09K11ANi5p2FzEElrM7U7XvwF0TEDrsXNBNPA/zqcIL9yYQosX0j4yQf0DIV+A9S0StqEYYBZk1mOf8= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708082978627231.9228293567918; Fri, 16 Feb 2024 03:29:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rawOH-0006T6-6s; Fri, 16 Feb 2024 06:28:25 -0500 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 1rawOF-0006SP-ST for qemu-devel@nongnu.org; Fri, 16 Feb 2024 06:28:24 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rawOE-0005qB-9k for qemu-devel@nongnu.org; Fri, 16 Feb 2024 06:28:23 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d746ce7d13so4982905ad.0 for ; Fri, 16 Feb 2024 03:28:21 -0800 (PST) Received: from grind.. ([177.94.15.159]) by smtp.gmail.com with ESMTPSA id z10-20020a1709028f8a00b001db7709b322sm2774053plo.298.2024.02.16.03.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:28:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1708082900; x=1708687700; 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=9OrXw+6O3YfHBgx/rcrbMpH4N4DiM1hCF2q4fYF8Wxg=; b=V+Ygxg4V+f1iaZzxaD+TOrAyKl5g4N71YxOeS8g7mH/Uc+hdbkpF8xC9X19z/MVfsL Z4xYMhSIthypbYabjhD2NHHKO1qQOZucNVWJE/Mr7WMNJzwp7jiu6K1n0mpilrUpr94/ 9T0UdJo31vsOZK5avG8ELIlOIyGrNi3Ic+4Q+Bq+r54ehLlB0rQ2j87q4n0lJ1RIZjsl BlsyK59z1Kbrg07ck7O9ZnOOCbkmvasoYb/67/k3+WMCfdisH4/BW/eJyVYEYtSEgEiw xANj2bDSh7l4Ay9cRUmVFMQwesnsghq1qU4fTOQpsHHajkAeJ/5ZHxMK1jlhNMfnYFYA LSRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708082900; x=1708687700; 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=9OrXw+6O3YfHBgx/rcrbMpH4N4DiM1hCF2q4fYF8Wxg=; b=GmcR32V4YBODq6f2HGbaAYz71cyYj6iuf/SlCWF/r1Zo/gja5kgouj12Kvnlpe+82A 1VHHnISw9uGgRXX0++6EaGVkCIb57t/IMVqo6L/UAKS/Tb7YrHcwho//1wt2LYtVrYdy nAuDAb/uiQZEqo0H6bxlaz07uIsW7fsr7BKqiM5O55WisG5syI3fw2SFtdZE40wP3YRL zajJ1HkPOtenKCZKwLAbR6Pgz5OZZiONOPf/Ow0UZnoqK0DLcutAbuMJAK8kJpBaZRu/ PfRgXssCNI66LajsA0SX746yQfqZlf/zJC+jBkZiRstfyh1t1nfXtDk6QpHcxl9hem6V vyFw== X-Gm-Message-State: AOJu0YyeibAPC4DY0g1xYQMCPSbqo8/xPf+Ch8RrJOcihDVIGZzyuNxJ 7d86ISXyXPQeyHLiEip7k7zAlKuiHWtqpmLVirOab4ZT58RExrXAKY+EunAZWc4UFNdoywCj45j / X-Google-Smtp-Source: AGHT+IFtwskf/lie1g5iPA3+CQaRS/4cLSmv0sNUr/AFjRRluBxrFxWKYohirI7akH6d81sw4fDC9Q== X-Received: by 2002:a17:902:e5d0:b0:1db:2ab0:f3de with SMTP id u16-20020a170902e5d000b001db2ab0f3demr5664587plf.13.1708082899975; Fri, 16 Feb 2024 03:28:19 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, richard.henderson@linaro.org, max.chou@sifive.com, Daniel Henrique Barboza Subject: [PATCH 2/3] trans_rvv.c.inc: remove redundant mark_vs_dirty() calls Date: Fri, 16 Feb 2024 08:28:05 -0300 Message-ID: <20240216112806.997948-3-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240216112806.997948-1-dbarboza@ventanamicro.com> References: <20240216112806.997948-1-dbarboza@ventanamicro.com> 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::634; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x634.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @ventanamicro.com) X-ZM-MESSAGEID: 1708082979951100005 Content-Type: text/plain; charset="utf-8" trans_vmv_v_i , trans_vfmv_v_f and the trans_##NAME macro from GEN_VMV_WHOLE_TRANS() are calling mark_vs_dirty() in both branches of their 'ifs'. conditionals. Call it just once in the end like other functions are doing. Signed-off-by: Daniel Henrique Barboza --- target/riscv/insn_trans/trans_rvv.c.inc | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/target/riscv/insn_trans/trans_rvv.c.inc b/target/riscv/insn_tr= ans/trans_rvv.c.inc index 044c9c903e..778e2723dd 100644 --- a/target/riscv/insn_trans/trans_rvv.c.inc +++ b/target/riscv/insn_trans/trans_rvv.c.inc @@ -2094,7 +2094,6 @@ static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_= i *a) if (s->vl_eq_vlmax && !(s->vta && s->lmul < 0)) { tcg_gen_gvec_dup_imm(s->sew, vreg_ofs(s, a->rd), MAXSZ(s), MAXSZ(s), simm); - mark_vs_dirty(s); } else { TCGv_i32 desc; TCGv_i64 s1; @@ -2115,9 +2114,9 @@ static bool trans_vmv_v_i(DisasContext *s, arg_vmv_v_= i *a) tcg_gen_addi_ptr(dest, tcg_env, vreg_ofs(s, a->rd)); fns[s->sew](dest, s1, tcg_env, desc); =20 - mark_vs_dirty(s); gen_set_label(over); } + mark_vs_dirty(s); return true; } return false; @@ -2660,7 +2659,6 @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_= v_f *a) =20 tcg_gen_gvec_dup_i64(s->sew, vreg_ofs(s, a->rd), MAXSZ(s), MAXSZ(s), t1); - mark_vs_dirty(s); } else { TCGv_ptr dest; TCGv_i32 desc; @@ -2686,9 +2684,9 @@ static bool trans_vfmv_v_f(DisasContext *s, arg_vfmv_= v_f *a) =20 fns[s->sew - 1](dest, t1, tcg_env, desc); =20 - mark_vs_dirty(s); gen_set_label(over); } + mark_vs_dirty(s); return true; } return false; @@ -3632,15 +3630,14 @@ static bool trans_##NAME(DisasContext *s, arg_##NAM= E * a) \ if (s->vstart_eq_zero) { \ tcg_gen_gvec_mov(s->sew, vreg_ofs(s, a->rd), \ vreg_ofs(s, a->rs2), maxsz, maxsz); \ - mark_vs_dirty(s); \ } else { \ TCGLabel *over =3D gen_new_label(); \ tcg_gen_brcondi_tl(TCG_COND_GEU, cpu_vstart, maxsz, over); \ tcg_gen_gvec_2_ptr(vreg_ofs(s, a->rd), vreg_ofs(s, a->rs2), \ tcg_env, maxsz, maxsz, 0, gen_helper_vmvr_v= ); \ - mark_vs_dirty(s); \ gen_set_label(over); \ } \ + mark_vs_dirty(s); \ return true; \ } \ return false; \ --=20 2.43.0 From nobody Fri Nov 1 05:39:55 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 ARC-Seal: i=1; a=rsa-sha256; t=1708082978; cv=none; d=zohomail.com; s=zohoarc; b=ChucaN8wPJ6wYoxzDVyHQf9Z1G9peHqBuBQOppkMikOqq+or2Cr17qb56nPHIROrTLKryPtcbIYCIB+lyYy7QcrK/MGeXczMO7ReZpanlzZwq581BMd337Csxc6ZOulDUmDTHie58u+kjq/5gK40lwUsuMEr6Mc+Ul77jQl0INw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1708082978; 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=GUW4y+sVEbMZE51fAwATSVNurT+QNFpidOYUiPbmWtc=; b=Ogot7/ENliE2yEPJF2qWjl7dJS4QbYhRMDwYl/T4OHtHBMCCiI1EB3VR0nV389db9zGOueVMOayjVSC6ZFXVKi3onchcotM/YC/C6o4kYTDqq8sEjeQwkoL71XEwc6/n0VgZ4wyZgf/xqfi38pJ2TIR+F4tFvY9XOu2Ym56Q+Yw= 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1708082978357138.20714529903012; Fri, 16 Feb 2024 03:29:38 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rawOK-0006UL-RW; Fri, 16 Feb 2024 06:28:28 -0500 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 1rawOI-0006Tr-OS for qemu-devel@nongnu.org; Fri, 16 Feb 2024 06:28:26 -0500 Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rawOH-0005ql-2Q for qemu-devel@nongnu.org; Fri, 16 Feb 2024 06:28:26 -0500 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1d7354ba334so17068385ad.1 for ; Fri, 16 Feb 2024 03:28:24 -0800 (PST) Received: from grind.. ([177.94.15.159]) by smtp.gmail.com with ESMTPSA id z10-20020a1709028f8a00b001db7709b322sm2774053plo.298.2024.02.16.03.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 03:28:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1708082903; x=1708687703; 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=GUW4y+sVEbMZE51fAwATSVNurT+QNFpidOYUiPbmWtc=; b=E11l5Bsv4YJLb0cHioEx+uSaRXjiLUSz/1RNwaZXJAKpoi5JESpVuRFi6v/37uujHv JrGjsduzbehTy9rg2BSRVJYXmLHP/ugbPjb6a+3U1NkflMLCDm9s1PA1m9fcmlkO/KCP KdiuyOb60qnvwOZC6RNhGuF4qovqA8C1ukZVCFdQN5a/hQR/NPk//hNYKvAU12dWOD2y uyW5VFljNz3x9nGrTjF8EmOZuLv763kJDqPp8vjKhN7gLBKh9jTkdrltz/f4YUUQ0xGP VfNv4fbeyWFL/qamS+DhKpu1A0B2BBAbKT+Vs6vo/WNTkOqSrlTIv5OoF0OA5nADvu0h vIoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708082903; x=1708687703; 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=GUW4y+sVEbMZE51fAwATSVNurT+QNFpidOYUiPbmWtc=; b=hr518JP1mfig9Vdt2MeanB1wrXd2JhpZAppohCN3S/Mjt7nt0rspS+eOtRfVbU7n+q IyK58V1tRRfAGJ0ATgwsPhAwC+qtzWMq/H8QLe9VOxODnIc4QMps2KuNbdVGDRL+44vk e+Y8CF8WFFIGEkN5PDCVjo9I3S2c8z63On8ilFjatU9luzim2yZWIwXv2/+ibM6r8WzD u8QdY69VEN5fOdvhVuO/D56F4rnM/7Tsai0SFpAKzgwtp6rAj3pAnNikVyiBBUl4I1G4 q5LKAi54CtqUwe6Q7zPjnLdDb1G4c3ycRP3ZZIrPmOGd06/NCYQ7j5Z/FsxnI9/1YCtq ijRA== X-Gm-Message-State: AOJu0YwdqFD0i4PTRir1m5E1x8o7V+j3Q8NmN+PrqvLgwimr5iCLAO1S YZZNCmxExm3nahhIo+u1X+fihejKwoYMTZhJPwEiGOVjc8UT7l9IMdK3RFYXiPThFFZt+EN+DTL k X-Google-Smtp-Source: AGHT+IF0srGgsFtTapvYCV3qfp9HifG87Iq8D4TbUbTZVvf7iarE6GYYQADx4xKgSwz2aOYmZSDXcQ== X-Received: by 2002:a17:902:fc50:b0:1d8:f016:cfaf with SMTP id me16-20020a170902fc5000b001d8f016cfafmr5380211plb.47.1708082903518; Fri, 16 Feb 2024 03:28:23 -0800 (PST) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, alistair.francis@wdc.com, bmeng@tinylab.org, liwei1518@gmail.com, zhiwei_liu@linux.alibaba.com, palmer@rivosinc.com, richard.henderson@linaro.org, max.chou@sifive.com, Daniel Henrique Barboza Subject: [PATCH 3/3] target/riscv/translate.c: set vstart_eq_zero in mark_vs_dirty() Date: Fri, 16 Feb 2024 08:28:06 -0300 Message-ID: <20240216112806.997948-4-dbarboza@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240216112806.997948-1-dbarboza@ventanamicro.com> References: <20240216112806.997948-1-dbarboza@ventanamicro.com> 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::634; envelope-from=dbarboza@ventanamicro.com; helo=mail-pl1-x634.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable 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 @ventanamicro.com) X-ZM-MESSAGEID: 1708082979955100006 Content-Type: text/plain; charset="utf-8" The 'vstart_eq_zero' flag which is used to determine if some insns, like vector reductor operations, should SIGILL. At this moment the flag is being updated only during cpu_get_tb_cpu_state(), at the start of each translation block. This cadence isn't enough and we're facing situations where a vector instruction successfully updated 'vstart' to zero, but the flag was still marked as 'false', resulting in a SIGILL because instructions are checking the flag. mark_vs_dirty() is called after any instruction changes Vector CSR state, making it a good place to update 'vstart_eq_zero'. Fixes: 8e1ee1fb57 ("target/riscv: rvv-1.0: add translation-time vector cont= ext status") Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1976 Signed-off-by: Daniel Henrique Barboza --- target/riscv/translate.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/target/riscv/translate.c b/target/riscv/translate.c index 177418b2b9..9943538894 100644 --- a/target/riscv/translate.c +++ b/target/riscv/translate.c @@ -652,9 +652,13 @@ static inline void mark_fs_dirty(DisasContext *ctx) { } */ static void mark_vs_dirty(DisasContext *ctx) { + TCGLabel *vstart_zero, *done; TCGv tmp; =20 if (ctx->mstatus_vs !=3D EXT_STATUS_DIRTY) { + vstart_zero =3D gen_new_label(); + done =3D gen_new_label(); + /* Remember the state change for the rest of the TB. */ ctx->mstatus_vs =3D EXT_STATUS_DIRTY; =20 @@ -668,6 +672,24 @@ static void mark_vs_dirty(DisasContext *ctx) tcg_gen_ori_tl(tmp, tmp, MSTATUS_VS); tcg_gen_st_tl(tmp, tcg_env, offsetof(CPURISCVState, mstatus_hs= )); } + + /* + * We can safely make 'vl_eq_vlmax =3D false' if we marked + * VS as dirty with non-zero 'vstart', i.e. there's a fault + * to be handled. If 'vstart' is zero then we should retain + * the existing 'vl_eq_vlmax' - it'll be recalculated on the + * start of the next TB or during vset{i}vl{i} (that forces a + * TB end). + */ + tcg_gen_brcondi_tl(TCG_COND_EQ, cpu_vstart, 0, vstart_zero); + ctx->vstart_eq_zero =3D false; + ctx->vl_eq_vlmax =3D false; + tcg_gen_br(done); + + gen_set_label(vstart_zero); + ctx->vstart_eq_zero =3D true; + + gen_set_label(done); } } #else --=20 2.43.0