From nobody Wed Oct 29 21:56:40 2025 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 header.i=teddy.astie@vates.tech; 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=reject dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1761210772; cv=none; d=zohomail.com; s=zohoarc; b=itxaC8tY7b0QpxRiBBrfEWLJyiN0RqVZF4eYBKJfk/E+w9eJCdyKwMdzmkTfRV25Z0wq0vJs1+AYbz40jqGK9C4Bn9h759kWtdrdSWCpIHZtgBhIQItgiIZOe8UQk/aNnCuQzY/USFAbfW/nV1BIwZ899koh0rEOFxFXmnn0BYE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761210772; h=Content-Type:Content-Transfer-Encoding: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=TNIECHJXjAZW/QQA5DbqLyVqUBTsMMLyLzIaY0t8Vu8=; b=XcgrWgE4JrbzvYGQGpzt53n0YuhqLPBo82L9NRF37lB7KYTh1Mf3HOrc+BH6CKh8if7/l9KykK17ufZn2ovRhABMt+FkVsqEhtcpc5c8otDk2UD4qwz+c88yKT+DFDMo3qXxJydvz+ePTW4wWr9DGpsoU8lV1jQqgb1TmhrQIYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1761210772845301.98323152886803; Thu, 23 Oct 2025 02:12:52 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1148838.1480706 (Exim 4.92) (envelope-from ) id 1vBrMu-0004Rt-Eh; Thu, 23 Oct 2025 09:12:24 +0000 Received: by outflank-mailman (output) from mailman id 1148838.1480706; Thu, 23 Oct 2025 09:12:24 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vBrMu-0004RL-A1; Thu, 23 Oct 2025 09:12:24 +0000 Received: by outflank-mailman (input) for mailman id 1148838; Thu, 23 Oct 2025 09:12:23 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vBrMt-0003Xf-3Q for xen-devel@lists.xenproject.org; Thu, 23 Oct 2025 09:12:23 +0000 Received: from mail187-3.suw11.mandrillapp.com (mail187-3.suw11.mandrillapp.com [198.2.187.3]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 617fb943-aff0-11f0-9d15-b5c5bf9af7f9; Thu, 23 Oct 2025 11:12:21 +0200 (CEST) Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail187-3.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4csgKG6yMPzDRm0l3 for ; Thu, 23 Oct 2025 09:12:18 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id f64d70b8ebde43beb15453b031bfe318; Thu, 23 Oct 2025 09:12:18 +0000 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" X-Inumbo-ID: 617fb943-aff0-11f0-9d15-b5c5bf9af7f9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1761210739; x=1761480739; bh=TNIECHJXjAZW/QQA5DbqLyVqUBTsMMLyLzIaY0t8Vu8=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=giNn3/G38rxzIH435qPlGZluIkS1JxThbQmMoRRyCh5Z5kJpXX5x6uyIVXLKU/Hrr rhLg28VBTqesa6zdgMMrGe7FBvTVqvj5cuFCav0gkh0voWqp8R0obt2ebyfbXFfuph tVan7uDI3tc4QDI9e6v5/VNEAklFBjRtkygQtvjD0hEQucXKfc4U9/HhHuoHvVWzYK oGb4x9VJwa6GUt5u9DGzABkJa8dURi9Ir9AP+IZankh4tzFD0vjmzJqSoHBlf3mXqW mmmCqiT6gamTLsV/vcq3wSfQ9xCY5CrIHrvx4w0Ota0WZbtT2+Ov7jpXMVIzg8f5eM Xcdbu4WmPqVig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1761210739; x=1761471239; i=teddy.astie@vates.tech; bh=TNIECHJXjAZW/QQA5DbqLyVqUBTsMMLyLzIaY0t8Vu8=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=T7W8qKfDPzu3AwMJXSwDmsasvHXVYt7Y5wsIZ4KPz/x6LwjPvZHqjEIbs6V9iN19B P6z4p6B61ZEki/4GZKYSTlkl0Y/YKf6C4/9nRhl49FlLZQPG+nYsAD2J/QAYeLQWlH +2DlCom8jokAE3zUx8Hk+Ri8wC/lXvy6nqjYW7+4Xb/FX4k0EtHv5yFyaWvXpkG+Bx LxWN22LhFCjGc9QisNQ5qhiEREznZkMLzkxIuS/WcnTb1NkqpC5un4kjK8zKLwOFJx mu3bJN9ysthMTDA0rdhBob41N+y9bTE6YBgweiFSL36pPFCYzphulmMXRBXgzmRiYQ xa/g1MMxhTj6Q== From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=20v2=201/5]=20vtd:=20Drop=20(un)map=5Fvtd=5Fdomain=5Fpage=20wrapper?= X-Mailer: git-send-email 2.51.1 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1761210736376 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" Message-Id: In-Reply-To: References: X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.f64d70b8ebde43beb15453b031bfe318?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20251023:md Date: Thu, 23 Oct 2025 09:12:18 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity teddy.astie@vates.tech) (identity @mandrillapp.com) X-ZM-MESSAGEID: 1761210774647154100 Content-Type: text/plain; charset="utf-8" Replace use of (un)map_vtd_domain_page with its general equivalents. Also take the opportunity to make iommu->root_page (previously root_maddr) use struct page_info instead of u64. Signed-off-by: Teddy Astie --- v2: - drop instead of moving - also replace `root_addr` with `root_page` (with struct page_info) xen/drivers/passthrough/vtd/dmar.c | 2 +- xen/drivers/passthrough/vtd/extern.h | 3 - xen/drivers/passthrough/vtd/intremap.c | 15 +++-- xen/drivers/passthrough/vtd/iommu.c | 88 ++++++++++++-------------- xen/drivers/passthrough/vtd/iommu.h | 7 +- xen/drivers/passthrough/vtd/qinval.c | 13 ++-- xen/drivers/passthrough/vtd/utils.c | 25 ++++---- xen/drivers/passthrough/vtd/x86/ats.c | 11 ++-- xen/drivers/passthrough/vtd/x86/vtd.c | 10 --- 9 files changed, 80 insertions(+), 94 deletions(-) diff --git a/xen/drivers/passthrough/vtd/dmar.c b/xen/drivers/passthrough/v= td/dmar.c index 91c22b8330..2380825f1c 100644 --- a/xen/drivers/passthrough/vtd/dmar.c +++ b/xen/drivers/passthrough/vtd/dmar.c @@ -1107,7 +1107,7 @@ int __init acpi_dmar_init(void) if ( rhsa ) iommu->node =3D pxm_to_node(rhsa->proximity_domain); =20 - if ( !(iommu->root_maddr =3D alloc_pgtable_maddr(1, iommu->node)) ) + if ( !(iommu->root_page =3D maddr_to_page(alloc_pgtable_maddr(1, i= ommu->node))) ) ret =3D -ENOMEM; } =20 diff --git a/xen/drivers/passthrough/vtd/extern.h b/xen/drivers/passthrough= /vtd/extern.h index c16583c951..2be50de168 100644 --- a/xen/drivers/passthrough/vtd/extern.h +++ b/xen/drivers/passthrough/vtd/extern.h @@ -77,9 +77,6 @@ int __must_check qinval_device_iotlb_sync(struct vtd_iomm= u *iommu, u16 did, u16 size, u64 addr); =20 uint64_t alloc_pgtable_maddr(unsigned long npages, nodeid_t node); -void free_pgtable_maddr(u64 maddr); -void *map_vtd_domain_page(u64 maddr); -void unmap_vtd_domain_page(const void *va); int domain_context_mapping_one(struct domain *domain, struct vtd_iommu *io= mmu, uint8_t bus, uint8_t devfn, const struct pci_dev *pdev, domid_t domid, diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrou= gh/vtd/intremap.c index 7726ee618a..6c779d476d 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 @@ -222,7 +223,7 @@ static void free_remap_entry(struct vtd_iommu *iommu, i= nt index) iommu_sync_cache(iremap_entry, sizeof(*iremap_entry)); iommu_flush_iec_index(iommu, 0, index); =20 - unmap_vtd_domain_page(iremap_entries); + unmap_domain_page(iremap_entries); iommu->intremap.num--; } =20 @@ -244,7 +245,7 @@ static unsigned int alloc_remap_entry(struct vtd_iommu = *iommu, unsigned int nr) { /* This entry across page boundry */ if ( iremap_entries ) - unmap_vtd_domain_page(iremap_entries); + unmap_domain_page(iremap_entries); =20 GET_IREMAP_ENTRY(iommu->intremap.maddr, i, iremap_entries, p); @@ -259,7 +260,7 @@ static unsigned int alloc_remap_entry(struct vtd_iommu = *iommu, unsigned int nr) } =20 if ( iremap_entries ) - unmap_vtd_domain_page(iremap_entries); + unmap_domain_page(iremap_entries); =20 if ( i < IREMAP_ENTRY_NR ) iommu->intremap.num +=3D nr; @@ -291,7 +292,7 @@ static int remap_entry_to_ioapic_rte( dprintk(XENLOG_ERR VTDPREFIX, "IO-APIC index (%d) has an empty entry\n", index); - unmap_vtd_domain_page(iremap_entries); + unmap_domain_page(iremap_entries); spin_unlock_irqrestore(&iommu->intremap.lock, flags); return -EFAULT; } @@ -309,7 +310,7 @@ 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); + unmap_domain_page(iremap_entries); spin_unlock_irqrestore(&iommu->intremap.lock, flags); =20 return 0; @@ -388,7 +389,7 @@ 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); + unmap_domain_page(iremap_entries); spin_unlock_irqrestore(&iommu->intremap.lock, flags); return 0; } @@ -607,7 +608,7 @@ 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); + unmap_domain_page(iremap_entries); spin_unlock_irqrestore(&iommu->intremap.lock, flags); =20 return alloc; diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/= vtd/iommu.c index 90f36ac22b..5bd4f19848 100644 --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -272,12 +272,6 @@ uint64_t alloc_pgtable_maddr(unsigned long npages, nod= eid_t node) return page_to_maddr(pg); } =20 -void free_pgtable_maddr(u64 maddr) -{ - if ( maddr !=3D 0 ) - free_domheap_page(maddr_to_page(maddr)); -} - /* context entry handling */ static u64 bus_to_context_maddr(struct vtd_iommu *iommu, u8 bus) { @@ -285,14 +279,14 @@ static u64 bus_to_context_maddr(struct vtd_iommu *iom= mu, u8 bus) u64 maddr; =20 ASSERT(spin_is_locked(&iommu->lock)); - root_entries =3D (struct root_entry *)map_vtd_domain_page(iommu->root_= maddr); + root_entries =3D __map_domain_page(iommu->root_page); root =3D &root_entries[bus]; if ( !root_present(*root) ) { maddr =3D alloc_pgtable_maddr(1, iommu->node); if ( maddr =3D=3D 0 ) { - unmap_vtd_domain_page(root_entries); + unmap_domain_page(root_entries); return 0; } set_root_value(*root, maddr); @@ -300,7 +294,7 @@ static u64 bus_to_context_maddr(struct vtd_iommu *iommu= , u8 bus) iommu_sync_cache(root, sizeof(struct root_entry)); } maddr =3D (u64) get_context_addr(*root); - unmap_vtd_domain_page(root_entries); + unmap_domain_page(root_entries); return maddr; } =20 @@ -344,7 +338,7 @@ static uint64_t addr_to_dma_page_maddr(struct domain *d= omain, daddr_t addr, } =20 pte_maddr =3D hd->arch.vtd.pgd_maddr; - parent =3D map_vtd_domain_page(pte_maddr); + parent =3D map_domain_page(maddr_to_mfn(pte_maddr)); while ( level > target ) { offset =3D address_level_offset(addr, level); @@ -388,7 +382,7 @@ static uint64_t addr_to_dma_page_maddr(struct domain *d= omain, daddr_t addr, =20 if ( dma_pte_present(*pte) ) { - struct dma_pte *split =3D map_vtd_domain_page(pte_maddr); + struct dma_pte *split =3D map_domain_page(maddr_to_mfn(pte= _maddr)); unsigned long inc =3D 1UL << level_to_offset_bits(level - = 1); =20 split[0].val |=3D pte->val & ~DMA_PTE_CONTIG_MASK; @@ -400,7 +394,7 @@ static uint64_t addr_to_dma_page_maddr(struct domain *d= omain, daddr_t addr, (split[offset - 1].val & ~DMA_PTE_CONTIG_MASK) + i= nc; =20 iommu_sync_cache(split, PAGE_SIZE); - unmap_vtd_domain_page(split); + unmap_domain_page(split); =20 if ( flush_flags ) *flush_flags |=3D IOMMU_FLUSHF_modified; @@ -422,11 +416,11 @@ static uint64_t addr_to_dma_page_maddr(struct domain = *domain, daddr_t addr, break; } =20 - unmap_vtd_domain_page(parent); - parent =3D map_vtd_domain_page(pte_maddr); + unmap_domain_page(parent); + parent =3D map_domain_page(maddr_to_mfn(pte_maddr)); } =20 - unmap_vtd_domain_page(parent); + unmap_domain_page(parent); out: return pte_maddr; } @@ -469,10 +463,10 @@ static paddr_t domain_pgd_maddr(struct domain *d, pad= dr_t pgd_maddr, agaw !=3D level_to_agaw(nr_pt_levels); agaw-- ) { - const struct dma_pte *p =3D map_vtd_domain_page(pgd_maddr); + const struct dma_pte *p =3D map_domain_page(maddr_to_mfn(pgd_maddr= )); =20 pgd_maddr =3D dma_pte_addr(*p); - unmap_vtd_domain_page(p); + unmap_domain_page(p); if ( !pgd_maddr ) return 0; } @@ -815,7 +809,7 @@ static int iommu_set_root_entry(struct vtd_iommu *iommu) unsigned long flags; =20 spin_lock_irqsave(&iommu->register_lock, flags); - dmar_writeq(iommu->reg, DMAR_RTADDR_REG, iommu->root_maddr); + dmar_writeq(iommu->reg, DMAR_RTADDR_REG, page_to_maddr(iommu->root_pag= e)); =20 sts =3D dmar_readl(iommu->reg, DMAR_GSTS_REG); dmar_writel(iommu->reg, DMAR_GCMD_REG, sts | DMA_GCMD_SRTP); @@ -1408,10 +1402,10 @@ void __init iommu_free(struct acpi_drhd_unit *drhd) =20 drhd->iommu =3D NULL; =20 - if ( iommu->root_maddr !=3D 0 ) + if ( iommu->root_page ) { - free_pgtable_maddr(iommu->root_maddr); - iommu->root_maddr =3D 0; + free_domheap_page(iommu->root_page); + iommu->root_page =3D NULL; } =20 if ( iommu->reg ) @@ -1504,7 +1498,7 @@ int domain_context_mapping_one( spin_unlock(&iommu->lock); return -ENOMEM; } - context_entries =3D (struct context_entry *)map_vtd_domain_page(maddr); + context_entries =3D map_domain_page(maddr_to_mfn(maddr)); context =3D &context_entries[devfn]; old =3D (lctxt =3D *context).full; =20 @@ -1521,7 +1515,7 @@ int domain_context_mapping_one( if ( !prev_dom ) { spin_unlock(&iommu->lock); - unmap_vtd_domain_page(context_entries); + unmap_domain_page(context_entries); dprintk(XENLOG_DEBUG VTDPREFIX, "no domain for did %u (nr_dom %u)\n", prev_did, cap_ndoms(iommu->cap)); @@ -1544,7 +1538,7 @@ int domain_context_mapping_one( { spin_unlock(&hd->arch.mapping_lock); spin_unlock(&iommu->lock); - unmap_vtd_domain_page(context_entries); + unmap_domain_page(context_entries); if ( prev_dom ) rcu_unlock_domain(prev_dom); return -ENOMEM; @@ -1564,7 +1558,7 @@ int domain_context_mapping_one( { unlock: spin_unlock(&iommu->lock); - unmap_vtd_domain_page(context_entries); + unmap_domain_page(context_entries); if ( prev_dom ) rcu_unlock_domain(prev_dom); return rc; @@ -1632,7 +1626,7 @@ int domain_context_mapping_one( =20 set_bit(iommu->index, hd->arch.vtd.iommu_bitmap); =20 - unmap_vtd_domain_page(context_entries); + unmap_domain_page(context_entries); =20 if ( !seg && !rc ) rc =3D me_wifi_quirk(domain, bus, devfn, domid, pgd_maddr, mode); @@ -1864,13 +1858,13 @@ int domain_context_unmap_one( spin_unlock(&iommu->lock); return 0; } - context_entries =3D (struct context_entry *)map_vtd_domain_page(maddr); + context_entries =3D map_domain_page(maddr_to_mfn(maddr)); context =3D &context_entries[devfn]; =20 if ( !context_present(*context) ) { spin_unlock(&iommu->lock); - unmap_vtd_domain_page(context_entries); + unmap_domain_page(context_entries); return 0; } =20 @@ -1902,7 +1896,7 @@ int domain_context_unmap_one( rc =3D 0; =20 spin_unlock(&iommu->lock); - unmap_vtd_domain_page(context_entries); + unmap_domain_page(context_entries); =20 if ( !iommu->drhd->segment && !rc ) rc =3D me_wifi_quirk(domain, bus, devfn, DOMID_INVALID, 0, @@ -2101,7 +2095,7 @@ static int __must_check cf_check intel_iommu_map_page( return -ENOMEM; } =20 - page =3D (struct dma_pte *)map_vtd_domain_page(pg_maddr); + page =3D map_domain_page(maddr_to_mfn(pg_maddr)); pte =3D &page[address_level_offset(dfn_to_daddr(dfn), level)]; old =3D *pte; =20 @@ -2119,7 +2113,7 @@ static int __must_check cf_check intel_iommu_map_page( if ( !((old.val ^ new.val) & ~DMA_PTE_CONTIG_MASK) ) { spin_unlock(&hd->arch.mapping_lock); - unmap_vtd_domain_page(page); + unmap_domain_page(page); return 0; } =20 @@ -2142,7 +2136,7 @@ static int __must_check cf_check intel_iommu_map_page( { struct page_info *pg =3D maddr_to_page(pg_maddr); =20 - unmap_vtd_domain_page(page); + unmap_domain_page(page); =20 new.val &=3D ~(LEVEL_MASK << level_to_offset_bits(level)); dma_set_pte_superpage(new); @@ -2151,7 +2145,7 @@ static int __must_check cf_check intel_iommu_map_page( flush_flags, false); BUG_ON(pg_maddr < PAGE_SIZE); =20 - page =3D map_vtd_domain_page(pg_maddr); + page =3D map_domain_page(maddr_to_mfn(pg_maddr)); pte =3D &page[address_level_offset(dfn_to_daddr(dfn), level)]; *pte =3D new; iommu_sync_cache(pte, sizeof(*pte)); @@ -2162,7 +2156,7 @@ static int __must_check cf_check intel_iommu_map_page( } =20 spin_unlock(&hd->arch.mapping_lock); - unmap_vtd_domain_page(page); + unmap_domain_page(page); =20 *flush_flags |=3D IOMMU_FLUSHF_added; if ( dma_pte_present(old) ) @@ -2209,13 +2203,13 @@ static int __must_check cf_check intel_iommu_unmap_= page( return pg_maddr ? -ENOMEM : 0; } =20 - page =3D map_vtd_domain_page(pg_maddr); + page =3D map_domain_page(maddr_to_mfn(pg_maddr)); pte =3D &page[address_level_offset(addr, level)]; =20 if ( !dma_pte_present(*pte) ) { spin_unlock(&hd->arch.mapping_lock); - unmap_vtd_domain_page(page); + unmap_domain_page(page); return 0; } =20 @@ -2230,12 +2224,12 @@ static int __must_check cf_check intel_iommu_unmap_= page( { struct page_info *pg =3D maddr_to_page(pg_maddr); =20 - unmap_vtd_domain_page(page); + unmap_domain_page(page); =20 pg_maddr =3D addr_to_dma_page_maddr(d, addr, level, flush_flags, f= alse); BUG_ON(pg_maddr < PAGE_SIZE); =20 - page =3D map_vtd_domain_page(pg_maddr); + page =3D map_domain_page(maddr_to_mfn(pg_maddr)); pte =3D &page[address_level_offset(addr, level)]; dma_clear_pte(*pte); iommu_sync_cache(pte, sizeof(*pte)); @@ -2247,7 +2241,7 @@ static int __must_check cf_check intel_iommu_unmap_pa= ge( =20 spin_unlock(&hd->arch.mapping_lock); =20 - unmap_vtd_domain_page(page); + unmap_domain_page(page); =20 *flush_flags |=3D IOMMU_FLUSHF_modified; =20 @@ -3052,7 +3046,7 @@ static void vtd_dump_page_table_level(paddr_t pt_madd= r, int level, paddr_t gpa, if ( level < 1 ) return; =20 - pt_vaddr =3D map_vtd_domain_page(pt_maddr); + pt_vaddr =3D map_domain_page(maddr_to_mfn(pt_maddr)); =20 next_level =3D level - 1; for ( i =3D 0; i < PTE_NUM; i++ ) @@ -3077,7 +3071,7 @@ static void vtd_dump_page_table_level(paddr_t pt_madd= r, int level, paddr_t gpa, dma_pte_write(*pte) ? 'w' : '-'); } =20 - unmap_vtd_domain_page(pt_vaddr); + unmap_domain_page(pt_vaddr); } =20 static void cf_check vtd_dump_page_tables(struct domain *d) @@ -3119,9 +3113,9 @@ static int fill_qpt(struct dma_pte *this, unsigned in= t level, =20 if ( level ) { - next =3D map_vtd_domain_page(page_to_maddr(pgs[level])= ); + next =3D __map_domain_page(pgs[level]); rc =3D fill_qpt(next, level - 1, pgs); - unmap_vtd_domain_page(next); + unmap_domain_page(next); } } =20 @@ -3131,9 +3125,9 @@ static int fill_qpt(struct dma_pte *this, unsigned in= t level, } else if ( level && !dma_pte_superpage(*pte) ) { - next =3D map_vtd_domain_page(dma_pte_addr(*pte)); + next =3D map_domain_page(maddr_to_mfn(dma_pte_addr(*pte))); rc =3D fill_qpt(next, level - 1, pgs); - unmap_vtd_domain_page(next); + unmap_domain_page(next); } } =20 @@ -3204,9 +3198,9 @@ static int cf_check intel_iommu_quarantine_init(struc= t pci_dev *pdev, struct dma_pte *root; struct page_info *pgs[6] =3D {}; =20 - root =3D map_vtd_domain_page(pdev->arch.vtd.pgd_maddr); + root =3D map_domain_page(maddr_to_mfn(pdev->arch.vtd.pgd_maddr)); rc =3D fill_qpt(root, level - 1, pgs); - unmap_vtd_domain_page(root); + unmap_domain_page(root); =20 pdev->arch.leaf_mfn =3D page_to_mfn(pgs[0]); } diff --git a/xen/drivers/passthrough/vtd/iommu.h b/xen/drivers/passthrough/= vtd/iommu.h index 29d350b23d..7c40f81408 100644 --- a/xen/drivers/passthrough/vtd/iommu.h +++ b/xen/drivers/passthrough/vtd/iommu.h @@ -19,6 +19,7 @@ #ifndef DRIVERS__PASSTHROUGH__VTD__IOMMU_H #define DRIVERS__PASSTHROUGH__VTD__IOMMU_H =20 +#include #include #include =20 @@ -366,8 +367,8 @@ struct iremap_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 )= ); \ + entries =3D (struct iremap_entry *)map_domain_page(maddr_to_mfn( = \ + (maddr) + (( (index) >> IREMAP_ENTRY_ORDER ) << PAGE_SHIFT )= ));\ entry =3D &entries[(index) % (1 << IREMAP_ENTRY_ORDER)]; = \ } while(0) =20 @@ -482,7 +483,7 @@ struct vtd_iommu { u64 ecap; spinlock_t lock; /* protect context */ spinlock_t register_lock; /* protect iommu register handling */ - u64 root_maddr; /* root entry machine address */ + struct page_info *root_page; /* root entry page */ nodeid_t node; struct msi_desc msi; struct acpi_drhd_unit *drhd; diff --git a/xen/drivers/passthrough/vtd/qinval.c b/xen/drivers/passthrough= /vtd/qinval.c index 036f3e8505..eb37832363 100644 --- a/xen/drivers/passthrough/vtd/qinval.c +++ b/xen/drivers/passthrough/vtd/qinval.c @@ -18,6 +18,7 @@ */ =20 =20 +#include #include #include #include @@ -81,7 +82,7 @@ static struct qinval_entry *qi_map_entry(const struct vtd= _iommu *iommu, { paddr_t base =3D iommu->qinval_maddr + ((index * sizeof(struct qinval_entry)) & PAGE_MASK); - struct qinval_entry *entries =3D map_vtd_domain_page(base); + struct qinval_entry *entries =3D map_domain_page(maddr_to_mfn(base)); =20 return &entries[index % (PAGE_SIZE / sizeof(*entries))]; } @@ -111,7 +112,7 @@ static int __must_check queue_invalidate_context_sync(s= truct vtd_iommu *iommu, qinval_update_qtail(iommu, index); spin_unlock_irqrestore(&iommu->register_lock, flags); =20 - unmap_vtd_domain_page(qinval_entry); + unmap_domain_page(qinval_entry); =20 return invalidate_sync(iommu); } @@ -145,7 +146,7 @@ static int __must_check queue_invalidate_iotlb_sync(str= uct vtd_iommu *iommu, qinval_update_qtail(iommu, index); spin_unlock_irqrestore(&iommu->register_lock, flags); =20 - unmap_vtd_domain_page(qinval_entry); + unmap_domain_page(qinval_entry); =20 return invalidate_sync(iommu); } @@ -176,7 +177,7 @@ static int __must_check queue_invalidate_wait(struct vt= d_iommu *iommu, qinval_update_qtail(iommu, index); spin_unlock_irqrestore(&iommu->register_lock, flags); =20 - unmap_vtd_domain_page(qinval_entry); + unmap_domain_page(qinval_entry); =20 /* Now we don't support interrupt method */ if ( sw ) @@ -277,7 +278,7 @@ int qinval_device_iotlb_sync(struct vtd_iommu *iommu, s= truct pci_dev *pdev, qinval_update_qtail(iommu, index); spin_unlock_irqrestore(&iommu->register_lock, flags); =20 - unmap_vtd_domain_page(qinval_entry); + unmap_domain_page(qinval_entry); =20 return dev_invalidate_sync(iommu, pdev, did); } @@ -305,7 +306,7 @@ static int __must_check queue_invalidate_iec_sync(struc= t vtd_iommu *iommu, qinval_update_qtail(iommu, index); spin_unlock_irqrestore(&iommu->register_lock, flags); =20 - unmap_vtd_domain_page(qinval_entry); + unmap_domain_page(qinval_entry); =20 ret =3D invalidate_sync(iommu); =20 diff --git a/xen/drivers/passthrough/vtd/utils.c b/xen/drivers/passthrough/= vtd/utils.c index 7c4d032f4f..5d365ea4e9 100644 --- a/xen/drivers/passthrough/vtd/utils.c +++ b/xen/drivers/passthrough/vtd/utils.c @@ -18,6 +18,7 @@ =20 #include #include +#include #include #include #include @@ -99,38 +100,38 @@ void print_vtd_entries(struct vtd_iommu *iommu, int bu= s, int devfn, u64 gmfn) iommu->index, &PCI_SBDF(iommu->drhd->segment, bus, devfn), gmfn); =20 - if ( iommu->root_maddr =3D=3D 0 ) + if ( iommu->root_page =3D=3D NULL ) { - printk(" iommu->root_maddr =3D 0\n"); + printk(" iommu->root_maddr =3D NULL\n"); return; } =20 - root_entry =3D (struct root_entry *)map_vtd_domain_page(iommu->root_ma= ddr); + root_entry =3D __map_domain_page(iommu->root_page); =20 printk(" root_entry[%02x] =3D %"PRIx64"\n", bus, root_entry[bus].va= l); if ( !root_present(root_entry[bus]) ) { - unmap_vtd_domain_page(root_entry); + unmap_domain_page(root_entry); printk(" root_entry[%02x] not present\n", bus); return; } =20 val =3D root_entry[bus].val; - unmap_vtd_domain_page(root_entry); - ctxt_entry =3D map_vtd_domain_page(val); + unmap_domain_page(root_entry); + ctxt_entry =3D map_domain_page(maddr_to_mfn(val)); =20 val =3D ctxt_entry[devfn].lo; printk(" context[%02x] =3D %"PRIx64"_%"PRIx64"\n", devfn, ctxt_entry[devfn].hi, val); if ( !context_present(ctxt_entry[devfn]) ) { - unmap_vtd_domain_page(ctxt_entry); + unmap_domain_page(ctxt_entry); printk(" ctxt_entry[%02x] not present\n", devfn); return; } =20 level =3D agaw_to_level(context_address_width(ctxt_entry[devfn])); - unmap_vtd_domain_page(ctxt_entry); + unmap_domain_page(ctxt_entry); if ( level !=3D VTD_PAGE_TABLE_LEVEL_3 && level !=3D VTD_PAGE_TABLE_LEVEL_4) { @@ -140,10 +141,10 @@ void print_vtd_entries(struct vtd_iommu *iommu, int b= us, int devfn, u64 gmfn) =20 do { - l =3D map_vtd_domain_page(val); + l =3D map_domain_page(maddr_to_mfn(val)); l_index =3D get_level_index(gmfn, level); pte.val =3D l[l_index]; - unmap_vtd_domain_page(l); + unmap_domain_page(l); printk(" l%u[%03x] =3D %"PRIx64" %c%c\n", level, l_index, pte.v= al, dma_pte_read(pte) ? 'r' : '-', dma_pte_write(pte) ? 'w' : '-'); @@ -204,7 +205,7 @@ void cf_check vtd_dump_iommu_info(unsigned char key) { /* This entry across page boundry */ if ( iremap_entries ) - unmap_vtd_domain_page(iremap_entries); + unmap_domain_page(iremap_entries); =20 GET_IREMAP_ENTRY(iremap_maddr, i, iremap_entries, p); @@ -232,7 +233,7 @@ void cf_check vtd_dump_iommu_info(unsigned char key) print_cnt++; } if ( iremap_entries ) - unmap_vtd_domain_page(iremap_entries); + unmap_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); diff --git a/xen/drivers/passthrough/vtd/x86/ats.c b/xen/drivers/passthroug= h/vtd/x86/ats.c index 61052ef580..fed3588e8e 100644 --- a/xen/drivers/passthrough/vtd/x86/ats.c +++ b/xen/drivers/passthrough/vtd/x86/ats.c @@ -16,6 +16,7 @@ * Author: Allen Kay */ =20 +#include #include #include #include @@ -83,17 +84,17 @@ static bool device_in_domain(const struct vtd_iommu *io= mmu, unsigned int tt; bool found =3D false; =20 - if ( unlikely(!iommu->root_maddr) ) + if ( unlikely(!iommu->root_page) ) { ASSERT_UNREACHABLE(); return false; } =20 - root_entry =3D map_vtd_domain_page(iommu->root_maddr); + root_entry =3D __map_domain_page(iommu->root_page); if ( !root_present(root_entry[pdev->bus]) ) goto out; =20 - ctxt_entry =3D map_vtd_domain_page(root_entry[pdev->bus].val); + ctxt_entry =3D map_domain_page(maddr_to_mfn(root_entry[pdev->bus].val)= ); if ( context_domain_id(ctxt_entry[pdev->devfn]) !=3D did ) goto out; =20 @@ -104,10 +105,10 @@ static bool device_in_domain(const struct vtd_iommu *= iommu, found =3D true; out: if ( root_entry ) - unmap_vtd_domain_page(root_entry); + unmap_domain_page(root_entry); =20 if ( ctxt_entry ) - unmap_vtd_domain_page(ctxt_entry); + unmap_domain_page(ctxt_entry); =20 return found; } diff --git a/xen/drivers/passthrough/vtd/x86/vtd.c b/xen/drivers/passthroug= h/vtd/x86/vtd.c index 76f12adc23..b0798dc6a1 100644 --- a/xen/drivers/passthrough/vtd/x86/vtd.c +++ b/xen/drivers/passthrough/vtd/x86/vtd.c @@ -36,13 +36,3 @@ * 1:1 iommu mappings except xen and unusable regions. */ boolean_param("iommu_inclusive_mapping", iommu_hwdom_inclusive); - -void *map_vtd_domain_page(u64 maddr) -{ - return map_domain_page(_mfn(paddr_to_pfn(maddr))); -} - -void unmap_vtd_domain_page(const void *va) -{ - unmap_domain_page(va); -} --=20 2.51.1 -- Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech From nobody Wed Oct 29 21:56:40 2025 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 header.i=teddy.astie@vates.tech; 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=reject dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1761210762; cv=none; d=zohomail.com; s=zohoarc; b=HhesT3wbpjNaqZNPXttM2bYYbmxuF/Q8f7D3Qrfz9JHO9FmmuayWpbU8rfsLNsYN8C70a0/1U4GlBfV7V0OhGx0PJUqXIG68A57MLm8aIW6KVZ1J+M1OkIOmKMI50Ytn3t5IZiwY57nY2u0tDltr1HDV6vnXQHD67/4fkJaSCvI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761210762; h=Content-Type:Content-Transfer-Encoding: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=uphiyDgxiUqnnF1yei7nNrbThGF81zpHRyjV+sbeQH0=; b=lqzG4RB2/6E+fTiWCXlTaM835Q48VtdcCsmSYpm4nw8CXcCEVoCcRmxfK0HWpmTrAX8MngKir2QFLeWmiRgJIii32EANj4eVetw698Q1SLOtBgC9E8bgx7mEfYTGU/JYhbyv7EL/oISy98g5CYTf2rqeAAWaJWc1cxd2mYfUkMQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1761210762749378.9104344134804; Thu, 23 Oct 2025 02:12:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1148835.1480675 (Exim 4.92) (envelope-from ) id 1vBrMr-0003li-Id; Thu, 23 Oct 2025 09:12:21 +0000 Received: by outflank-mailman (output) from mailman id 1148835.1480675; Thu, 23 Oct 2025 09:12:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vBrMr-0003lb-G4; Thu, 23 Oct 2025 09:12:21 +0000 Received: by outflank-mailman (input) for mailman id 1148835; Thu, 23 Oct 2025 09:12:20 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vBrMq-0003Xf-2j for xen-devel@lists.xenproject.org; Thu, 23 Oct 2025 09:12:20 +0000 Received: from mail187-3.suw11.mandrillapp.com (mail187-3.suw11.mandrillapp.com [198.2.187.3]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 5f96bea7-aff0-11f0-9d15-b5c5bf9af7f9; Thu, 23 Oct 2025 11:12:18 +0200 (CEST) Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail187-3.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4csgKF26CBzDRJG7p for ; Thu, 23 Oct 2025 09:12:17 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id b988a4c6efea49f589ce491a220c8f88; Thu, 23 Oct 2025 09:12:17 +0000 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" X-Inumbo-ID: 5f96bea7-aff0-11f0-9d15-b5c5bf9af7f9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1761210737; x=1761480737; bh=uphiyDgxiUqnnF1yei7nNrbThGF81zpHRyjV+sbeQH0=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=QnSxTE3OKLeQDJbkzIV7kdgNdgXZg54/VynYOdUFWCuHEUT2KqvD1kug2IvBpPh/t VXReO9Pqn1sao8S+ueo9Sp5CDfzqppk4lbE6/8Lc7lZ7A+SD83BUCZaI5bAHln8hO5 SriND52KSTs8QXudeI/DeUvecfqeA/Rvv4XuEMZTbZGCvQFCaFwB5ZnLuxImV39m86 eLSlKErCI7Pm6qKQe9wA4li2p1TXA6bHhIyKxii5azknQ5SH8xoAc2Y+jfFG9aJ44k 2V6fN//hxvcBJWJxfDkPyUF5+9Hgqf3qEImwPlXnCvqmBl1fGv+0hl7krE+yI8Wgrd uWrI5Sou13xeg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1761210737; x=1761471237; i=teddy.astie@vates.tech; bh=uphiyDgxiUqnnF1yei7nNrbThGF81zpHRyjV+sbeQH0=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=cpNgC0oSI+AP8aIrLNViiUoXeCT09aeoGpowyV+lQo0pbmBzLQVQcgFMtKqqW11ho 1IpYDwc3td+YN/GOGCl03OHd1tC6T1mvtnRc2f7uitFoXQtAXh7YqWxa3dJkxEMSLj 2RP1AHxMQ3iir0EDC2V2peAI/CFHwdgw6tryf5sv0kAUBfLHOxG9JqPEWBZC4Rt77j 5sPDjgg1AXW83HXesizhT2ij2l1Oo4vOL3CG99aA50CJ0LDUdoyxNMIpBUHXZOSOma vhcWeAIMq0fO7eoz9FXTmxC4ltnjYhyp6tA9bphameei2kaHK6T1tqywluD1i5D4dF vqgjocnUrFE3w== From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=20v2=202/5]=20vtd:=20Drop=20"iommu=5Finclusive=5Fmapping"=20command-line=20option?= X-Mailer: git-send-email 2.51.1 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1761210736644 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" Message-Id: In-Reply-To: References: X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.b988a4c6efea49f589ce491a220c8f88?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20251023:md Date: Thu, 23 Oct 2025 09:12:17 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity teddy.astie@vates.tech) (identity @mandrillapp.com) X-ZM-MESSAGEID: 1761210764558154100 Content-Type: text/plain; charset="utf-8" This command-line option is deprecated and super-seeded with dom0-iommu=3Dmap-inclusive. Drop this command-line parameter and delete vtd/x86/vtd.c which is now empty. Signed-off-by: Teddy Astie --- v2: - new CHANGELOG.md | 2 ++ docs/misc/xen-command-line.pandoc | 6 ---- xen/drivers/passthrough/vtd/x86/Makefile | 3 +- xen/drivers/passthrough/vtd/x86/vtd.c | 38 ------------------------ 4 files changed, 3 insertions(+), 46 deletions(-) delete mode 100644 xen/drivers/passthrough/vtd/x86/vtd.c diff --git a/CHANGELOG.md b/CHANGELOG.md index 0cf9ad2d95..d4a22b8f8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,8 @@ The format is based on [Keep a Changelog](https://keepach= angelog.com/en/1.0.0/) - On x86: - GNTTABOP_cache_flush: it's unused on x86 and the implementation is broken. + - Intel-specific iommu_inclusive_mapping=3D option: super-seed= ed + by dom0-iommu=3Dmap-inclusive since Xen 4.16. =20 - Support of qemu-traditional has been removed. =20 diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 28a98321c7..0af71e289a 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -1691,12 +1691,6 @@ Specify the timeout of the device IOTLB invalidation= in milliseconds. By default, the timeout is 1000 ms. When you see error 'Queue invalidate wait descriptor timed out', try increasing this value. =20 -### iommu_inclusive_mapping -> `=3D ` - -**WARNING: This command line option is deprecated, and superseded by -_dom0-iommu=3Dmap-inclusive_ - using both options in combination is undefi= ned.** - ### irq-max-guests (x86) > `=3D ` =20 diff --git a/xen/drivers/passthrough/vtd/x86/Makefile b/xen/drivers/passthr= ough/vtd/x86/Makefile index fe20a0b019..82b3904a91 100644 --- a/xen/drivers/passthrough/vtd/x86/Makefile +++ b/xen/drivers/passthrough/vtd/x86/Makefile @@ -1,2 +1 @@ -obj-y +=3D ats.o -obj-y +=3D vtd.o +obj-y +=3D ats.o \ No newline at end of file diff --git a/xen/drivers/passthrough/vtd/x86/vtd.c b/xen/drivers/passthroug= h/vtd/x86/vtd.c deleted file mode 100644 index b0798dc6a1..0000000000 --- a/xen/drivers/passthrough/vtd/x86/vtd.c +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2008, Intel Corporation. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms and conditions of the GNU General Public License, - * version 2, as published by the Free Software Foundation. - * - * This program is distributed in the hope it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License f= or - * more details. - * - * You should have received a copy of the GNU General Public License along= with - * this program; If not, see . - * - * Copyright (C) Allen Kay - * Copyright (C) Weidong Han - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "../iommu.h" -#include "../dmar.h" -#include "../vtd.h" -#include "../extern.h" - -/* - * iommu_inclusive_mapping: when set, all memory below 4GB is included in = dom0 - * 1:1 iommu mappings except xen and unusable regions. - */ -boolean_param("iommu_inclusive_mapping", iommu_hwdom_inclusive); --=20 2.51.1 -- Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech From nobody Wed Oct 29 21:56:40 2025 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 header.i=teddy.astie@vates.tech; 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=reject dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1761210761; cv=none; d=zohomail.com; s=zohoarc; b=YB+tXHOPC3FlIyMVvXKWYcEtqVoOwxfX9WNHWM4ivMphZ9rtEp/mE3jLDfe0H5p8YPRCp0cyc0qkERh1aTZIj3Yh+82O0NDa/4FZQilr8bGnIjCCEWLfsHz05B1vb0fKuZlVJTc0eSFj3360TIULwkNzMmIqdraeMZn6WtjwXTQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761210761; h=Content-Type:Content-Transfer-Encoding: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=dmYymRXdQlvyIjJOCaPFoHAY8shqwbUzyg9v7qIutBA=; b=hUPR4XXr8BFb5efLVWzukpPAjTK9YhT2BRNT8dTHoa9qH5Siw9zqIrPvmSmq52EKvg/cwCpPDaCV7qyEr31WPowLjwxll1GSp16kuyQlXajgj9/HpsPbH9y6sYrc/iRbJAQRcrXUvD08BhVNX+npi+M5j1ZVFyx36NyfoohdLs8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1761210761471798.9633583695171; Thu, 23 Oct 2025 02:12:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1148836.1480687 (Exim 4.92) (envelope-from ) id 1vBrMs-0003zh-TZ; Thu, 23 Oct 2025 09:12:22 +0000 Received: by outflank-mailman (output) from mailman id 1148836.1480687; Thu, 23 Oct 2025 09:12:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vBrMs-0003za-OS; Thu, 23 Oct 2025 09:12:22 +0000 Received: by outflank-mailman (input) for mailman id 1148836; Thu, 23 Oct 2025 09:12:21 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vBrMr-0003Xf-33 for xen-devel@lists.xenproject.org; Thu, 23 Oct 2025 09:12:21 +0000 Received: from mail180-10.suw31.mandrillapp.com (mail180-10.suw31.mandrillapp.com [198.2.180.10]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 607b37cf-aff0-11f0-9d15-b5c5bf9af7f9; Thu, 23 Oct 2025 11:12:20 +0200 (CEST) Received: from pmta11.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail180-10.suw31.mandrillapp.com (Mailchimp) with ESMTP id 4csgKH1Plkz5QlgsB for ; Thu, 23 Oct 2025 09:12:19 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 291a88186bbd414a9eb5fb1b639043c2; Thu, 23 Oct 2025 09:12:19 +0000 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" X-Inumbo-ID: 607b37cf-aff0-11f0-9d15-b5c5bf9af7f9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1761210739; x=1761480739; bh=dmYymRXdQlvyIjJOCaPFoHAY8shqwbUzyg9v7qIutBA=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=mPV/TU44iBbaoJW9BLPOGhcaSkRH05kyrPRkqHQ/82/ErTSdxQuUyEIOgSP8HCNk+ kvaLv6TyHpBjHS+cydUhkM97oemt9CEZXiSd92vgN5ShuYgv/G/KGX7c+SVPcQE4YP jMEG9wir9j0+HWbfjXGudhRnOe//ow3TTTULBdzMfjXYWC4vI1OJOzkXM/eJpw9xPJ Kv3r1tNZXuWH09kwamV9lihaJOaSP2DfPUMB/Ay/MncSEK0nM2aM0z20OY5RK287KA o8adwnerk1/GlHv5EN4XC15g74J1rnm3XFwkDVr5XypLuQ2u8P4gbuos/9J20ikUjj 4M5vpq+ISWfoA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1761210739; x=1761471239; i=teddy.astie@vates.tech; bh=dmYymRXdQlvyIjJOCaPFoHAY8shqwbUzyg9v7qIutBA=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=qqtzB1pAwuJg6H7CmJzuWQmt7vGlU7MBHGZ7zYXpKgH+wr+CPSW2jJf6WGrjRgaSY z4wZSYd4nC6ViBCqcB62n2S0+LVqnB+qdZwcH+CAUdMb/7ens2vTb7GUAbwrTrN7XB JXQ8jaAlZUKbQjJ2dhK3Z5wfepMm+IcvUFrP43MEX8v9B4Ck84xe8uwdayb8o8o/6Z meuo0a0Aqxo+c/C1pc+iuh78yAeJd7khtvZPeMi9UuKMUTT1mvonewkuNKf7kiTpI8 Jgwdobq0KSZJOCxZTUoyjrsiq4iqggpJkEZ4KOEATrwI+8MmLUCFGy/R4tpZOvzGC4 bIMZIvN1cTSNA== From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=20v2=203/5]=20vtd:=20Collapse=20x86=20subdirectory?= X-Mailer: git-send-email 2.51.1 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1761210736930 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" Message-Id: <3e9e5ea80bb534b69bd315099da6b5d049852823.1761209564.git.teddy.astie@vates.tech> In-Reply-To: References: X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.291a88186bbd414a9eb5fb1b639043c2?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20251023:md Date: Thu, 23 Oct 2025 09:12:19 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @mandrillapp.com) (identity teddy.astie@vates.tech) X-ZM-MESSAGEID: 1761210763205154100 Content-Type: text/plain; charset="utf-8" The x86 subdirectory was originally meant to split x86-specific logic from general VT-d code. Today, Xen only supports VT-d on x86 and the code actual= ly implemented in this subdirectory isn't x86-specific (e.g ATS code is not x86 specific). As ats.c is the only remaining file in this directory, and isn't x86 specif= ic, move it up to vtd directory and remove the now empty x86 subdirectory. Signed-off-by: Teddy Astie --- v2: - reviewed commit description xen/drivers/passthrough/vtd/Makefile | 3 +-- xen/drivers/passthrough/vtd/{x86 =3D> }/ats.c | 10 +++++----- xen/drivers/passthrough/vtd/x86/Makefile | 1 - 3 files changed, 6 insertions(+), 8 deletions(-) rename xen/drivers/passthrough/vtd/{x86 =3D> }/ats.c (97%) delete mode 100644 xen/drivers/passthrough/vtd/x86/Makefile diff --git a/xen/drivers/passthrough/vtd/Makefile b/xen/drivers/passthrough= /vtd/Makefile index fde7555fac..328a014016 100644 --- a/xen/drivers/passthrough/vtd/Makefile +++ b/xen/drivers/passthrough/vtd/Makefile @@ -1,5 +1,4 @@ -obj-$(CONFIG_X86) +=3D x86/ - +obj-y +=3D ats.o obj-y +=3D iommu.o obj-y +=3D dmar.o obj-y +=3D utils.o diff --git a/xen/drivers/passthrough/vtd/x86/ats.c b/xen/drivers/passthroug= h/vtd/ats.c similarity index 97% rename from xen/drivers/passthrough/vtd/x86/ats.c rename to xen/drivers/passthrough/vtd/ats.c index fed3588e8e..3b7c4028a6 100644 --- a/xen/drivers/passthrough/vtd/x86/ats.c +++ b/xen/drivers/passthrough/vtd/ats.c @@ -23,11 +23,11 @@ #include #include #include -#include "../iommu.h" -#include "../dmar.h" -#include "../vtd.h" -#include "../extern.h" -#include "../../ats.h" +#include "iommu.h" +#include "dmar.h" +#include "vtd.h" +#include "extern.h" +#include "../ats.h" =20 static LIST_HEAD(ats_dev_drhd_units); =20 diff --git a/xen/drivers/passthrough/vtd/x86/Makefile b/xen/drivers/passthr= ough/vtd/x86/Makefile deleted file mode 100644 index 82b3904a91..0000000000 --- a/xen/drivers/passthrough/vtd/x86/Makefile +++ /dev/null @@ -1 +0,0 @@ -obj-y +=3D ats.o \ No newline at end of file --=20 2.51.1 -- Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech From nobody Wed Oct 29 21:56:40 2025 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 header.i=teddy.astie@vates.tech; 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=reject dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1761210765; cv=none; d=zohomail.com; s=zohoarc; b=b6s4ryoZR07rfxzYbXTpoaMThcb9UJgKseJGarJkwdP30VAOuQq5mYura3xeMNipKYKWZcr3VnWZozf45rHbWOhojlV18wS8UV3kMF6n+sNxFbyRCs6NnN7Wh2Qpyscjr/ZbSB+pWtdIH5xXv+1ac9/1vwsR0fTJqm0fRPKMKFk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761210765; h=Content-Type:Content-Transfer-Encoding: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=ISwWHQVTQY5EpDzB9R3kRNbTEtx9jHYcJ14ZAaa+DSw=; b=hUabbp5O1B9rrNoKDorwKKGWK7lkw2tsV40Tp8YIgzlJTtpspvZJLLSAOQztgXUUdM5J6Ilq02TE7kIDc1rzThpKvSRjahOzPXMBTQs646ZEwVqu3+D209iczYBJ3nx4IcZ3cZ4tWk10keabVPo/VKvW+9w/yBhmDbeKjm4/78U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1761210765504935.4495950877223; Thu, 23 Oct 2025 02:12:45 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1148839.1480716 (Exim 4.92) (envelope-from ) id 1vBrMw-0004l1-T7; Thu, 23 Oct 2025 09:12:26 +0000 Received: by outflank-mailman (output) from mailman id 1148839.1480716; Thu, 23 Oct 2025 09:12:26 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vBrMw-0004kt-ON; Thu, 23 Oct 2025 09:12:26 +0000 Received: by outflank-mailman (input) for mailman id 1148839; Thu, 23 Oct 2025 09:12:24 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vBrMu-0004V7-Rw for xen-devel@lists.xenproject.org; Thu, 23 Oct 2025 09:12:24 +0000 Received: from mail187-3.suw11.mandrillapp.com (mail187-3.suw11.mandrillapp.com [198.2.187.3]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 5fb59c3d-aff0-11f0-980a-7dc792cee155; Thu, 23 Oct 2025 11:12:18 +0200 (CEST) Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail187-3.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4csgKF3cy7zDRJJTy for ; Thu, 23 Oct 2025 09:12:17 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 62ce87008b414352a437bdf9322b8903; Thu, 23 Oct 2025 09:12:17 +0000 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" X-Inumbo-ID: 5fb59c3d-aff0-11f0-980a-7dc792cee155 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1761210737; x=1761480737; bh=ISwWHQVTQY5EpDzB9R3kRNbTEtx9jHYcJ14ZAaa+DSw=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=tt6hASuV80FoYEEbV9VtZmoCQRQXXnb7fmE7MPrLiiPZFZumiVWVrl/ge/F3ZKYca xtJJlhyJmCGFQyRk8BEKCdX+4rFZDpsoqft5dg2wHArN+InU325jlXs8NAZT3eloZe l2Q7oSCMYUNMpI8VVGFhLw0FS0ZAZOVDsO0p7oCLVq9o+ov6b7+Jn08ZH4Wjp/oHnP AAsfLiu7CCzVZHnbn5Bk/tugOMAFbpqTi08w+2jmaW0dE82/9Yb3YgetG00CVzRV7c BXQ4nTmOMxc+Cx8sRjw3MRGOkV3M/grhosyixhfQ3/RPL0kvQCRxDIBcpRqa1fmi+L trpQfOQ/txufQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1761210737; x=1761471237; i=teddy.astie@vates.tech; bh=ISwWHQVTQY5EpDzB9R3kRNbTEtx9jHYcJ14ZAaa+DSw=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=WGI8GujYpaiADEOS4lxBEkSihptbwAXig2dMYUv72WYtGSWboqS3vugpdk819f2XU ECGFJhoRqEb5URsW4JKJx/9dTnVSbBpwApenC5HPpW/s+oB0UbjhfjGef2MbBbBULC QNJIlf6gMHArE/UdBZdp8pZFLnzGMfbVWWhgx4KYKjiL59tEmT4F6ZrPFitTagaEzg iC8j8apoRf+keFE/rn1NmsLzrFUH7ostC7rYnienzZsc3rynjWyjdqleIgxkN3CkAV sPoNbRK8enwUnf9kkuBZ/aKRLQ0Ll+OYHObJSD3/BK4pZufXQphNcgWuFkiolXmiS3 MElP2BpxfGObA== From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=20v2=204/5]=20vtd:=20Remove=20IO=5FxAPIC=5Froute=5Fentry=20macro?= X-Mailer: git-send-email 2.51.1 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1761210737079 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" Message-Id: <5bd53445740ba85c8b49d9018b6600fd90eadb50.1761209564.git.teddy.astie@vates.tech> In-Reply-To: References: X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.62ce87008b414352a437bdf9322b8903?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20251023:md Date: Thu, 23 Oct 2025 09:12:17 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @mandrillapp.com) (identity teddy.astie@vates.tech) X-ZM-MESSAGEID: 1761210768790154100 Content-Type: text/plain; charset="utf-8" This macro was introduced to abstract between IO-APIC and IO-SAPIC (ia64), now that ia64 isn't supported anymore, this macro now only refers to IO-API= C. Signed-off-by: Teddy Astie --- v2: - formatting changes xen/drivers/passthrough/vtd/intremap.c | 10 +++++----- xen/drivers/passthrough/vtd/vtd.h | 3 --- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrou= gh/vtd/intremap.c index 6c779d476d..612e08bcec 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -269,7 +269,7 @@ static unsigned int alloc_remap_entry(struct vtd_iommu = *iommu, unsigned int nr) } =20 static int remap_entry_to_ioapic_rte( - struct vtd_iommu *iommu, int index, struct IO_xAPIC_route_entry *old_r= te) + struct vtd_iommu *iommu, int index, struct IO_APIC_route_entry *old_rt= e) { struct iremap_entry *iremap_entry =3D NULL, *iremap_entries; unsigned long flags; @@ -317,8 +317,8 @@ static int remap_entry_to_ioapic_rte( } =20 static int ioapic_rte_to_remap_entry(struct vtd_iommu *iommu, - int apic, unsigned int ioapic_pin, struct IO_xAPIC_route_entry *old_rt= e, - struct IO_xAPIC_route_entry new_rte) + 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 new_ire; @@ -399,7 +399,7 @@ unsigned int cf_check io_apic_read_remap_rte( { unsigned int ioapic_pin =3D (reg - 0x10) / 2; int index; - struct IO_xAPIC_route_entry old_rte =3D { }; + struct IO_APIC_route_entry old_rte =3D {}; int rte_upper =3D (reg & 1) ? 1 : 0; struct vtd_iommu *iommu =3D ioapic_to_iommu(IO_APIC_ID(apic)); =20 @@ -421,7 +421,7 @@ unsigned int cf_check io_apic_read_remap_rte( void cf_check io_apic_write_remap_rte( unsigned int apic, unsigned int pin, uint64_t rte) { - struct IO_xAPIC_route_entry old_rte =3D {}, new_rte; + struct IO_APIC_route_entry old_rte =3D {}, new_rte; struct vtd_iommu *iommu =3D ioapic_to_iommu(IO_APIC_ID(apic)); int rc; =20 diff --git a/xen/drivers/passthrough/vtd/vtd.h b/xen/drivers/passthrough/vt= d/vtd.h index b95124517b..f0286b40c3 100644 --- a/xen/drivers/passthrough/vtd/vtd.h +++ b/xen/drivers/passthrough/vtd/vtd.h @@ -31,9 +31,6 @@ #define MAP_ERROR_RECOVERY (1u << 2) #define UNMAP_ME_PHANTOM_FUNC (1u << 3) =20 -/* Allow for both IOAPIC and IOSAPIC. */ -#define IO_xAPIC_route_entry IO_APIC_route_entry - struct IO_APIC_route_remap_entry { union { u64 val; --=20 2.51.1 -- Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech From nobody Wed Oct 29 21:56:40 2025 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 header.i=teddy.astie@vates.tech; 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=reject dis=none) header.from=vates.tech ARC-Seal: i=1; a=rsa-sha256; t=1761210767; cv=none; d=zohomail.com; s=zohoarc; b=BP2ABHj23zI8CLeYaTwoOYhaPQ8CmAiRWizcPhUZbu02X9sdECiloesdi00+Yw8CqtBUAW5Mx1Y/PVEKTuLBez59HpW2c4FexJ+61AbCeA/RDebtkiINHYUjTQMYOY/OqOElEcoBteRm4YDJJCSZ2Og3yxCU+hAOZZN9g3bpo0c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1761210767; h=Content-Type:Content-Transfer-Encoding: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=yTbHnfaf7GPXN/1gvP3xsR4YaZcOqdxNGFcNw4CUJhw=; b=c8+/n7y2cA5CvOhMVn8qkf+v1doNmPGvYfXiWBSyK+fKzjgN1dYaz+pBwqa6Omqr9NdWvq4UzUaAiGRyPDvj6SV2wOfRl54LuIFrlD0+0kZt7FiJzMgrZ4lAXNoKChk0TteXhzqLu5S8Moq6hx1Wgey8JCmKar5i5VuNf8xDwZU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=teddy.astie@vates.tech; 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1761210767078625.2466343129754; Thu, 23 Oct 2025 02:12:47 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.1148837.1480690 (Exim 4.92) (envelope-from ) id 1vBrMt-00042Y-4M; Thu, 23 Oct 2025 09:12:23 +0000 Received: by outflank-mailman (output) from mailman id 1148837.1480690; Thu, 23 Oct 2025 09:12:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vBrMt-00040m-0O; Thu, 23 Oct 2025 09:12:23 +0000 Received: by outflank-mailman (input) for mailman id 1148837; Thu, 23 Oct 2025 09:12:22 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1vBrMs-0003Xf-36 for xen-devel@lists.xenproject.org; Thu, 23 Oct 2025 09:12:22 +0000 Received: from mail187-3.suw11.mandrillapp.com (mail187-3.suw11.mandrillapp.com [198.2.187.3]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 609508d8-aff0-11f0-9d15-b5c5bf9af7f9; Thu, 23 Oct 2025 11:12:20 +0200 (CEST) Received: from pmta09.mandrill.prod.suw01.rsglab.com (localhost [127.0.0.1]) by mail187-3.suw11.mandrillapp.com (Mailchimp) with ESMTP id 4csgKF5HR4zDRJFM2 for ; Thu, 23 Oct 2025 09:12:17 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id 153b393e8f7746baa02821dbf06fa66d; Thu, 23 Oct 2025 09:12:17 +0000 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" X-Inumbo-ID: 609508d8-aff0-11f0-9d15-b5c5bf9af7f9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1761210737; x=1761480737; bh=yTbHnfaf7GPXN/1gvP3xsR4YaZcOqdxNGFcNw4CUJhw=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=D2PrbGnkwDSpCqU0k5INp9bxRMxl/G1PkVOKC5/D9IDaBMLjPMcDOpGOR6fcmnpqV Pumwbvc2CYykPute7uVqeSorYD4LMfJcYJBzLalZt+3ccfULsZxjoPh1t/RZeGMYqq k0IZe1NU0c2HCp+2VUkvQP5wTjZ+rSRYZrepIAcOmJ8UE8hIDsYWuV0fiX/RMoC/jR JGTvXaIJ9UpkJbuNF+YA+4fUeIdC38p1Yf5CL9O5GCMneDIeruv+4AWHs0meWSuBAN ZonZbiAjEM8YRnPPr6EiecDEZRn1xArJrQxVxC3NeVAVR62GNu65y+h/9VQswI9/cr FCeA9qDDEZ8ig== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1761210737; x=1761471237; i=teddy.astie@vates.tech; bh=yTbHnfaf7GPXN/1gvP3xsR4YaZcOqdxNGFcNw4CUJhw=; h=From:Subject:To:Cc:Message-Id:In-Reply-To:References:Feedback-ID: Date:MIME-Version:Content-Type:Content-Transfer-Encoding:CC:Date: Subject:From; b=dwDRODDyLKhf6wHnMLNc1bMRJLrmPYwDr0bIDRXZSGBGpBY3ZdyPwvMJ3Afdm8EPi i4vNh9JDKBMrTEDAco4K+FwMSWb5gcYpORtPnbiPbTIMOUC5ryu5Kwj5VX1DmUuWVB W5OWh8WWyZXFT+4mgQNEBm/RxNuGGj8leoEPNXmWDCJ40ktda6ReW+pZG6IsWrvVF6 keRDs0sVCij9y4IOo4h+t6c8ge/4MmBBMFjfm7WgycraG1539ZThG8BphfrMJ1JQrM WIDAx+/zJqImdE1uoEHsYu4e8IZxO1zjLCfQDfOqrm0OfsSYgf6eJZWEo34vd9ZLev q7+ow154HCxpA== From: "Teddy Astie" Subject: =?utf-8?Q?[PATCH=20v2=205/5]=20x86/ioapic:=20Don't=20open-code=2032-bits=20rte=20reads?= X-Mailer: git-send-email 2.51.1 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1761210737228 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" Message-Id: In-Reply-To: References: X-Native-Encoded: 1 X-Report-Abuse: =?UTF-8?Q?Please=20forward=20a=20copy=20of=20this=20message,=20including=20all=20headers,=20to=20abuse@mandrill.com.=20You=20can=20also=20report=20abuse=20here:=20https://mandrillapp.com/contact/abuse=3Fid=3D30504962.153b393e8f7746baa02821dbf06fa66d?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20251023:md Date: Thu, 23 Oct 2025 09:12:17 +0000 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity teddy.astie@vates.tech) (identity @mandrillapp.com) X-ZM-MESSAGEID: 1761210770826158500 Content-Type: text/plain; charset="utf-8" There are many places where we use interesting ways of reading 32-bits components of the RTE. Introduce and use low and high components directly to the rte structure instead. Also take the opportunity to simplify "x & 1 ? 1 : 0". Signed-off-by: Teddy Astie --- v2: - make rte_upper to use bool instead xen/arch/x86/include/asm/io_apic.h | 1 + xen/arch/x86/io_apic.c | 29 ++++++++++---------------- xen/drivers/passthrough/vtd/intremap.c | 9 +++----- 3 files changed, 15 insertions(+), 24 deletions(-) diff --git a/xen/arch/x86/include/asm/io_apic.h b/xen/arch/x86/include/asm/= io_apic.h index 4680dce9e1..0e85f2a860 100644 --- a/xen/arch/x86/include/asm/io_apic.h +++ b/xen/arch/x86/include/asm/io_apic.h @@ -122,6 +122,7 @@ struct IO_APIC_route_entry { } dest; }; uint64_t raw; + struct { uint32_t low, high; }; }; }; =20 diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c index 24447aef6c..9d2edec179 100644 --- a/xen/arch/x86/io_apic.c +++ b/xen/arch/x86/io_apic.c @@ -257,28 +257,23 @@ nomem: return NULL; } =20 -union entry_union { - struct { u32 w1, w2; }; - struct IO_APIC_route_entry entry; -}; - struct IO_APIC_route_entry __ioapic_read_entry( unsigned int apic, unsigned int pin, bool raw) { - union entry_union eu; + struct IO_APIC_route_entry entry; =20 if ( raw || !iommu_intremap ) { - eu.w1 =3D __io_apic_read(apic, 0x10 + 2 * pin); - eu.w2 =3D __io_apic_read(apic, 0x11 + 2 * pin); + entry.low =3D __io_apic_read(apic, 0x10 + 2 * pin); + entry.high =3D __io_apic_read(apic, 0x11 + 2 * pin); } else { - eu.w1 =3D iommu_read_apic_from_ire(apic, 0x10 + 2 * pin); - eu.w2 =3D iommu_read_apic_from_ire(apic, 0x11 + 2 * pin); + entry.low =3D iommu_read_apic_from_ire(apic, 0x10 + 2 * pin); + entry.high =3D iommu_read_apic_from_ire(apic, 0x11 + 2 * pin); } =20 - return eu.entry; + return entry; } =20 static struct IO_APIC_route_entry ioapic_read_entry( @@ -297,12 +292,10 @@ void __ioapic_write_entry( unsigned int apic, unsigned int pin, bool raw, struct IO_APIC_route_entry e) { - union entry_union eu =3D { .entry =3D e }; - if ( raw || !iommu_intremap ) { - __io_apic_write(apic, 0x11 + 2 * pin, eu.w2); - __io_apic_write(apic, 0x10 + 2 * pin, eu.w1); + __io_apic_write(apic, 0x11 + 2 * pin, e.high); + __io_apic_write(apic, 0x10 + 2 * pin, e.low); /* * Might be called before io_apic_pin_eoi is allocated. Entry wil= l be * initialized to the RTE value once the cache is allocated. @@ -2235,7 +2228,7 @@ int ioapic_guest_read(unsigned long physbase, unsigne= d int reg, u32 *pval) dprintk(XENLOG_INFO, "IO-APIC: apic=3D%d, pin=3D%d, irq=3D%d\n" \ XENLOG_INFO "IO-APIC: new_entry=3D%08x\n" \ XENLOG_INFO "IO-APIC: " f "\n", \ - apic, pin, irq, *(u32 *)&rte, ##a ) + apic, pin, irq, rte.low, ##a ) =20 int ioapic_guest_write(unsigned long physbase, unsigned int reg, u32 val) { @@ -2254,7 +2247,7 @@ int ioapic_guest_write(unsigned long physbase, unsign= ed int reg, u32 val) pin =3D (reg - 0x10) >> 1; =20 /* Write first half from guest; second half is target info. */ - *(u32 *)&rte =3D val; + rte.low =3D val; =20 /* * What about weird destination types? @@ -2305,7 +2298,7 @@ int ioapic_guest_write(unsigned long physbase, unsign= ed int reg, u32 val) ret =3D io_apic_read(apic, 0x10 + 2 * pin); spin_unlock_irqrestore(&ioapic_lock, flags); rte.vector =3D desc->arch.vector; - if ( *(u32*)&rte !=3D ret ) + if ( rte.low !=3D ret ) WARN_BOGUS_WRITE("old_entry=3D%08x pirq=3D%d\n" XENLOG_INFO "IO-APIC: Attempt to modify IO-APIC pin for i= n-use IRQ!", ret, pirq); diff --git a/xen/drivers/passthrough/vtd/intremap.c b/xen/drivers/passthrou= gh/vtd/intremap.c index 612e08bcec..a276518c52 100644 --- a/xen/drivers/passthrough/vtd/intremap.c +++ b/xen/drivers/passthrough/vtd/intremap.c @@ -400,7 +400,7 @@ unsigned int cf_check io_apic_read_remap_rte( unsigned int ioapic_pin =3D (reg - 0x10) / 2; int index; struct IO_APIC_route_entry old_rte =3D {}; - int rte_upper =3D (reg & 1) ? 1 : 0; + bool rte_upper =3D reg & 1; struct vtd_iommu *iommu =3D ioapic_to_iommu(IO_APIC_ID(apic)); =20 if ( !iommu->intremap.num || @@ -411,11 +411,8 @@ unsigned int cf_check io_apic_read_remap_rte( =20 if ( remap_entry_to_ioapic_rte(iommu, index, &old_rte) ) return __io_apic_read(apic, reg); - - if ( rte_upper ) - return (*(((u32 *)&old_rte) + 1)); - else - return (*(((u32 *)&old_rte) + 0)); + =20 + return rte_upper ? old_rte.high : old_rte.low; } =20 void cf_check io_apic_write_remap_rte( --=20 2.51.1 -- Teddy Astie | Vates XCP-ng Developer XCP-ng & Xen Orchestra - Vates solutions web: https://vates.tech