From nobody Wed Aug 26 15:02:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1785319705; cv=none; d=zohomail.com; s=zohoarc; b=mnetOczVmN759wtnKgwekztBL38cTrE4MOFmGtaDtdeKMs37cjahYugZvkLWg7Xg3WWwDga2cvh6K/+nI9/uukv1Ma+JUrXbrLB/e/taL3+mUj7IwAbQfRLxpqTK+ene1zLxEm1TJkLKvFYFIr9Lnq/kvaPan5XRxaiujv3nkk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785319705; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kP34VkRmXUHEqgTF9zcqnvF5Ro7DYiwr7LhOjNgGxHI=; b=WnAlbXQ9o35KHhOg6izyKZi4+OtU6T9FOXC+OxzV2l9Otz+uuvkRsR40iNOP0HQASt+ezIO94ifpToVtufHZMVvpSNXa1PHTRwvE4Wd/vpcXvi22BwGVFU15VFSGwyrwcQbaAS8Wx5ibfEa8mGGfne3qtOXYybXUc19tSYw0XpE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785319705504798.9311656410653; Wed, 29 Jul 2026 03:08:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1375439.1622600 (Exim 4.92) (envelope-from ) id 1wp1Cl-0007lP-Qt; Wed, 29 Jul 2026 10:08:03 +0000 Received: by outflank-mailman (output) from mailman id 1375439.1622600; Wed, 29 Jul 2026 10:08:03 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wp1Cl-0007lI-OR; Wed, 29 Jul 2026 10:08:03 +0000 Received: by outflank-mailman (input) for mailman id 1375439; Wed, 29 Jul 2026 10:08:02 +0000 Received: from mx.expurgate.net ([194.145.224.20]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wp1Cj-0007jT-V4 for xen-devel@lists.xenproject.org; Wed, 29 Jul 2026 10:08:01 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wp1Cj-00HNLw-7z for xen-devel@lists.xenproject.org; Wed, 29 Jul 2026 12:08:01 +0200 Received: from [10.42.69.3] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a69d0f3-2eae-0a2a0a5409dd-0a2a45039a82-10 for ; Wed, 29 Jul 2026 12:08:01 +0200 Received: from [185.255.28.18] (helo=prod-mta-13.swg-srv.net) by tlsNG-33051d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a69d100-fae8-0a2a45030019-b9ff1c12832d-3 for ; Wed, 29 Jul 2026 12:08:01 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 19fad586037000e099.002 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 29 Jul 2026 10:07:58 +0000 Received: from localhost.localdomain (88-188-240-210.subs.proxad.net [88.188.240.210]) (Authenticated sender: teddy.astie@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id 451A98320D; Wed, 29 Jul 2026 12:07:57 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=kP34VkRmXUHEqgTF9zcqnvF5Ro7DYiwr7LhOjNgGxHI=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=t67146ahM3hirT1qDy9IsyOBZkzKFtkprnERXBpX+TF/syho6nwNqPTzb+zGNUncoQRSj5Lej 9x5VGyP7o8OettPaiBzC5CUAa/QLzxKaFm4vEgIt+3PvEZ2mUfmpQDkfXHjktBeud+zTXqIKoqB GVgHnSoAlbB8Md04XIp3iKTcBXT+m6XmS9ug/4PnXIShuEqX6hwLsS4oDgpWe699BglXTI1lhwd FjKm3yZLDFM025XqY5FrnfG6siD1VhwHjslPu1nUbcZ/k8ELFNREgio+Dq7TwGgCbodjOUk2zsu eIv7VRb9aObYquYTXn3r2QbPpSWj752Pdd/AjEW0b3ag== X-Zone-Loop: defc1e1d417112baefa663110e8549dbb5d5bf66416d x-campaign-type: default x-transaction-id: 1d1ebdbe-a5fd-4ea0-bdfa-1daaee9e224f x-swg-uid: 01-13b89d0d-80cf-4c56-8878-fa8581d52ba5 X-Mailer: Sweego Message-ID: <1785319678.8631fc262581453bbf619ec5b2062170.19fad586037000e099@vates.tech> x-swg-bid: 1785319678.8631fc262581453bbf619ec5b2062170.19fad586037000e099 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Teddy Astie To: xen-devel@lists.xenproject.org Cc: Teddy Astie , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [RESEND PATCH 1/5] vtd: Ensure root entry is updated consistently Date: Wed, 29 Jul 2026 12:05:39 +0200 In-Reply-To: <1785319236.8631fc262581453bbf619ec5b2062170.19fad51a4be000e099@vates.tech> References: <1785319236.8631fc262581453bbf619ec5b2062170.19fad51a4be000e099@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.1669.af91e764794eb07c.19fad585de6.7c53ed0f29ba61cc=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1785319677415 X-purgate-ID: tlsNG-33051d/1785319681-6CCDB4E9-7B68D1A4/0/0 X-purgate-type: clean X-purgate-size: 2626 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1785319707680158500 ---=Part.1669.af91e764794eb07c.19fad585de6.7c53ed0f29ba61cc=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Make sure the root entry is updated consistently such that the compiler is not allowed to perform optimizations around setting present bit (and i.e set present bit before setting up the pagetable addresss, which would cause the IOMMU to use a pagetable at address 0 instead). This issue can only occurs at boot time where present bit is initially clea= red or when a bus is first introduced in the machine. Fixes: ccfe4e08455f ("Intel vt-d specific changes in arch/x86/hvm/vmx/vtd.") Signed-off-by: Teddy Astie --- xen/drivers/passthrough/vtd/iommu.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/= vtd/iommu.c index 3d6f787b3c..c314ce1db8 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -281,13 +281,13 @@ void free_pgtable_maddr(u64 maddr) /* context entry handling */ static u64 bus_to_context_maddr(struct vtd_iommu *iommu, u8 bus) { - struct root_entry *root, *root_entries; + struct root_entry root, *root_entries; u64 maddr; =20 ASSERT(spin_is_locked(&iommu->lock)); root_entries =3D (struct root_entry *)map_vtd_domain_page(iommu->root_= maddr); - root =3D &root_entries[bus]; - if ( !root_present(*root) ) + root.val =3D ACCESS_ONCE(root_entries[bus].val); + if ( !root_present(root) ) { maddr =3D alloc_pgtable_maddr(1, iommu->node); if ( maddr =3D=3D 0 ) @@ -295,11 +295,12 @@ static u64 bus_to_context_maddr(struct vtd_iommu *iom= mu, u8 bus) unmap_vtd_domain_page(root_entries); return 0; } - set_root_value(*root, maddr); - set_root_present(*root); - iommu_sync_cache(root, sizeof(struct root_entry)); + set_root_value(root, maddr); + set_root_present(root); + ACCESS_ONCE(root_entries[bus].val) =3D root.val; + iommu_sync_cache(&root_entries[bus], sizeof(struct root_entry)); } - maddr =3D (u64) get_context_addr(*root); + maddr =3D (u64) get_context_addr(root); unmap_vtd_domain_page(root_entries); return maddr; } --=20 2.54.0 --=20 Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.1669.af91e764794eb07c.19fad585de6.7c53ed0f29ba61cc=--- From nobody Wed Aug 26 15:02:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1785319406; cv=none; d=zohomail.com; s=zohoarc; b=WJ8eqgqupxpLJDSP6g3a+Him5YT7+w2ons1a9R0q+umQ36vzYft/FMedvKz49eAVHkE36LCDXt28/0hh5cfA/gTmUtdMIVnjPpxXwhTflnPaJC4hQK3CNLBKabIZyHDJZiW+SR2bfMtTfdF5m+m5gdpfLe310O/bD/X+D2gAlxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785319406; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=L72Xz6FWuOgwpG8TgAcFqY54LAvujFyro31yPfEgagc=; b=U3dBAldOGapBAsp1PZPXRQB1F4Ju0YyO+e9gZ0reJ87eQldOce6NXeJXucxjb0gQF3Z4r4K2xhTzsm63RLHui6Ej3vABpNY2RWUzRhl5TKg75MVwKGg97y6zvewL016UTJKP0u5ffCE5pNVAVKUGSYWoY+goniqukIUqT6Pzmmc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785319406445835.4576856712545; Wed, 29 Jul 2026 03:03:26 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1375402.1622565 (Exim 4.92) (envelope-from ) id 1wp17L-0004zt-3e; Wed, 29 Jul 2026 10:02:27 +0000 Received: by outflank-mailman (output) from mailman id 1375402.1622565; Wed, 29 Jul 2026 10:02:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wp17L-0004zm-0z; Wed, 29 Jul 2026 10:02:27 +0000 Received: by outflank-mailman (input) for mailman id 1375402; Wed, 29 Jul 2026 10:02:25 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wp17J-0004yz-HZ for xen-devel@lists.xenproject.org; Wed, 29 Jul 2026 10:02:25 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wp17I-007PyJ-UP for xen-devel@lists.xenproject.org; Wed, 29 Jul 2026 12:02:24 +0200 Received: from [10.42.69.8] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a69cfa2-e002-0a2a0a5209dd-0a2a4508a58a-48 for ; Wed, 29 Jul 2026 12:02:24 +0200 Received: from [185.255.28.34] (helo=prod-mta-13-01.swg-srv.net) by tlsNG-c1860d.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a69cfb0-f659-0a2a45080019-b9ff1c2294b1-3 for ; Wed, 29 Jul 2026 12:02:24 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13-01.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 19fad533bfc000e099.002 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 29 Jul 2026 10:02:21 +0000 Received: from localhost.localdomain (88-188-240-210.subs.proxad.net [88.188.240.210]) (Authenticated sender: teddy.astie@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id 837408312C; Wed, 29 Jul 2026 12:02:18 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=L72Xz6FWuOgwpG8TgAcFqY54LAvujFyro31yPfEgagc=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=dcAD6OC4MKbYLDwX/63dROolu9Z+32//6JOqQaI1iIsogL28rGyEphz5q9+hVkoFLAKrO/6Jx sHo205YywLkYBMZqi4knZ1YqObsxZscqfJhJebF6O2HVfelIKMXr7x9ptBL21TWl5kpYtvrFpxG 8mfL0HbTgvPr9XdAcDnqir8KzL+ExB4hGP+tify3+3OrAi+AK+asJc1QIHr6cvx6Nukt28dhkCh zx3GuoLBcidSFLq7eujOcvg7Qqy6PQ5JFRwlvB78+0VMOWVBHvee2xNYpfaruYZJpTDArpAFvuD 21yGtf5AAww0qU4lGDchcf3XWb21tRHIVTTG9+VZe5dw== X-Zone-Loop: 393318f3b89818c07c15a735954d8b87ec552d17f5b4 x-campaign-type: default x-transaction-id: d712f36d-4dd9-4b5f-a042-d024ade97722 x-swg-uid: 01-5df9e053-648e-459e-a315-db74decaf080 X-Mailer: Sweego Message-ID: <1785319341.8631fc262581453bbf619ec5b2062170.19fad533bfc000e099@vates.tech> x-swg-bid: 1785319341.8631fc262581453bbf619ec5b2062170.19fad533bfc000e099 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Teddy Astie To: xen-devel@lists.xenproject.org Cc: Teddy Astie , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 2/5] vtd: Ensure context entry is cleared properly Date: Wed, 29 Jul 2026 11:59:44 +0200 In-Reply-To: <1785319236.8631fc262581453bbf619ec5b2062170.19fad51a4be000e099@vates.tech> References: <1785319236.8631fc262581453bbf619ec5b2062170.19fad51a4be000e099@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.165e.746cbe8ad397ee00.19fad5332b2.5eb59192ce5ca342=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1785319338674 X-purgate-ID: tlsNG-c1860d/1785319344-D6B4187B-BE92D544/0/0 X-purgate-type: clean X-purgate-size: 2098 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1785319408246158500 ---=Part.165e.746cbe8ad397ee00.19fad5332b2.5eb59192ce5ca342=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When removing a context entry for a device, the present bit needs to be cleared first, then we can clear the rest of the field. In the current logic, the compiler is allowed to perform optimizations in a way where high is cleared before the present bit (which is in low part) is, leading to a window where the context entry is invalid and would make the IOMMU fault (as address width would be set to a reserved value). Fix the logic by ensuring we clear the low part first (which also clears the present bit) then the high part afterward. Fixes: cada0c18f8d1 ("vtd: Move dom0 RMRR check to intel_iommu_remove_devic= e()") Reported-by: Teddy Astie Signed-off-by: Andrew Cooper Signed-off-by: Teddy Astie --- xen/drivers/passthrough/vtd/iommu.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/= vtd/iommu.c index c314ce1db8..1005e200c1 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1889,8 +1889,14 @@ int domain_context_unmap_one( =20 iommu_domid =3D context_domain_id(*context); =20 - context_clear_present(*context); - context_clear_entry(*context); + /* + * Clear the context entry. + * + * As this is performed with two stores, ensure lo (containing the pre= sent + * bit) is cleared first. + */ + ACCESS_ONCE(context->lo) =3D 0; + ACCESS_ONCE(context->hi) =3D 0; iommu_sync_cache(context, sizeof(struct context_entry)); =20 rc =3D iommu_flush_context_device(iommu, iommu_domid, --=20 2.54.0 --=20 Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.165e.746cbe8ad397ee00.19fad5332b2.5eb59192ce5ca342=--- From nobody Wed Aug 26 15:02:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1785319366; cv=none; d=zohomail.com; s=zohoarc; b=SGw0idF0TaP44PomTMyQ0lKTbXdPC9t0/51sip0QzCf79mLuWRvIYmVj1JatO8LbGfZ0fxqEW/WkLLm94LPa1tkmo/uwkjBFuQLL/yOzfFY8e/hP29VZwaqMNaVmwDl54J3mkooAiY7MHG071jIR0MSDGWhKIk3CbPMGZSPhFqc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785319366; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pAkuv/Vm1N/fSTcQURBKADr4OoqbpIuchdK+Q3GlJ8s=; b=fGmB2OyugVKbjHqnQ2YHxW7/RERhuCWAhdWFpxG4lvXFTcuXcIPUL5SKyTrG05r/R5TCoX+PHIRaej1iUkrWCrX/LF7g4jjbyB0Jua4u+g9nxrUbF6tevNzdALNM9mN94HZ8AFSe90wDGs4f8Yp6uY6hq68tR3PIuFyUfltRn5o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 17853193666889.352131218530076; Wed, 29 Jul 2026 03:02:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1375403.1622570 (Exim 4.92) (envelope-from ) id 1wp17L-00051q-GU; Wed, 29 Jul 2026 10:02:27 +0000 Received: by outflank-mailman (output) from mailman id 1375403.1622570; Wed, 29 Jul 2026 10:02:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wp17L-00051Y-87; Wed, 29 Jul 2026 10:02:27 +0000 Received: by outflank-mailman (input) for mailman id 1375403; Wed, 29 Jul 2026 10:02:26 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wp17K-0004zL-0g for xen-devel@lists.xenproject.org; Wed, 29 Jul 2026 10:02:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wp17J-00H4B5-DI for xen-devel@lists.xenproject.org; Wed, 29 Jul 2026 12:02:25 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a69cfaa-5cb7-0a2a0a5109dd-0a2a450bc72c-44 for ; Wed, 29 Jul 2026 12:02:25 +0200 Received: from [185.255.28.18] (helo=prod-mta-13.swg-srv.net) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a69cfb1-b7e8-0a2a450b0019-b9ff1c129c6d-3 for ; Wed, 29 Jul 2026 12:02:25 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 19fad533fa5000e099.002 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 29 Jul 2026 10:02:21 +0000 Received: from localhost.localdomain (88-188-240-210.subs.proxad.net [88.188.240.210]) (Authenticated sender: teddy.astie@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id 718168312C; Wed, 29 Jul 2026 12:02:21 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=pAkuv/Vm1N/fSTcQURBKADr4OoqbpIuchdK+Q3GlJ8s=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=cVDPU7dtRxSa/Rg/xDLhHpuoB6l+WMWY7ozZLaix5NSIgWKQ0357ksaA+ePoWPICwlggi//J0 iMFIBgt4BftG2djd+8Yq38rSfwP/55tePVNwYPcSz65CIewhlGpA50UHfNTGFwUoXI1VuWhyJGC /GaK2+anIFNyKkGX0LX3puewQDcf9R1jZE+vY8WO9rfruqP6Mvw7wE0O7uz1rLzy7an1r4dKwVa 02R71YXjrUv9N/A+NhfP+7YsF0LOHCd3IQ/CmZwHROehLLohqWyLrJCFloX+V/Z9ImqgYjZoy0B 4k3/pOsW77hCmlYWJDBOOMOXxIMXFegXUrZVJtDOyaMQ== X-Zone-Loop: beb9989fdb96ca2408d1c05d77e4feaa6d52e01832a0 x-campaign-type: default x-transaction-id: a2c762af-242f-4275-b252-a04686a8bcb5 x-swg-uid: 01-87d3cbd0-08d9-4ea7-986f-ee981be792b7 X-Mailer: Sweego Message-ID: <1785319342.8631fc262581453bbf619ec5b2062170.19fad533fa5000e099@vates.tech> x-swg-bid: 1785319342.8631fc262581453bbf619ec5b2062170.19fad533fa5000e099 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Teddy Astie To: xen-devel@lists.xenproject.org Cc: Teddy Astie , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 3/5] vtd: Print originating iommu on faults Date: Wed, 29 Jul 2026 11:59:45 +0200 In-Reply-To: <1785319236.8631fc262581453bbf619ec5b2062170.19fad51a4be000e099@vates.tech> References: <1785319236.8631fc262581453bbf619ec5b2062170.19fad51a4be000e099@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.165f.3c636d07eed5d9e9.19fad533e1e.753e7b5c344b1c59=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1785319341598 X-purgate-ID: tlsNG-42698a/1785319345-182F49EA-9FDF0506/0/0 X-purgate-type: clean X-purgate-size: 1340 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1785319367345158500 ---=Part.165f.3c636d07eed5d9e9.19fad533e1e.753e7b5c344b1c59=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" When a fault occurs on a IOMMU, print the IOMMU the fault is coming from. Signed-off-by: Teddy Astie Acked-by: Jan Beulich --- xen/drivers/passthrough/vtd/iommu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/= vtd/iommu.c index 1005e200c1..5e9232d4b1 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -992,8 +992,8 @@ static int iommu_page_fault_do_one(struct vtd_iommu *io= mmu, int type, break; } =20 - printk(XENLOG_G_WARNING VTDPREFIX "%s: reason %02x - %s\n", - kind, fault_reason, reason); + printk(XENLOG_G_WARNING VTDPREFIX "%s: reason %02x - %s on iommu:%u\n", + kind, fault_reason, reason, iommu->index); =20 if ( iommu_verbose && fault_type =3D=3D DMA_REMAP ) print_vtd_entries(iommu, PCI_BUS(source_id), PCI_DEVFN(source_id), --=20 2.54.0 --=20 Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.165f.3c636d07eed5d9e9.19fad533e1e.753e7b5c344b1c59=--- From nobody Wed Aug 26 15:02:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1785319387; cv=none; d=zohomail.com; s=zohoarc; b=B7psEydSPgRyYNLqOI+7x1CbnBje7ugNi80sTEtjezPEBTldp7ofMvuf6GxvQUGkKqNMrr+Q/iQWUv8zoOa+tLZwVt06Z+Ny2ugeRmgJpXfVUt80+13KB1tf7cHxfOMMJYPEQBphg4Lj5FDnW91kSK4s/H3DoRxCYap0VZYFgEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785319387; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vJftr1eo97gxl7wukzI+29dhsDRj5s60nGT0kIopQPk=; b=CG7KtpB5qNTctga0M4G2IvTY9IQk4saGYQpmxO06Bhp14ounk5bm3fw2TdE4QyjR/35gFk5KAI1J9elnMjYoOcjFybMP5L5qcx7QPq+m2kg0y4TZ0EjNECvevPpxQX+WYVrGJSFscxFlU4PUcvyOtRtjvaqueL7p5nqvGLgvPNo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785319387747164.5750761843642; Wed, 29 Jul 2026 03:03:07 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1375404.1622576 (Exim 4.92) (envelope-from ) id 1wp17L-0005Br-Sy; Wed, 29 Jul 2026 10:02:27 +0000 Received: by outflank-mailman (output) from mailman id 1375404.1622576; Wed, 29 Jul 2026 10:02:27 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wp17L-0005Ac-PG; Wed, 29 Jul 2026 10:02:27 +0000 Received: by outflank-mailman (input) for mailman id 1375404; Wed, 29 Jul 2026 10:02:26 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wp17K-0004zW-HC for xen-devel@lists.xenproject.org; Wed, 29 Jul 2026 10:02:26 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wp17J-00H4B5-To for xen-devel@lists.xenproject.org; Wed, 29 Jul 2026 12:02:25 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a69cfaa-5cb7-0a2a0a5109dd-0a2a450bc72c-46 for ; Wed, 29 Jul 2026 12:02:25 +0200 Received: from [185.255.28.18] (helo=prod-mta-13.swg-srv.net) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a69cfb1-b7e8-0a2a450b0019-b9ff1c129c6d-4 for ; Wed, 29 Jul 2026 12:02:25 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 19fad53421a000e099.002 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 29 Jul 2026 10:02:22 +0000 Received: from localhost.localdomain (88-188-240-210.subs.proxad.net [88.188.240.210]) (Authenticated sender: teddy.astie@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id 148788312C; Wed, 29 Jul 2026 12:02:22 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=vJftr1eo97gxl7wukzI+29dhsDRj5s60nGT0kIopQPk=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=Q81bZHxZiyFCKVRsgn5pKOmwOzhsAocSFK20qObhur2vfGV2tSmjfOFZ4+vBotivmh9x1wzP2 qaCEvDiQv08WA75WeZwoxoVRqFx18/4cC1H+gse1VlEVas95VpVSOGD0qoj6zhAcOpkKCfvDZ8s XXqjvEsvUernq4PbYHI+ApceHDrcyr80e/loKl7r2CK92Khydww3ReWzAr/H6EnRvtEI0vr/5S+ CrfsyYimEvVaJ4dle/f7rV1Y0eRFlYGuU9Y7ixqPsGgEzQlMCMFp67fwKjlQqss+5+q3rnYYWCf tVkpU0n3jRpW4MjIUD4mTh7c1fMh1+4kgqie/A4f84SA== X-Zone-Loop: 2f38c52c458c533ecb9b4b440eba7e8525a4c52af488 x-campaign-type: default x-transaction-id: a02325df-5c32-46cd-a500-6e663ef7e2df x-swg-uid: 01-39c0f6fe-8f27-429e-a263-34e7e0ccee1e X-Mailer: Sweego Message-ID: <1785319342.8631fc262581453bbf619ec5b2062170.19fad53421a000e099@vates.tech> x-swg-bid: 1785319342.8631fc262581453bbf619ec5b2062170.19fad53421a000e099 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Teddy Astie To: xen-devel@lists.xenproject.org Cc: Teddy Astie , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 4/5] vtd: Don't disable hwdom passthrough on unhandled SAGAW bits Date: Wed, 29 Jul 2026 11:59:46 +0200 In-Reply-To: <1785319236.8631fc262581453bbf619ec5b2062170.19fad51a4be000e099@vates.tech> References: <1785319236.8631fc262581453bbf619ec5b2062170.19fad51a4be000e099@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.1660.bbb0cd3ae15d8a5.19fad534088.540bf220d1a0f6b=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1785319342216 X-purgate-ID: tlsNG-42698a/1785319345-1B4D39EA-BE6375B1/0/0 X-purgate-type: clean X-purgate-size: 1765 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1785319389509158500 ---=Part.1660.bbb0cd3ae15d8a5.19fad534088.540bf220d1a0f6b=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" On recent VT-d spec, bit 3 indicates support for 5-level pagetables, this is currently considered unhandled and causes "hwdom passthrough" to be disabled, even though it's unrelated. Given these are is capability bits, we don't need to consider unhandled bits, but only make sure that the ones we want (e.g 39-bit or 48-bit AGAW) are set. Fixes: 474fc7d3c652 ("iommu/vt-d: fix SAGAW capability parsing") Signed-off-by: Teddy Astie --- xen/drivers/passthrough/vtd/iommu.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/= vtd/iommu.c index 5e9232d4b1..a3b718d0cc 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -1327,14 +1327,7 @@ int __init iommu_alloc(struct acpi_drhd_unit *drhd) } =20 if ( sagaw >> 3 ) - { - printk_once(XENLOG_WARNING VTDPREFIX - " Unhandled bits in SAGAW %#x%s\n", - sagaw, - iommu_hwdom_passthrough ? ", disabling passthrough" : = ""); - - iommu_hwdom_passthrough =3D false; - } + printk_once(XENLOG_WARNING VTDPREFIX " Unhandled bits in SAGAW %#x= \n", sagaw); =20 iommu->nr_pt_levels =3D agaw_to_level(agaw); if ( min_pt_levels > iommu->nr_pt_levels ) --=20 2.54.0 --=20 Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.1660.bbb0cd3ae15d8a5.19fad534088.540bf220d1a0f6b=--- From nobody Wed Aug 26 15:02:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1785319374; cv=none; d=zohomail.com; s=zohoarc; b=dTXsd/gzqFInGoux5VIrIR/i54IK5YE/Zz7lZw8/YbrXvVm3caNvMOpaQqCNpT6DFl69ldIL85wfuLu18Fu7lx315Enw5WNgmTeWE6k0fmmKEtYEfuo1z8q9UVCQ3Mf97tDHnDinw3+MqMY6rX+nCP6KqLDPqQTQ1vBO/l5XztM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785319374; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=96NWkxxoch+1tQ+w60+vezT9Zo68h4fHDKbXLcZcY90=; b=II7ewrmGYZxth1Rt9rPgRFP7qt3z/eLWMeyJ0qnb++mcTK9U4ICa9nZBA0eGB8dvYQwaaW4AEy3ohxGuzPKBDQLF8/aMYD5zWYh2ewnhvOoYwYoPATpck4hnoTBzMSVqpZqglJwMRPKO5Dmewv7Ynwj5HtpLxHD6jq0wazHEBDY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1785319374417935.8389747027809; Wed, 29 Jul 2026 03:02:54 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1375405.1622583 (Exim 4.92) (envelope-from ) id 1wp17M-0005HW-A1; Wed, 29 Jul 2026 10:02:28 +0000 Received: by outflank-mailman (output) from mailman id 1375405.1622583; Wed, 29 Jul 2026 10:02:28 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wp17M-0005GA-2B; Wed, 29 Jul 2026 10:02:28 +0000 Received: by outflank-mailman (input) for mailman id 1375405; Wed, 29 Jul 2026 10:02:27 +0000 Received: from mx.expurgate.net ([195.190.135.10]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1wp17L-0004zi-2g for xen-devel@lists.xenproject.org; Wed, 29 Jul 2026 10:02:27 +0000 Received: from mx.expurgate.net (helo=localhost) by mx.expurgate.net with esmtp id 1wp17K-007PyJ-Fk for xen-devel@lists.xenproject.org; Wed, 29 Jul 2026 12:02:26 +0200 Received: from [10.42.69.11] (helo=localhost) by localhost with ESMTP (eXpurgate MTA 0.9.1) (envelope-from ) id 6a69cfb2-e002-0a2a0a5209dd-0a2a450bc730-0 for ; Wed, 29 Jul 2026 12:02:26 +0200 Received: from [185.255.28.18] (helo=prod-mta-13.swg-srv.net) by tlsNG-42698a.mxtls.expurgate.net with ESMTPS (eXpurgate 4.57.1) (envelope-from ) id 6a69cfb1-b7e8-0a2a450b0019-b9ff1c129c6d-5 for ; Wed, 29 Jul 2026 12:02:26 +0200 Received: from mail2.vates.fr ([37.26.189.201] mail2.vates.fr) (Authenticated sender: 8631fc262581453bbf619ec5b2062170/smtp/7773de5a-2839-4720-82ee-e06722ae1d3e) by prod-mta-13.swg-srv.net (ZoneMTA - prod-mta-13) with ESMTPSA id 19fad5345fc000e099.002 for (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384); Wed, 29 Jul 2026 10:02:23 +0000 Received: from localhost.localdomain (88-188-240-210.subs.proxad.net [88.188.240.210]) (Authenticated sender: teddy.astie@vates.tech) by mail2.vates.fr (Postfix) with ESMTPSA id AE84C8312C; Wed, 29 Jul 2026 12:02:22 +0200 (CEST) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" Authentication-Results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=vates.tech header.i="@vates.tech" header.h="From:Subject:Date:Message-ID:To:Cc:MIME-Version:Content-Type:In-Reply-To:References:Feedback-ID" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; q=dns/txt; s=selector1; bh=96NWkxxoch+1tQ+w60+vezT9Zo68h4fHDKbXLcZcY90=; h=from:subject:date:message-id:to:cc:mime-version:content-type:in-reply-to:references:feedback-id; b=VJRfeON/55NZj5XXICjtpRABtAImkmzuM0Mn7tl7U9vRDkiyYPoLP03ktG+oWYnV+FGwriyZB xOzI18PY65Sk62tVErtSC/9SMUuRyy20mfmKVfoUGhblhbiE2PjMNluE5QzdF7NkbxVjhaW8OpF oYBXfXL6hwMPhGDr2LORBsLDsIbkhwHCbQCMG7MZJIZPiqJmj77u5CMVIn0NUQK9P8zVXpcGxKr Y5ZR8+0lU/0bx7QdyIHoZvkNt4Z2DPgY3voCMNg9OyaaM4F4kLKvFQIL6rQvrJgiSRcCNM5+1ir 2jYLBTgHD07nFfFei8QVPZHshzfk4ZITinCLTrrU0/1A== X-Zone-Loop: dad82f4b7fba7d10c50f1c2840ddd18f50d62d11570d x-campaign-type: default x-transaction-id: edbbe2e1-6242-47b9-890b-dfa50c2f7f3c x-swg-uid: 01-ced710f2-afb7-4de8-a08c-f954404b2a7f X-Mailer: Sweego Message-ID: <1785319343.8631fc262581453bbf619ec5b2062170.19fad5345fc000e099@vates.tech> x-swg-bid: 1785319343.8631fc262581453bbf619ec5b2062170.19fad5345fc000e099 Feedback-ID: default:8631fc262581453bbf619ec5b2062170:Sweego x-campaign-id: default x-client-id: 8631fc262581453bbf619ec5b2062170 X-Originating-IP: [37.26.189.201] From: Teddy Astie To: xen-devel@lists.xenproject.org Cc: Teddy Astie , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH 5/5] vtd: Move intremap table to xenheap Date: Wed, 29 Jul 2026 11:59:47 +0200 In-Reply-To: <1785319236.8631fc262581453bbf619ec5b2062170.19fad51a4be000e099@vates.tech> References: <1785319236.8631fc262581453bbf619ec5b2062170.19fad51a4be000e099@vates.tech> MIME-Version: 1.0 X-BM-Disclaimer: Yes Content-Type: multipart/alternative; boundary="-=Part.1661.b7e19c699866e3d7.19fad534300.d10821a32adda283=-" X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1785319342849 X-purgate-ID: tlsNG-42698a/1785319346-192CC9EA-4C0FA44B/0/0 X-purgate-type: clean X-purgate-size: 13722 X-ZohoMail-DKIM: pass (identity @vates.tech) X-ZM-MESSAGEID: 1785319375390158500 ---=Part.1661.b7e19c699866e3d7.19fad534300.d10821a32adda283=- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Interrupt remapping entries often needs to be accessed, and we're creating pointers to it on demand, which brings a lot of complexity (e.g GET_IREMAP_ENTRY() macro), move it to xenheap such that it's persistently mapped and we won't have to worry about mapping and unmapping individual intremap table pages. Signed-off-by: Teddy Astie --- xen/drivers/passthrough/vtd/intremap.c | 61 +++++++++----------------- xen/drivers/passthrough/vtd/iommu.h | 16 +------ xen/drivers/passthrough/vtd/utils.c | 22 +++------- 3 files changed, 26 insertions(+), 73 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrou= gh/vtd/intremap.c index dd2788efd7..fc683516cb 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -17,6 +17,7 @@ * Copyright (C) Xiaohui Xin */ =20 +#include #include #include #include @@ -208,21 +209,19 @@ static void update_irte(struct vtd_iommu *iommu, stru= ct iremap_entry *entry, /* Mark specified intr remap entry as free */ static void free_remap_entry(struct vtd_iommu *iommu, int index) { - struct iremap_entry *iremap_entry =3D NULL, *iremap_entries, new_ire = =3D { }; + struct iremap_entry *iremap_entry =3D NULL, new_ire =3D { }; =20 if ( index < 0 || index > IREMAP_ENTRY_NR - 1 ) return; =20 ASSERT(spin_is_locked(&iommu->intremap.lock)); =20 - GET_IREMAP_ENTRY(iommu->intremap.maddr, index, - iremap_entries, iremap_entry); + iremap_entry =3D &iommu->intremap.entries[index]; =20 update_irte(iommu, iremap_entry, &new_ire, false); iommu_sync_cache(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); =20 - unmap_vtd_domain_page(iremap_entries); iommu->intremap.num--; } =20 @@ -232,25 +231,13 @@ static void free_remap_entry(struct vtd_iommu *iommu,= int index) */ static unsigned int alloc_remap_entry(struct vtd_iommu *iommu, unsigned in= t nr) { - struct iremap_entry *iremap_entries =3D NULL; unsigned int i, found; =20 ASSERT(spin_is_locked(&iommu->intremap.lock)); =20 for ( found =3D i =3D 0; i < IREMAP_ENTRY_NR; i++ ) { - struct iremap_entry *p; - if ( i % (1 << IREMAP_ENTRY_ORDER) =3D=3D 0 ) - { - /* This entry across page boundry */ - if ( iremap_entries ) - unmap_vtd_domain_page(iremap_entries); - - GET_IREMAP_ENTRY(iommu->intremap.maddr, i, - iremap_entries, p); - } - else - p =3D &iremap_entries[i % (1 << IREMAP_ENTRY_ORDER)]; + struct iremap_entry *p =3D &iommu->intremap.entries[i]; =20 if ( p->val ) /* not a free entry */ found =3D 0; @@ -258,9 +245,6 @@ static unsigned int alloc_remap_entry(struct vtd_iommu = *iommu, unsigned int nr) break; } =20 - if ( iremap_entries ) - unmap_vtd_domain_page(iremap_entries); - if ( i < IREMAP_ENTRY_NR ) iommu->intremap.num +=3D nr; =20 @@ -270,7 +254,7 @@ static unsigned int alloc_remap_entry(struct vtd_iommu = *iommu, unsigned int nr) static int remap_entry_to_ioapic_rte( struct vtd_iommu *iommu, int index, struct IO_APIC_route_entry *old_rt= e) { - struct iremap_entry *iremap_entry =3D NULL, *iremap_entries; + struct iremap_entry *iremap_entry =3D NULL; unsigned long flags; =20 if ( index < 0 || index > IREMAP_ENTRY_NR - 1 ) @@ -283,15 +267,13 @@ static int remap_entry_to_ioapic_rte( =20 spin_lock_irqsave(&iommu->intremap.lock, flags); =20 - GET_IREMAP_ENTRY(iommu->intremap.maddr, index, - iremap_entries, iremap_entry); + iremap_entry =3D &iommu->intremap.entries[index]; =20 if ( iremap_entry->val =3D=3D 0 ) { dprintk(XENLOG_ERR VTDPREFIX, "IO-APIC index (%d) has an empty entry\n", index); - unmap_vtd_domain_page(iremap_entries); spin_unlock_irqrestore(&iommu->intremap.lock, flags); return -EFAULT; } @@ -309,7 +291,6 @@ static int remap_entry_to_ioapic_rte( old_rte->dest.logical.logical_dest =3D iremap_entry->remap.dst >> = 8; } =20 - unmap_vtd_domain_page(iremap_entries); spin_unlock_irqrestore(&iommu->intremap.lock, flags); =20 return 0; @@ -319,7 +300,7 @@ static int ioapic_rte_to_remap_entry(struct vtd_iommu *= iommu, int apic, unsigned int ioapic_pin, struct IO_APIC_route_entry *old_rte, struct IO_APIC_route_entry new_rte) { - struct iremap_entry *iremap_entry =3D NULL, *iremap_entries; + struct iremap_entry *iremap_entry =3D NULL; struct iremap_entry new_ire; struct IO_APIC_route_remap_entry *remap_rte; int index; @@ -347,8 +328,7 @@ static int ioapic_rte_to_remap_entry(struct vtd_iommu *= iommu, return -EFAULT; } =20 - GET_IREMAP_ENTRY(iommu->intremap.maddr, index, - iremap_entries, iremap_entry); + iremap_entry =3D &iommu->intremap.entries[index]; =20 new_ire =3D *iremap_entry; =20 @@ -388,7 +368,6 @@ static int ioapic_rte_to_remap_entry(struct vtd_iommu *= iommu, iommu_sync_cache(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); =20 - unmap_vtd_domain_page(iremap_entries); spin_unlock_irqrestore(&iommu->intremap.lock, flags); return 0; } @@ -500,7 +479,7 @@ static int msi_msg_to_remap_entry( struct vtd_iommu *iommu, struct pci_dev *pdev, struct msi_desc *msi_desc, struct msi_msg *msg) { - struct iremap_entry *iremap_entry =3D NULL, *iremap_entries, new_ire = =3D { }; + struct iremap_entry *iremap_entry =3D NULL, new_ire =3D { }; struct msi_msg_remap_entry *remap_rte; unsigned int index, i, nr =3D 1; unsigned long flags; @@ -556,8 +535,7 @@ static int msi_msg_to_remap_entry( return -EFAULT; } =20 - GET_IREMAP_ENTRY(iommu->intremap.maddr, index, - iremap_entries, iremap_entry); + iremap_entry =3D &iommu->intremap.entries[index]; =20 if ( !pi_desc ) { @@ -604,7 +582,6 @@ static int msi_msg_to_remap_entry( iommu_sync_cache(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); =20 - unmap_vtd_domain_page(iremap_entries); spin_unlock_irqrestore(&iommu->intremap.lock, flags); =20 return alloc; @@ -628,7 +605,7 @@ int __init cf_check intel_setup_hpet_msi(struct msi_des= c *msi_desc) unsigned long flags; int rc =3D 0; =20 - if ( !iommu->intremap.maddr ) + if ( !iommu->intremap.entries ) return 0; =20 spin_lock_irqsave(&iommu->intremap.lock, flags); @@ -663,7 +640,7 @@ int enable_intremap(struct vtd_iommu *iommu, int eim) sts =3D dmar_readl(iommu->reg, DMAR_GSTS_REG); =20 /* Return if already enabled by Xen */ - if ( (sts & DMA_GSTS_IRES) && iommu->intremap.maddr ) + if ( (sts & DMA_GSTS_IRES) && iommu->intremap.entries ) return 0; =20 if ( !(sts & DMA_GSTS_QIES) ) @@ -679,16 +656,18 @@ int enable_intremap(struct vtd_iommu *iommu, int eim) " Compatibility Format Interrupts permitted on IOMMU #%u:" " Device pass-through will be insecure\n", iommu->index); =20 - if ( iommu->intremap.maddr =3D=3D 0 ) + if ( !iommu->intremap.entries ) { - iommu->intremap.maddr =3D alloc_pgtable_maddr(IREMAP_ARCH_PAGE_NR, - iommu->node); - if ( iommu->intremap.maddr =3D=3D 0 ) + iommu->intremap.entries =3D + alloc_xenheap_pages(get_order_from_pages(IREMAP_ARCH_PAGE_NR), + MEMF_node(iommu->node= )); + if ( !iommu->intremap.entries ) { dprintk(XENLOG_WARNING VTDPREFIX, - "Cannot allocate memory for ir_ctrl->iremap_maddr\n"); + "Cannot allocate memory for iommu->intremap.entries\n"= ); return -ENOMEM; } + memset(iommu->intremap.entries, 0, IREMAP_ARCH_PAGE_NR * PAGE_SIZE= ); =20 iommu->intremap.num =3D 0; } @@ -700,7 +679,7 @@ int enable_intremap(struct vtd_iommu *iommu, int eim) * Interrupt Mode. */ dmar_writeq(iommu->reg, DMAR_IRTA_REG, - iommu->intremap.maddr | IRTA_REG_TABLE_SIZE | + virt_to_maddr(iommu->intremap.entries) | IRTA_REG_TABLE_SI= ZE | (eim ? IRTA_EIME : 0)); =20 /* set SIRTP */ diff --git a/xen/drivers/passthrough/vtd/iommu.h b/xen/drivers/passthrough/= vtd/iommu.h index ccb00889d7..0cd2c2ef3a 100644 --- a/xen/drivers/passthrough/vtd/iommu.h +++ b/xen/drivers/passthrough/vtd/iommu.h @@ -357,20 +357,6 @@ struct iremap_entry { #define iremap_set_present(v) do {(v).lo |=3D 1;} while(0) #define iremap_clear_present(v) do {(v).lo &=3D ~1;} while(0) =20 -/* - * Get the intr remap entry: - * maddr - machine addr of the table - * index - index of the entry - * entries - return addr of the page holding this entry, need unmap it - * entry - return required entry - */ -#define GET_IREMAP_ENTRY(maddr, index, entries, entry) = \ -do { = \ - entries =3D (struct iremap_entry *)map_vtd_domain_page( = \ - (maddr) + (( (index) >> IREMAP_ENTRY_ORDER ) << PAGE_SHIFT )= ); \ - entry =3D &entries[(index) % (1 << IREMAP_ENTRY_ORDER)]; = \ -} while(0) - /* queue invalidation entry */ struct qinval_entry { union { @@ -491,7 +477,7 @@ struct vtd_iommu { uint64_t qinval_maddr; /* queue invalidation page machine address */ =20 struct { - uint64_t maddr; /* interrupt remap table machine address */ + struct iremap_entry *entries; /* interrupt remap table entries */ unsigned int num; /* total num of used interrupt remap entry */ spinlock_t lock; /* lock for irq remapping table */ } intremap; diff --git a/xen/drivers/passthrough/vtd/utils.c b/xen/drivers/passthrough/= vtd/utils.c index 7c4d032f4f..3ae4d35e2d 100644 --- a/xen/drivers/passthrough/vtd/utils.c +++ b/xen/drivers/passthrough/vtd/utils.c @@ -187,11 +187,12 @@ void cf_check vtd_dump_iommu_info(unsigned char key) { /* Dump interrupt remapping table. */ uint64_t irta =3D dmar_readq(iommu->reg, DMAR_IRTA_REG); - uint64_t iremap_maddr =3D irta & PAGE_MASK; unsigned int nr_entry =3D 1 << ((irta & 0xF) + 1); - struct iremap_entry *iremap_entries =3D NULL; unsigned int print_cnt =3D 0; =20 + /* Hardware must be using the same table as us. */ + ASSERT((irta & PAGE_MASK) =3D=3D virt_to_maddr(iommu->intremap= .entries)); + printk(" Interrupt remapping table (nr_entry=3D%#x. " "Only dump P=3D1 entries here):\n", nr_entry); printk("R means remapped format, P means posted format.\n"); @@ -199,18 +200,7 @@ void cf_check vtd_dump_iommu_info(unsigned char key) printk("P: SVT SQ SID V AVL FPD PDA U= RG P\n"); for ( i =3D 0; i < nr_entry; i++ ) { - struct iremap_entry *p; - if ( i % (1 << IREMAP_ENTRY_ORDER) =3D=3D 0 ) - { - /* This entry across page boundry */ - if ( iremap_entries ) - unmap_vtd_domain_page(iremap_entries); - - GET_IREMAP_ENTRY(iremap_maddr, i, - iremap_entries, p); - } - else - p =3D &iremap_entries[i % (1 << IREMAP_ENTRY_ORDER)]; + struct iremap_entry *p =3D &iommu->intremap.entries[i]; =20 if ( !p->remap.p ) continue; @@ -231,8 +221,6 @@ void cf_check vtd_dump_iommu_info(unsigned char key) =20 print_cnt++; } - if ( iremap_entries ) - unmap_vtd_domain_page(iremap_entries); if ( iommu->intremap.num !=3D print_cnt ) printk("Warning: Print %u IRTE (actually have %u)!\n", print_cnt, iommu->intremap.num); @@ -251,7 +239,7 @@ void cf_check vtd_dump_iommu_info(unsigned char key) { iommu =3D ioapic_to_iommu(mp_ioapics[apic].mpc_apicid); =20 - if ( !iommu->intremap.maddr || !iommu->intremap.num ) + if ( !iommu->intremap.entries || !iommu->intremap.num ) continue; =20 printk( "\nRedirection table of IOAPIC %x:\n", apic); --=20 2.54.0 --=20 Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech ---=Part.1661.b7e19c699866e3d7.19fad534300.d10821a32adda283=---