From 4cde4a552ed35f3cc74df877d5a7cfbbfced8fb3 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Fri, 25 Jul 2025 10:01:26 -0400 Subject: [PATCH] xen/arm: allow translated iommu mappings 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 Signed-off-by: Stewart Hildebrand Tested-by: Jason Andryuk Reviewed-by: Julien Grall --- 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 bdb271584b..a3e3cafb87 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); } /*