From nobody Fri Jan 9 08:47:36 2026 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; 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=pass header.i=@intel.com; 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=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1766056919; cv=none; d=zohomail.com; s=zohoarc; b=LmP883FsYqWTtrHAzqZx5o015KatYfgJHwxW3TaaOtaIODJ9Echm60k9DaNv6efAIONMpjDBFGAOzoC6IOwPrDzEotxW/jsvpmT2w1pxiZ1eC7H4LuwXF5JIyo6sf06SKHML6zZCkxlWkX4aq/O31kc7G/4qRomu5tEhSjzbL3M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1766056919; 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:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=3k170rlGEAuA45kq6nXbJzmfQwoFbqZ3d/OnBxr5BzA=; b=grWG21KZe7eacm8G7Oo+dF9JB5iGwTmSFOU79Clh99tp3QwucUQ2LPL0voTkIzTyWy+17yp7XbreerYftUpZpYnoPuVlnKM5j5d16DyHU97+ukDP2HxGb3HRVW+aJy+6qn3tpS7Crl/lNg3lXeRUzR4JKUvBZT4zshKbREspLNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=@intel.com; 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=none dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1766056919841148.76035523941584; Thu, 18 Dec 2025 03:21:59 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id E8E823F33E; Thu, 18 Dec 2025 06:21:58 -0500 (EST) Received: from [172.19.199.83] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 5B80B419B0; Thu, 18 Dec 2025 06:20:51 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 763523F316; Thu, 18 Dec 2025 06:06:24 -0500 (EST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 CD59041871 for ; Thu, 18 Dec 2025 06:06:21 -0500 (EST) Received: from fmviesa005.fm.intel.com ([10.60.135.145]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2025 03:05:13 -0800 Received: from spr-duan.bj.intel.com ([172.16.114.123]) by fmviesa005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Dec 2025 03:05:12 -0800 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1766055982; x=1797591982; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=zUf18Mgt6FXpk+qch1T5C3j69AodrRhQWzDAw3JDNpU=; b=bxNc5Z78ULXO8teDEyreJN5XAFz2dSCXoA3d1CyGRxPmFR/PC4MCPTUL MX1wuHVBVTajqC0VnZEAQ90VsXLBZVfKOwNig0P8F+8oxUXwGqFIeUasj fZDUZ/dmPyQbLsCNQ1AbLb9vQO/qg3pT5uNGct/kBi5Dl84g1HaRaxkCO JJFQo/udTasYDTTvuFRsEC8wwWUxLNZ1SoD5pOcRdNM+r2kZ9Sg7VpRcc lvnEtm1nvUdKrtsUbwjHgEruAlEi4gTBV8DYyod0mpRFWSfvsEpNeNstz hOrB62taJ1rc2LPOahbhWMe29YpYyISlHrfjSR8bEG/h8mPTJPqWPgCeh g==; X-CSE-ConnectionGUID: jN7rfdKfQFSIStiYUM+zag== X-CSE-MsgGUID: S26Kky8yRf63hpsTF+T4NQ== X-IronPort-AV: E=McAfee;i="6800,10657,11645"; a="67885334" X-IronPort-AV: E=Sophos;i="6.21,158,1763452800"; d="scan'208";a="67885334" X-CSE-ConnectionGUID: 98FJnmhoT9KfhjjcQNGl4A== X-CSE-MsgGUID: qIdPxmqwSne+cWaEmZYaQA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.21,158,1763452800"; d="scan'208";a="202948703" From: Zhenzhong Duan To: devel@lists.libvirt.org Subject: [PATCH 2/3] conf: add support for 'scalable_mode' and 'first_stage' attributes to intel IOMMU Date: Thu, 18 Dec 2025 06:04:48 -0500 Message-ID: <20251218110449.53658-3-zhenzhong.duan@intel.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251218110449.53658-1-zhenzhong.duan@intel.com> References: <20251218110449.53658-1-zhenzhong.duan@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ZRHNBTZ3DBYJ5WP2WWVWIT6ZYU52SCDI X-Message-ID-Hash: ZRHNBTZ3DBYJ5WP2WWVWIT6ZYU52SCDI X-MailFrom: zhenzhong.duan@intel.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: nathanc@nvidia.com, clg@redhat.com, Zhenzhong Duan 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: X-ZohoMail-DKIM: pass (identity @intel.com) X-ZM-MESSAGEID: 1766056921396158500 Content-Type: text/plain; charset="utf-8" Correspond to 'x-scalable-mode' and 'x-flts' properties in QEMU. Signed-off-by: Zhenzhong Duan --- docs/formatdomain.rst | 8 +++++++ src/conf/domain_conf.c | 35 ++++++++++++++++++++++++++++++- src/conf/domain_conf.h | 2 ++ src/conf/domain_validate.c | 6 ++++++ src/conf/schemas/domaincommon.rng | 10 +++++++++ 5 files changed, 60 insertions(+), 1 deletion(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index dcb24b1b23..cd130a3f51 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -9250,6 +9250,14 @@ Example: The ``pciBus`` attribute notes the index of the controller that an IOMMU device is attached to. (QEMU/KVM and ``smmuv3`` model only) =20 + ``scalable_mode`` + Enable scalable mode DMA translation. + :since:`Since 11.11.0` (QEMU/KVM and ``intel`` model only) + + ``first_stage`` + Enable first stage translation. + :since:`Since 11.11.0` (QEMU/KVM and ``intel`` 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 6e47ccb23d..5fd573c66b 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -14507,6 +14507,15 @@ virDomainIOMMUDefParseXML(virDomainXMLOption *xmlo= pt, if (virXMLPropInt(driver, "pciBus", 10, VIR_XML_PROP_NONE, &iommu->pci_bus, -1) < 0) return NULL; + + if (virXMLPropTristateSwitch(driver, "scalable_mode", VIR_XML_PROP= _NONE, + &iommu->scalable_mode) < 0) + return NULL; + + if (virXMLPropTristateSwitch(driver, "first_stage", VIR_XML_PROP_N= ONE, + &iommu->fsts) < 0) + return NULL; + } =20 if (virDomainDeviceInfoParseXML(xmlopt, node, ctxt, @@ -16558,7 +16567,9 @@ virDomainIOMMUDefEquals(const virDomainIOMMUDef *a, a->eim !=3D b->eim || a->iotlb !=3D b->iotlb || a->aw_bits !=3D b->aw_bits || - a->dma_translation !=3D b->dma_translation) + a->dma_translation !=3D b->dma_translation || + a->scalable_mode !=3D b->scalable_mode || + a->fsts !=3D b->fsts) return false; =20 if (a->info.type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && @@ -22260,6 +22271,20 @@ virDomainIOMMUDefCheckABIStability(virDomainIOMMUD= ef *src, virTristateSwitchTypeToString(src->xtsup)); return false; } + if (src->scalable_mode !=3D dst->scalable_mode) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain IOMMU device dma translation '%1$s= ' does not match source '%2$s'"), + virTristateSwitchTypeToString(dst->scalable_mode), + virTristateSwitchTypeToString(src->scalable_mode)); + return false; + } + if (src->fsts !=3D dst->fsts) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Target domain IOMMU device dma translation '%1$s= ' does not match source '%2$s'"), + virTristateSwitchTypeToString(dst->fsts), + virTristateSwitchTypeToString(src->fsts)); + return false; + } =20 return virDomainDeviceInfoCheckABIStability(&src->info, &dst->info); } @@ -28574,6 +28599,14 @@ virDomainIOMMUDefFormat(virBuffer *buf, virBufferAsprintf(&driverAttrBuf, " xtsup=3D'%s'", virTristateSwitchTypeToString(iommu->xtsup)); } + if (iommu->scalable_mode !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&driverAttrBuf, " scalable_mode=3D'%s'", + virTristateSwitchTypeToString(iommu->scalable_mo= de)); + } + if (iommu->fsts !=3D VIR_TRISTATE_SWITCH_ABSENT) { + virBufferAsprintf(&driverAttrBuf, " first_stage=3D'%s'", + virTristateSwitchTypeToString(iommu->fsts)); + } if (iommu->pci_bus >=3D 0) { virBufferAsprintf(&driverAttrBuf, " pciBus=3D'%d'", iommu->pci_bus); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index da4ce9fc86..6e381e9b5a 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3063,6 +3063,8 @@ struct _virDomainIOMMUDef { virTristateSwitch dma_translation; virTristateSwitch xtsup; virTristateSwitch pt; + virTristateSwitch scalable_mode; + virTristateSwitch fsts; }; =20 typedef enum { diff --git a/src/conf/domain_validate.c b/src/conf/domain_validate.c index 8bbea5f000..27fe2b490e 100644 --- a/src/conf/domain_validate.c +++ b/src/conf/domain_validate.c @@ -3119,6 +3119,8 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *io= mmu) iommu->aw_bits !=3D 0 || iommu->dma_translation !=3D VIR_TRISTATE_SWITCH_ABSENT || iommu->xtsup !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->scalable_mode !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->fsts !=3D VIR_TRISTATE_SWITCH_ABSENT || iommu->pt !=3D VIR_TRISTATE_SWITCH_ABSENT) { virReportError(VIR_ERR_XML_ERROR, _("iommu model '%1$s' doesn't support some addi= tional attributes"), @@ -3133,6 +3135,8 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *io= mmu) iommu->iotlb !=3D VIR_TRISTATE_SWITCH_ABSENT || iommu->aw_bits !=3D 0 || iommu->dma_translation !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->scalable_mode !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->fsts !=3D VIR_TRISTATE_SWITCH_ABSENT || iommu->pci_bus >=3D 0) { virReportError(VIR_ERR_XML_ERROR, _("iommu model '%1$s' doesn't support additiona= l attributes"), @@ -3146,6 +3150,8 @@ virDomainIOMMUDefValidate(const virDomainIOMMUDef *io= mmu) iommu->eim !=3D VIR_TRISTATE_SWITCH_ABSENT || iommu->aw_bits !=3D 0 || iommu->dma_translation !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->scalable_mode !=3D VIR_TRISTATE_SWITCH_ABSENT || + iommu->fsts !=3D VIR_TRISTATE_SWITCH_ABSENT || iommu->pci_bus >=3D 0) { virReportError(VIR_ERR_XML_ERROR, _("iommu model '%1$s' doesn't support some addi= tional attributes"), diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index 78cf0a08cf..394f23ff4d 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -6332,6 +6332,16 @@ + + + + + + + + + + --=20 2.47.3