[PATCH] iommu/amd-vi: avoid pointless flushes in invalidate_all_domain_pages()

Roger Pau Monne posted 1 patch 9 months, 4 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20230707135915.47359-1-roger.pau@citrix.com
xen/drivers/passthrough/amd/iommu_init.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] iommu/amd-vi: avoid pointless flushes in invalidate_all_domain_pages()
Posted by Roger Pau Monne 9 months, 4 weeks ago
Fix invalidate_all_domain_pages() to only attempt to flush the domains
that have IOMMU enabled, otherwise the flush is pointless.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/amd/iommu_init.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c
index 7dbd7e7d094a..af6713d2fc02 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -1532,8 +1532,10 @@ int __init amd_iommu_init_late(void)
 static void invalidate_all_domain_pages(void)
 {
     struct domain *d;
+
     for_each_domain( d )
-        amd_iommu_flush_all_pages(d);
+        if ( is_iommu_enabled(d) )
+            amd_iommu_flush_all_pages(d);
 }
 
 static int cf_check _invalidate_all_devices(
-- 
2.41.0


Re: [PATCH] iommu/amd-vi: avoid pointless flushes in invalidate_all_domain_pages()
Posted by Jan Beulich 9 months, 3 weeks ago
On 07.07.2023 15:59, Roger Pau Monne wrote:
> Fix invalidate_all_domain_pages() to only attempt to flush the domains
> that have IOMMU enabled, otherwise the flush is pointless.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>