Hi, On 25/07/2025 15:01, Stewart Hildebrand wrote:
From: Stefano Stabellini <[email protected]>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 <[email protected]> Signed-off-by: Stewart Hildebrand <[email protected]>
Reviewed-by: Julien Grall <[email protected]>
--- v4->v5: * no change v3->v4: * no change 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); }/*
-- Julien Grall
