From nobody Wed Sep 23 09:55:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1783707347; cv=none; d=zohomail.com; s=zohoarc; b=jdpqgXFSYQY6MfGltQUnzjGUN49x0pw2bEEW1dJ5WXlFzxn6HH17K1+D8MzBCdOP7Bpe/LvnEWHl5uiQ5RSySoP7U18yK4bx8xqK9qO46EeuYzHvKC63HtsM/uxzdsgeLP01PcbdnBBZW+c0T0JAhZLnSr1QLrNT9axE61RNRiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1783707347; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=yspuUIP+ue/IgMhnjrhe4uY6LB19YsEZu8U2A+xdrOg=; b=RblGRvV2eYJr/WniU1eAks4gznOll++j+jAStFfcSL1IBnxqGhhw02eO03c/zKdWbpXq95E0rOUZLUYmyicwnC0NKt3WQSsTRnbVJhuq3H5qi3iAAs08nsdFVX8M+8BYHuzCj5/bAdERrJS3bSdH/EbnBv3GYpQQyQ4Cl6CKA8g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [38.145.34.151]) by mx.zohomail.com with SMTPS id 17837073476501013.9355223599947; Fri, 10 Jul 2026 11:15:47 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6E59F41BB8; Fri, 10 Jul 2026 14:15:46 -0400 (EDT) Received: from [172.19.199.10] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id BBAEF41DD6; Fri, 10 Jul 2026 14:13:42 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id BBE2641BC1; Fri, 10 Jul 2026 14:13:26 -0400 (EDT) Received: from smtp-relay-internal-0.canonical.com (smtp-relay-internal-0.canonical.com [185.125.188.122]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 88A5F41B11 for ; Fri, 10 Jul 2026 14:13:24 -0400 (EDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 28ADF3FA6E for ; Fri, 10 Jul 2026 18:05:38 +0000 (UTC) Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-47bbe3b9705so1115313f8f.0 for ; Fri, 10 Jul 2026 11:05:38 -0700 (PDT) Received: from workstation5 ([2a02:3035:621:9ef:5b82:e6cb:d339:9973]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-47a9e4d6e4csm58675604f8f.10.2026.07.10.11.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jul 2026 11:05:36 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=4.0.1 X-Greylist: delayed 464 seconds by postgrey-1.37 at lists.libvirt.org; Fri, 10 Jul 2026 14:13:24 EDT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20251003; t=1783706738; bh=yspuUIP+ue/IgMhnjrhe4uY6LB19YsEZu8U2A+xdrOg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l6xmfFLz2A3CYb/Bnw8Uacbe/WDvODG0bthWy937IU7xTNiLb/Y5F+a+EJmRU5YPB jCELzEiSs1pxF0BTnOFQMAL+SMuLy3qIs7Qp2ZgSNVqWSRO9A13HQb5iERHLt4mdpD uJb6xxBmEoT5hYQKsMfPqdkA8uRuReZyZQ0vMfDzaAF9AxY86gS36HFyJ1XJci++QO OiirkJ92oUgZGs+v6DpHrCEcGJZK/bxJLgTZS/a0UKYQOurij+XL5iKZ1d8a/Qrm8s UMFyHrHtsL8WhajHZTiDOBdbU9amlICJvoNNd4dEL2QgAwa1kOWAlTBXOJfJUmOUEJ ZBaKryCqio8jI0J1b91uAoWEpHIG0pFJ5SXegGOW+Pf3Nulm7O6Ifd7ZJRUWhjCVX2 H7x4oRlgaUqQQpzNId9WyD7dhy9mC8lyIlTMQG2864jNn4P6D4GoojGE24UAKOBIgP yYHTQO9Twm59jTLvIk2E9I8FxBbgp44exUixkHMYmiyrbqMK2Vy+4WdQErKjTdR9u4 OBpEb9rrIdWpVbNGryDVtoVBgBrB7gyzNCawkIsElUyd1EMYCBYoKrRMDtZ+RLrWfQ nrMEfOzpa3UtbGKqwPoSj25VhaGR+qFGRkff7JMqpD3lfHcJpMV0rLieAiwxLdyejd M2Alwho9PBSylUDlkbZugERU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783706737; x=1784311537; 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:content-type; bh=yspuUIP+ue/IgMhnjrhe4uY6LB19YsEZu8U2A+xdrOg=; b=WZ9R/bsXb2auZHpb2Wu0vQ4mKxm225vS6E78/jUHvcqo8aFv89o/GqVQP41yYZLjl9 CqArZ+/6zRXFIvaU5yONtYysEjWNZ4EfHLzw/DMsAZ2F9KHpqV1m9kizK2Ah4fVYZtKz otL4O604HzOTuJElLg986xuejWzDTL4nYWYT55UOuzst7/aVdP+2XMXsT8CNRPcnxi+E 1ey9UMLoryz6v0bdwsYlxjwJapHFKVFnaEeKMF/rQ0//fTVv6jocl3HuBCaZ5XtTP5KP CimFDoqqS1ZLeCGTv6aeI90Xao/fc4ZmPvBVVq47t+850vrCi0WrG4PXrK88b5r779vY rRoQ== X-Gm-Message-State: AOJu0YxT5EsiouMcbtSQ9V8lszbc4rZm9jrdMgJw2tNaSb0xjdFKPvvA Em8H9hw7reG0aCEzqmfxaHHyyGWtR2XXoK9sDSQgjqn1owuSUBVhw0Lf/URNxNNZFmHMy5kyPYH hTHCVnPnQ9qH1pLbMfwBq01HezxVuLfWBiYDE+JkfjjNuAI7n5h1r0BQpB6OM2wsCe6DdCiywl4 dDU1ki2C8= X-Gm-Gg: AfdE7cmMjni7HJOkDc6gnZG4+IXSQ54DwFUPe2Jpsr0rPVCwlQ9N4dkAEGH1X5B9nKk 5eRCchmdaYQ8Z2lqtOai7cl9DT5zIyvf6230OFiEyGGliDhevldeXskprv+8XA+8lYhYaLoCZxX kkA0CnmUNAz7EfzN3Olea2Bvptb2kZS0xjHPYxqceXRVxiRr+SiR51p3iqhYeg1DwhRdsDRMuo5 4pTOa6AVzVAXSgqy/+IMd9K18T4L4md/lLuwqrt4d6Z29tcvPxBU8VuhRGhzO5gT2WZEIXegrjL AbrrLKrb6OuWJLRnJyiuAxUrAP/kV9TSX9ja9Pugp0e8tqYtPh6A+D9JNGy5EZjnn57q2vCPDQr 7KKHLOZBK6rK7v7ChiMomyfh+A81onirdlV0R8EZBMhWphbkmNYNoH9fYzERg7btq X-Received: by 2002:a05:6000:382:b0:474:cd60:1154 with SMTP id ffacd0b85a97d-47df0797672mr13290587f8f.41.1783706737719; Fri, 10 Jul 2026 11:05:37 -0700 (PDT) X-Received: by 2002:a05:6000:382:b0:474:cd60:1154 with SMTP id ffacd0b85a97d-47df0797672mr13290568f8f.41.1783706737352; Fri, 10 Jul 2026 11:05:37 -0700 (PDT) To: devel@lists.libvirt.org Subject: [PATCH 1/6] conf: add vlen tag for RISC-V CPUs Date: Fri, 10 Jul 2026 20:05:18 +0200 Message-ID: <20260710180523.54387-2-heinrich.schuchardt@canonical.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260710180523.54387-1-heinrich.schuchardt@canonical.com> References: <20260710180523.54387-1-heinrich.schuchardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SEBGGLBIVDDLVV24LGKU5OP4SIPF56AF X-Message-ID-Hash: SEBGGLBIVDDLVV24LGKU5OP4SIPF56AF X-MailFrom: heinrich.schuchardt@canonical.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Heinrich Schuchardt via Devel Reply-To: Heinrich Schuchardt X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1783707351355158500 Content-Type: text/plain; charset="utf-8" RISC-V CPUs provide a scalable vector extension. The length of the vector registers is implementation specific. QEMU allows to set the vector length as a CPU property, e.g. '-cpu rva23s64,vlen=3D256'. To describe this feature a new CPU tag is introduced where conforming to the RISC-V ISA specification vlen must be a power of 2 in the range 8 to 65536. The current QEMU release has tighter bounds depending on the chosen vector extensions: * max_vlen =3D 1024 * min_vlen =3D 32 (zve32x), 64 (zve64x), or 128 (V) This patch checks the configuration against the bounds of the ISA specification. This patch only covers the configuration management for vlen. Signed-off-by: Heinrich Schuchardt --- src/conf/cpu_conf.c | 25 +++++++++++++++++++++++++ src/conf/cpu_conf.h | 1 + 2 files changed, 26 insertions(+) diff --git a/src/conf/cpu_conf.c b/src/conf/cpu_conf.c index f5a2004ee6..331f806968 100644 --- a/src/conf/cpu_conf.c +++ b/src/conf/cpu_conf.c @@ -250,6 +250,7 @@ virCPUDefCopyWithoutModel(const virCPUDef *cpu) copy->sigFamily =3D cpu->sigFamily; copy->sigModel =3D cpu->sigModel; copy->sigStepping =3D cpu->sigStepping; + copy->vlen =3D cpu->vlen; =20 if (cpu->cache) { copy->cache =3D g_new0(virCPUCacheDef, 1); @@ -356,6 +357,7 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, g_autofree xmlNodePtr *nodes =3D NULL; xmlNodePtr topology =3D NULL; xmlNodePtr maxphysaddrNode =3D NULL; + xmlNodePtr vlenNode =3D NULL; g_autofree xmlNodePtr *cacheNodes =3D NULL; ssize_t ncacheNodes =3D 0; VIR_XPATH_NODE_AUTORESTORE(ctxt) @@ -691,6 +693,20 @@ virCPUDefParseXML(xmlXPathContextPtr ctxt, =20 } =20 + if ((vlenNode =3D virXPathNode("./vlen[1]", ctxt))) { + if (virXMLPropUInt(vlenNode, "value", 10, + VIR_XML_PROP_REQUIRED | VIR_XML_PROP_NONZERO, + &def->vlen) < 0) + return -1; + + if (def->vlen < 8 || def->vlen > 65536 || + (def->vlen & (def->vlen - 1)) !=3D 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid CPU vlen value, must be a power of t= wo in range [8, 65536]")); + return -1; + } + } + *cpu =3D g_steal_pointer(&def); return 0; } @@ -875,6 +891,9 @@ virCPUDefFormatBuf(virBuffer *buf, virBufferAddLit(buf, "/>\n"); } =20 + if (def->vlen) + virBufferAsprintf(buf, "\n", def->vlen); + for (i =3D 0; i < def->nfeatures; i++) { virCPUFeatureDef *feature =3D def->features + i; =20 @@ -1175,6 +1194,12 @@ virCPUDefIsEqual(virCPUDef *src, return false; } =20 + if (src->vlen !=3D dst->vlen) { + MISMATCH(_("Target CPU vlen %1$u does not match source %2$u"), + dst->vlen, src->vlen); + return false; + } + if (src->nfeatures !=3D dst->nfeatures) { MISMATCH(_("Target CPU feature count %1$zu does not match source %= 2$zu"), dst->nfeatures, src->nfeatures); diff --git a/src/conf/cpu_conf.h b/src/conf/cpu_conf.h index 0cac1a1489..406deb5e0b 100644 --- a/src/conf/cpu_conf.h +++ b/src/conf/cpu_conf.h @@ -154,6 +154,7 @@ struct _virCPUDef { unsigned int sigFamily; unsigned int sigModel; unsigned int sigStepping; + unsigned int vlen; /* RISC-V vector register length in bits; 0 for u= nspecified */ size_t nfeatures; size_t nfeatures_max; virCPUFeatureDef *features; --=20 2.53.0