From nobody Sun Dec 14 06:19:49 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=1750244068; cv=none; d=zohomail.com; s=zohoarc; b=kI7XQgxNYd+q2Dt0gw2yuoL6p8zp74i/pD6mpZuSaF26AqV/IwMZ2WV98PNKRpelFonsfdn+IqMDIqiKpfYk+NLin6vv/umM6NffYpkWHrKJ54iWgBDJNNrVrEDO38r0Oo/gq7TuLaKJG8b6b2p07gVgXBZ/b12dVHAJkKL74BE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1750244068; 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=XYEG/7dRncveWVjIDp73mpv9tXM86HJuuWa77kdi0E8=; b=caGP/SV08fdrn57rjM0yF/D9olpFgj2cQ4QaDzsbxso/yDedu5E9+xXbDMAFAhxz9PUxb2Ikf5M7ilWMw1y91vcQVUyELTe2QtxuO/VwJGR9AKkROcojQpzO8QO4XOzcCXQE+625Y37ziyKcOSd8y2RvXPRDVHbrwIuAB/j6GKU= 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 1750244068802799.221220976646; Wed, 18 Jun 2025 03:54:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id CBFF9B34; Wed, 18 Jun 2025 06:54:27 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 038EB139A; Wed, 18 Jun 2025 06:49:58 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 23AFF12E4; Wed, 18 Jun 2025 06:49:52 -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 336DE1279 for ; Wed, 18 Jun 2025 06:49:34 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-508-6k_TQb_iMsC3aHEAPfR1OA-1; Wed, 18 Jun 2025 06:49:32 -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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7515D180028F for ; Wed, 18 Jun 2025 10:49:31 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.226.79]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 773A8180045B for ; Wed, 18 Jun 2025 10:49:30 +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=1750243773; 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=pwxJ7sojz+kk6qrJUfCWzl8Ak0+8/9cfEhMRdWAuEPA=; b=HE5wklnMSO6hYZxPhj1lk+1s+5A38aMmBGDZR2Fh8OhVine8F2qGvTWa0gFXNBTkdyNIYX pkiRSNrPP1ttv5I0lTEOrN7YpjK8dP9lxj/e2+vMN6A/pbMjS6CbzUmuh1F2TNHUIHHHT4 cxKbX8pm0kboNDM7JyY0yRY9pTr/gac= X-MC-Unique: 6k_TQb_iMsC3aHEAPfR1OA-1 X-Mimecast-MFC-AGG-ID: 6k_TQb_iMsC3aHEAPfR1OA_1750243771 To: devel@lists.libvirt.org Subject: [libvirt PATCH v2 5/7] conf: add passthrough and xtsup attributes for IOMMU Date: Wed, 18 Jun 2025 12:46:21 +0200 Message-ID: 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: OmH0AVocfHnQFXjQLOIoaynZYhPCk8k5BOjiOEKlZqc_1750243771 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4DKFUIS32FBOLO26HKR3QW3W4V64LASI X-Message-ID-Hash: 4DKFUIS32FBOLO26HKR3QW3W4V64LASI 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: 1750244069519116600 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 Reviewed-by: Peter Krempa --- 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 7ebb4c3e9e..4c7ec17d45 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -9104,6 +9104,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 12882291a6..2469144a66 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14360,6 +14360,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, @@ -21994,6 +22002,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); } @@ -28261,6 +28283,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 051037eff9..667b3ff10a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3025,6 +3025,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 92b9ba3cc7..1ff441e184 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -6237,6 +6237,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