[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v3 2/2] xen/arm: allow translated iommu mappings


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Tue, 22 Jul 2025 18:51:25 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=odzuwLMUbjumx7YA9q/tHmH+rdqA+R4OdgxxOO9c9Ks=; b=UjhQTUAkyy3FCIg/K5qWSvl11Z092YS+tAgNHl4SFYbj6o8WFEPBZ1TuDYbPUNXapp38PMmPzdhIaFKSkr+NjRexjyxZQC/ITqY4lfTpw463GL12435dBHb3m2VWmAuIqUZZMHo4Hldlgi278uHcIwr8QHFT3+5yXuyZQZIh268JOzPibREinqy/PXqh76mmqWVvYdkrwVNijqVXiI/DMasXSsUPqdU/SA1VG8O9hxIj2D1qPXZgQc4SJGXg2hZXjSZD0GYh/oWfGTNCNYYeOYA2+VUgp4NzSvsS3bhJDuzaNlhP8HqjHysgyShjkuB7FNttcouj13TOvAc95pm8GQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=EVCaUOlCe1k8jT/BmCYYOhNBE4S/HLTf6JMUfjgAHkSgmRmKtOjrOg4qMssh8GclABiL/2+aNKAjdBWuAhQO8JFwBHMkcJd0ERX/HBZCG0Dml2mYjTKo53oOSJF4NttP9R+0Rm0dyiXA8NKDeSBP2YFCy8EqnFs1GnAaxToDeHe4FVcnoL6H45jhjysU6mWCXtiA93c48YuV9GdO1ib5ui/3KlGiz5vsthlqcRBlgiOfsw4ntT+LPr4WhnRCY7wEQn+K0PiVWzsNupPTLQO37ka13V1Fr1JZJMpam9E2r5X1a3Gs8vtgTuamC9DjrNu2OZHEpsaeMm+tBBLMB9yb6A==
  • Cc: Stefano Stabellini <stefano.stabellini@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Delivery-date: Tue, 22 Jul 2025 22:52:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

From: Stefano Stabellini <stefano.stabellini@xxxxxxx>

In preparation of exposing vITS to domUs, generalize arm_iommu_map_page
and arm_iommu_unmap_page to allow ITS doorbell mappings with dfn != mfn.

The mfn does not need to be passed to guest_physmap_remove_page since
there is no mfn checking on the p2m_iommu_map_{rw,ro} p2m types during
unmap. Pass INVALID_MFN to guest_physmap_remove_page.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxx>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
v2->v3:
* split change from ("xen/arm: fix arm_iommu_map_page after f9f6b22ab")
* both map and unmap
---
 xen/drivers/passthrough/arm/iommu_helpers.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/xen/drivers/passthrough/arm/iommu_helpers.c 
b/xen/drivers/passthrough/arm/iommu_helpers.c
index bdb271584b0d..a3e3cafb8705 100644
--- a/xen/drivers/passthrough/arm/iommu_helpers.c
+++ b/xen/drivers/passthrough/arm/iommu_helpers.c
@@ -36,9 +36,6 @@ int __must_check arm_iommu_map_page(struct domain *d, dfn_t 
dfn, mfn_t mfn,
 {
     p2m_type_t t;
 
-    BUG_ON(!domain_use_host_layout(d));
-    BUG_ON(mfn_x(mfn) != dfn_x(dfn));
-
     /* We only support readable and writable flags */
     if ( !(flags & (IOMMUF_readable | IOMMUF_writable)) )
         return -EINVAL;
@@ -49,7 +46,7 @@ int __must_check arm_iommu_map_page(struct domain *d, dfn_t 
dfn, mfn_t mfn,
      * The function guest_physmap_add_entry replaces the current mapping
      * if there is already one...
      */
-    return guest_physmap_add_entry(d, _gfn(dfn_x(dfn)), _mfn(dfn_x(dfn)),
+    return guest_physmap_add_entry(d, _gfn(dfn_x(dfn)), mfn,
                                    IOMMUF_order(flags), t);
 }
 
@@ -58,11 +55,7 @@ int __must_check arm_iommu_unmap_page(struct domain *d, 
dfn_t dfn,
                                       unsigned int order,
                                       unsigned int *flush_flags)
 {
-    if ( !domain_use_host_layout(d) )
-        return -EINVAL;
-
-    return guest_physmap_remove_page(d, _gfn(dfn_x(dfn)), _mfn(dfn_x(dfn)),
-                                     order);
+    return guest_physmap_remove_page(d, _gfn(dfn_x(dfn)), INVALID_MFN, order);
 }
 
 /*
-- 
2.50.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.