From nobody Fri May 10 20:50:22 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=linux.alibaba.com ARC-Seal: i=1; a=rsa-sha256; t=1711333105; cv=none; d=zohomail.com; s=zohoarc; b=IiWLW5DgXKlYH3n4qhD2TaiHX3GXr47WJ2sEaWllMRlR92v3ld7Yr/JjxGifn0ayxiqbIPX1a8j8sb9edE6OulGYtBpvjv/XVHbov9pfPVL0rss3f/4Ll/PSh9vpKc5U8GGX3gfDs2/L3wpl9v46ietAyqJgGEWGS5m8VOvHRwQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1711333105; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gDEcVt7HpohF2BJxvlG3tnvyDzgR04c6yMZXRJot6jY=; b=jYJ0auUVSPWN8+sXUTdoxYEPWWXZFwfNaRlvYlOUbC9GalnzUvIWfhDB1PKjCTh+71mvavEFIWZi1lZCiRJVKW8pU8++Ml2vwWdmYoQZH8HoEmgkHHRPAPyWaiT+eqUp2RzKPCq/p7gN0AcmslkLehu5WpdS0uowbh/AvIoRobo= 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 1711333105882717.760852403124; Sun, 24 Mar 2024 19:18:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1roZtw-0002z1-DS; Sun, 24 Mar 2024 22:17:28 -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 1roZtv-0002yo-1L; Sun, 24 Mar 2024 22:17:27 -0400 Received: from out30-119.freemail.mail.aliyun.com ([115.124.30.119]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1roZts-00034B-27; Sun, 24 Mar 2024 22:17:26 -0400 Received: from localhost.localdomain(mailfrom:eric.huang@linux.alibaba.com fp:SMTPD_---0W386B2x_1711333030) by smtp.aliyun-inc.com; Mon, 25 Mar 2024 10:17:11 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1711333032; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=gDEcVt7HpohF2BJxvlG3tnvyDzgR04c6yMZXRJot6jY=; b=gP36IoODrhb699Wi2ZbGXds4VedJABR2i5I41zeKD8F3y2ffbvzkXbthP4Z242UowZYskEMD6+iRhuuNoR6Leo8Lc/QIsdmHM3UZf58NdL+q2Gf/2az2fHjfTXT3Wma0D6T+ykvJ2MWtNvJNxv4qMuKwkF3mImWcZfd1F5FqQHM= X-Alimail-AntiSpam: AC=PASS; BC=-1|-1; BR=01201311R201e4; CH=green; DM=||false|; DS=||; FP=0|-1|-1|-1|0|-1|-1|-1; HT=ay29a033018045176; MF=eric.huang@linux.alibaba.com; NM=1; PH=DS; RN=10; SR=0; TI=SMTPD_---0W386B2x_1711333030; From: Huang Tao To: qemu-devel@nongnu.org Cc: qemu-riscv@nongnu.org, zhiwei_liu@linux.alibaba.com, dbarboza@ventanamicro.com, liwei1518@gmail.com, bin.meng@windriver.com, alistair.francis@wdc.com, palmer@dabbelt.com, Huang Tao , Richard Henderson Subject: [PATCH v3] target/riscv: Fix the element agnostic function problem Date: Mon, 25 Mar 2024 10:16:54 +0800 Message-ID: <20240325021654.6594-1-eric.huang@linux.alibaba.com> X-Mailer: git-send-email 2.41.0 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=115.124.30.119; envelope-from=eric.huang@linux.alibaba.com; helo=out30-119.freemail.mail.aliyun.com X-Spam_score_int: -174 X-Spam_score: -17.5 X-Spam_bar: ----------------- X-Spam_report: (-17.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, UNPARSEABLE_RELAY=0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5 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 @linux.alibaba.com) X-ZM-MESSAGEID: 1711333107174100001 Content-Type: text/plain; charset="utf-8" In RVV and vcrypto instructions, the masked and tail elements are set to 1s using vext_set_elems_1s function if the vma/vta bit is set. It is the eleme= nt agnostic policy. However, this function can't deal the big endian situation. This patch fixes the problem by adding handling of such case. Signed-off-by: Huang Tao Suggested-by: Richard Henderson Reviewed-by: LIU Zhiwei --- Changes in v3: - use "if (HOST_BIG_ENDIAN)" instead of "#if HOST_BIG_ENDIAN" Changes in v2: - Keep the api of vext_set_elems_1s - Reduce the number of patches. --- target/riscv/vector_internals.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/target/riscv/vector_internals.c b/target/riscv/vector_internal= s.c index 12f5964fbb..36635a1138 100644 --- a/target/riscv/vector_internals.c +++ b/target/riscv/vector_internals.c @@ -30,6 +30,28 @@ void vext_set_elems_1s(void *base, uint32_t is_agnostic,= uint32_t cnt, if (tot - cnt =3D=3D 0) { return ; } + + if (HOST_BIG_ENDIAN) { + /* + * Deal the situation when the elements are insdie + * only one uint64 block including setting the + * masked-off element. + */ + if (((tot - 1) ^ cnt) < 8) { + memset(base + H1(tot - 1), -1, tot - cnt); + return; + } + /* + * Otherwise, at least cross two uint64_t blocks. + * Set first unaligned block. + */ + if (cnt % 8 !=3D 0) { + uint32_t j =3D ROUND_UP(cnt, 8); + memset(base + H1(j - 1), -1, j - cnt); + cnt =3D j; + } + /* Set other 64bit aligend blocks */ + } memset(base + cnt, -1, tot - cnt); } =20 --=20 2.41.0