From nobody Sun Dec 14 06:20:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; 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 8.43.85.245 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=1748446029; cv=none; d=zohomail.com; s=zohoarc; b=Ph3eU788oDVhnWyOZylM0HY0q7EAgC8+hL0GeBzl1jIRXniJBUwh0STx0k3iAew9nuDwbBkDqRYAgYm8re6MAj9KC5JSTVqd7QUHBK6Clgtx9rQbkLwx//u6GyJowwMVX0Kte6lbsQErfmsK96HoRwEP9/oNEUdeZsaFNswlOsM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748446029; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=AdIiwYh2HC0q32k74Q8pgtfH3qwFR5MgHeAn1tDelZo=; b=QD0eaMNv0HCeLVnTeCoxIyOpS9B81C7Ftu9SEkQ229F5iL3KpjOegRpzDXZn+HMIAtCgOnefEabUIwcNm2nFzNKzGIx61YBSMM3YLrBh774N8Tw1aOWyJzx2mv95W4ykKU7cGXe5TqzAXDMhS618rurNvEqbkQx/99sHz75VBP0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 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 [8.43.85.245]) by mx.zohomail.com with SMTPS id 1748446029847868.1344153663971; Wed, 28 May 2025 08:27:09 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E0DDC14D2; Wed, 28 May 2025 11:27:08 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A401F136A; Wed, 28 May 2025 11:22:35 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DC1D1141C; Wed, 28 May 2025 11:22:27 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id BEA111381 for ; Wed, 28 May 2025 11:22:08 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-166-YXQ6dnZ_N_KCQ1ZYge8i8A-1; Wed, 28 May 2025 11:22:06 -0400 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (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 mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 120441945108 for ; Wed, 28 May 2025 15:22:06 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.44.34.165]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3816018004A7 for ; Wed, 28 May 2025 15:22:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748445728; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XN0RTiEmDRs0U3Wz50i0fLcqXD2rR0ExLP5MqxyXoO4=; b=EkqnT4tdES5pNU9GencYodBue35+bn7krlYY41lR5T4pxxsiPuEYsp1zT/I/TfuGDAKyn+ LdESyW0hxzDXDkxE31fBreLqkxLtFha90ipuPXp5MwIIF+c4MDUZFMSnYhDPC7JCK+4vrm R/GFYYBmCleEjwLhCI4sJSIzaeaRYEg= X-MC-Unique: YXQ6dnZ_N_KCQ1ZYge8i8A-1 X-Mimecast-MFC-AGG-ID: YXQ6dnZ_N_KCQ1ZYge8i8A_1748445726 To: devel@lists.libvirt.org Subject: [libvirt PATCHv2 5/7] conf: add passthrough and xtsup attributes for IOMMU Date: Wed, 28 May 2025 17:20:11 +0200 Message-ID: <57a812d0dd07ac8d8f24f3392507b263fbbd61ef.1748445613.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: v7l_KJsT6_IQr3yfKwDCIMVrV7NnAThVdxEi2ijy5q8_1748445726 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 47JN5NXCB6T2DCXTKKHWOPCOX7PPSTJ5 X-Message-ID-Hash: 47JN5NXCB6T2DCXTKKHWOPCOX7PPSTJ5 X-MailFrom: jtomko@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: =?utf-8?q?J=C3=A1n_Tomko_via_Devel?= Reply-To: =?UTF-8?q?J=C3=A1n=20Tomko?= X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1748446031680116600 Content-Type: text/plain; charset="utf-8" From: J=C3=A1n Tomko For the newly supported AMD device. Signed-off-by: J=C3=A1n Tomko --- docs/formatdomain.rst | 8 ++++++++ src/conf/domain_conf.c | 30 +++++++++++++++++++++++++++++ src/conf/domain_conf.h | 2 ++ src/conf/schemas/domaincommon.rng | 10 ++++++++++ tests/qemuxmlconfdata/amd-iommu.xml | 2 +- 5 files changed, 51 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 1fa814931f..7af14c656f 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -9092,6 +9092,14 @@ Example: example to efficiently enable more than 255 vCPUs. :since:`Since 10.7.0` (QEMU/KVM and ``intel`` model only) =20 + ``passthrough`` + Enable passthrough. In this mode, DMA read/writes are not translated. + :since:`Since 11.5.0` (QEMU/KVM and ``amd`` model only) + + ``xtsup`` + Enable x2APIC mode. Useful for higher number of guest CPUs. + :since:`Since 11.5.0` (QEMU/KVM and ``amd`` model only) + The ``virtio`` IOMMU devices can further have ``address`` element as descr= ibed in `Device addresses`_ (address has to by type of ``pci``). =20 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 2e7454f4d6..c20fe0e241 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14333,6 +14333,14 @@ virDomainIOMMUDefParseXML(virDomainXMLOption *xmlo= pt, if (virXMLPropTristateSwitch(driver, "dma_translation", VIR_XML_PR= OP_NONE, &iommu->dma_translation) < 0) return NULL; + + if (virXMLPropTristateSwitch(driver, "xtsup", VIR_XML_PROP_NONE, + &iommu->xtsup) < 0) + return NULL; + + if (virXMLPropTristateSwitch(driver, "passthrough", VIR_XML_PROP_N= ONE, + &iommu->pt) < 0) + return NULL; } =20 if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, @@ -21963,6 +21971,20 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUD= ef *src, virTristateSwitchTypeToString(src->dma_translation)= ); return false; } + if (src->pt !=3D dst->pt) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain IOMMU device dma translation '%1$s= ' does not match source '%2$s'"), + virTristateSwitchTypeToString(dst->pt), + virTristateSwitchTypeToString(src->pt)); + return false; + } + if (src->xtsup !=3D dst->xtsup) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain IOMMU device dma translation '%1$s= ' does not match source '%2$s'"), + virTristateSwitchTypeToString(dst->xtsup), + virTristateSwitchTypeToString(src->xtsup)); + return false; + } =20 return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); } @@ -28190,6 +28212,14 @@ virDomainIOMMUDefFormat(virBuffer *buf, virBufferAsprintf(&driverAttrBuf, " dma_translation=3D'%s'", virTristateSwitchTypeToString(iommu->dma_transla= tion)); } + if (iommu->pt !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&driverAttrBuf, " passthrough=3D'%s'", + virTristateSwitchTypeToString(iommu->pt)); + } + if (iommu->xtsup !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&driverAttrBuf, " xtsup=3D'%s'", + virTristateSwitchTypeToString(iommu->xtsup)); + } =20 virXMLFormatElement(&childBuf, "driver", &driverAttrBuf, NULL); =20 diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index bcac061aa6..d1ee598eb0 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3019,6 +3019,8 @@ struct _virDomainIOMMUDef { unsigned int aw_bits; virDomainDeviceInfo info; virTristateSwitch dma_translation; + virTristateSwitch xtsup; + virTristateSwitch pt; }; =20 typedef enum { diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index f135e6f1d7..b180ab46c7 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -6226,6 +6226,16 @@ + + + + + + + + + + diff --git a/tests/qemuxmlconfdata/amd-iommu.xml b/tests/qemuxmlconfdata/am= d-iommu.xml index 0668ed4237..4ad79ce4ae 100644 --- a/tests/qemuxmlconfdata/amd-iommu.xml +++ b/tests/qemuxmlconfdata/amd-iommu.xml @@ -32,7 +32,7 @@ - +
--=20 2.49.0