From nobody Mon Feb 9 10:12:14 2026 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=reject dis=none) header.from=sifive.com ARC-Seal: i=1; a=rsa-sha256; t=1767878900; cv=none; d=zohomail.com; s=zohoarc; b=dWd4ZeYHdxp99Zzf9vi6TT8jSiMcN+IBaDhZwH6lD9n/6iDanTrEUPnKpNPFU/Mc2AHFe0fzqbAfIiBUFKjtIoDgYGFCIzB5p7Ym4BEIvThLMg+QEKcrZc87H77Nd/OCIbx+4ihKJjMAsrGgX3wlEsOY15OJMN9S8St7QBtMvd4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1767878900; 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=hUjBC9iK/AQDQc/SPGCkS6zufkBrrvUHdIbr52+DJOg=; b=Db1dToDVVOgf5Iw7QXbrA9KubUq8IH4aedpet4VRuioBCqSscjd3aWOepzQWm9PsoxJ/BZXUAE8NqS+rgmtw0g7phjvWfEFrp3jwta6IFvfa9Qr3BN+JPsza3uE0tGa0Ujr1ktl7jhd6bUHTUyA/nrkWGigWFOWHHikdsPMfX6w= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1767878900633580.8029025467312; Thu, 8 Jan 2026 05:28:20 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vdq2M-0000cI-9K; Thu, 08 Jan 2026 08:26:50 -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 1vdq2K-0000bM-QF for qemu-devel@nongnu.org; Thu, 08 Jan 2026 08:26:48 -0500 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 1vdq2J-0003VG-3x for qemu-devel@nongnu.org; Thu, 08 Jan 2026 08:26:48 -0500 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-bc274b8b15bso2094234a12.1 for ; Thu, 08 Jan 2026 05:26:46 -0800 (PST) Received: from duncan.localdomain (114-35-142-126.hinet-ip.hinet.net. [114.35.142.126]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34f6ae3f033sm2298787a91.0.2026.01.08.05.26.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Jan 2026 05:26:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1767878806; x=1768483606; 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=hUjBC9iK/AQDQc/SPGCkS6zufkBrrvUHdIbr52+DJOg=; b=giMOl71/UNIKXZRuwdLreNsgYzyoFZC4bGgxTKsFOrFZH3FtUpYGWkq5b45WPn0WN/ ezifgZXMdQN/8IF/kvTaUXxukkMBH9ebLEkMwcfFfDxyYzC+1Kxabg53xaBS+TRMVMQX 1bCvIPUs+Mi0wUuR3uT8/JmTzYl5N+bsvy83uTfI2Z2iuY49wDbf7uNZ86n1yjT9owpx 7yY8ov8lNLMVMqdu46eYQrqtxyFxx7O9n9Rxx6F3VC8EfNrq4/pxVWsMx2ckKjXMk9Tc LJXT7E0ZAp8eB7oHTo/C+C3Co0/7RTIn6ka7K4FhaCoKy2IQTcdwqcn8vAYG8Z1DrfwO oQNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767878806; x=1768483606; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=hUjBC9iK/AQDQc/SPGCkS6zufkBrrvUHdIbr52+DJOg=; b=rGGIUgFBSv/WgIYw7YQgfrYG222XRkuDaq6myoIBCGnzYZsJ/EDO9DMS2Ork4m4EtB LWBwwbpR9pUETtHPTgEdzgXRsSBLiS+oO9LD7PNyojFjwcvIobxW5vdt2xR5ajn05WGz pXZD5UjcOGSBWCvDhmK9QGrgD2M93sd06CZ98ndx23sprvPRRAJ9taQKAePdHSsWyOQC 5SFOHNn/SNfoxOcqkKiccRBG4rX47crpC3YHdke7AGRC5Le/wMCgRErXno69HDEVwruV 8II74cZrTGtJEr20oSQvMNFaQ/4oZ1hkttdJHV94/S1TAheH3lwkjnAtxEgZfCn9mF4z VViQ== X-Gm-Message-State: AOJu0YylEU/rzOYOdYHWWD61q6TnkUAvQhOA9kY9TVQ+HK5ce5g6eLsK 1QpuGwFmeiDpBlXYWV15Hq8LSFteSfasx8GjVavj2qW0KlCS7SCZpE+4qiaEfyfjAjtSxj/C5S6 LgI0oYIF965c9jE8Pwm+4WpVZZKYa6W3VqN/eSNs2E+XPIbXdQ2TsPzdQFIi3YylR+NurqA+DKs w4KAUMsSp6K7cKms8za5+ud+2a5+CdWpmN+M3AEPs= X-Gm-Gg: AY/fxX42a2GHzDhrXm0XZpLA7E22ydCifv9JSuo2tuxaa+1nHLXCQyTxk/zjIcZBFEv ETBW0rjmSa+ij1Q8RuLHaufgRXLKHw/GV/N+qJa/AEKjXM2uKgQN1aFgQH6pq0KEIXGldr5U+4g Lcklzo/fyr6e5Ntfz9Sui6bkX1BKcuZ5UHEF2KsJX8PPm5A54y8UlvKgvq8rI2xsCDfAkF2xbPn ID/zED5KmIl7VjxDlQNlgu1GR7Ycsutof2RqXQJmPIJXcu/HDm3t3C3/6PKRq55Yau9LMwesdVx f/Spwaek+3tlL/bQKfuptsJZs+VedSfIYLIduS9pMn9rqaonjxy8IwFQAk05MJf0h7dkzVaZluG aQT2sjD1GtE1Yyw3ZcB8YwJ9sEPzKX9RHbTPycO21x2crREICVTW7ZLyutTRMppuoYfBubSuVck 3+tm4LxwJtcnC4cdLu5+lmKoXPDiM6FbmsL+2RyyBQohz7mTStlWN+HJo= X-Google-Smtp-Source: AGHT+IEey6A4OBBU/hchk93LEnDm89WzuCHBkqpAmpJUEUEOz8CAHQzPLhWg+AbHadQni9mveOZtAQ== X-Received: by 2002:a17:90b:3d08:b0:33b:be31:8194 with SMTP id 98e67ed59e1d1-34f68cea72fmr5775330a91.34.1767878805546; Thu, 08 Jan 2026 05:26:45 -0800 (PST) From: Max Chou To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Palmer Dabbelt , Alistair Francis , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Max Chou Subject: [PATCH v2 3/9] target/riscv: rvv: Add new VTYPE CSR field - altfmt Date: Thu, 8 Jan 2026 21:26:24 +0800 Message-ID: <20260108132631.9429-4-max.chou@sifive.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260108132631.9429-1-max.chou@sifive.com> References: <20260108132631.9429-1-max.chou@sifive.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 (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=max.chou@sifive.com; 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=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 @sifive.com) X-ZM-MESSAGEID: 1767878902223158500 Content-Type: text/plain; charset="utf-8" According to the Zvfbfa ISA spec v0.1, the vtype CSR adds a new field: altfmt for BF16 support. This update changes the layout of the vtype CSR fields. - Removed VEDIV field (bits 8-9) since EDIV extension is not planned to be part of the base V extension - Added ALTFMT field at bit 8 - Changed RESERVED field to start from bit 9 instead of bit 10 When Zvfbfa is disabled, bits 8+ are treated as reserved (preserving existing behavior for altfmt bit). When Zvfbfa is enabled, only bits 9+ are reserved. Reference: - https://github.com/riscvarchive/riscv-v-spec/blob/master/ediv.adoc Reviewed-by: Daniel Henrique Barboza Signed-off-by: Max Chou --- target/riscv/cpu.h | 4 ++-- target/riscv/vector_helper.c | 29 ++++++++++++++++++++++++----- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 35d1f6362c..962cc45073 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -191,8 +191,8 @@ FIELD(VTYPE, VLMUL, 0, 3) FIELD(VTYPE, VSEW, 3, 3) FIELD(VTYPE, VTA, 6, 1) FIELD(VTYPE, VMA, 7, 1) -FIELD(VTYPE, VEDIV, 8, 2) -FIELD(VTYPE, RESERVED, 10, sizeof(target_ulong) * 8 - 11) +FIELD(VTYPE, ALTFMT, 8, 1) +FIELD(VTYPE, RESERVED, 9, sizeof(target_ulong) * 8 - 10) =20 typedef struct PMUCTRState { /* Current value of a counter */ diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c index 2de3358ee8..525a47bf66 100644 --- a/target/riscv/vector_helper.c +++ b/target/riscv/vector_helper.c @@ -33,6 +33,22 @@ #include "vector_internals.h" #include =20 +static target_ulong vtype_reserved(CPURISCVState *env, target_ulong vtype) +{ + int xlen =3D riscv_cpu_xlen(env); + target_ulong reserved =3D 0; + + if (riscv_cpu_cfg(env)->ext_zvfbfa) { + reserved =3D vtype & MAKE_64BIT_MASK(R_VTYPE_RESERVED_SHIFT, + xlen - 1 - R_VTYPE_RESERVED_SHI= FT); + } else { + reserved =3D vtype & MAKE_64BIT_MASK(R_VTYPE_ALTFMT_SHIFT, + xlen - 1 - R_VTYPE_ALTFMT_SHIFT= ); + } + + return reserved; +} + target_ulong HELPER(vsetvl)(CPURISCVState *env, target_ulong s1, target_ulong s2, target_ulong x0) { @@ -41,12 +57,9 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_u= long s1, uint64_t vlmul =3D FIELD_EX64(s2, VTYPE, VLMUL); uint8_t vsew =3D FIELD_EX64(s2, VTYPE, VSEW); uint16_t sew =3D 8 << vsew; - uint8_t ediv =3D FIELD_EX64(s2, VTYPE, VEDIV); + uint8_t altfmt =3D FIELD_EX64(s2, VTYPE, ALTFMT); int xlen =3D riscv_cpu_xlen(env); bool vill =3D (s2 >> (xlen - 1)) & 0x1; - target_ulong reserved =3D s2 & - MAKE_64BIT_MASK(R_VTYPE_RESERVED_SHIFT, - xlen - 1 - R_VTYPE_RESERVED_SH= IFT); uint16_t vlen =3D cpu->cfg.vlenb << 3; int8_t lmul; =20 @@ -63,7 +76,13 @@ target_ulong HELPER(vsetvl)(CPURISCVState *env, target_u= long s1, } } =20 - if ((sew > cpu->cfg.elen) || vill || (ediv !=3D 0) || (reserved !=3D 0= )) { + if (cpu->cfg.ext_zvfbfa) { + if (altfmt =3D=3D 1 && vsew >=3D MO_32) { + vill =3D true; + } + } + + if ((sew > cpu->cfg.elen) || vill || (vtype_reserved(env, s2) !=3D 0))= { /* only set vill bit. */ env->vill =3D 1; env->vtype =3D 0; --=20 2.43.7