[PATCH v7 21/23] intel_iommu: Add migration support with x-flts=on

Zhenzhong Duan posted 23 patches 3 months, 2 weeks ago
There is a newer version of this series
[PATCH v7 21/23] intel_iommu: Add migration support with x-flts=on
Posted by Zhenzhong Duan 3 months, 2 weeks ago
When x-flts=on, we set up bindings to nested HWPT in host, after
migration, VFIO device binds to nesting parent HWPT by default.
We need to re-establish the bindings to nested HWPT, or else device
DMA will break.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 hw/i386/intel_iommu.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index edd1416382..8fec61be3e 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -4360,6 +4360,13 @@ static int vtd_post_load(void *opaque, int version_id)
      */
     vtd_switch_address_space_all(iommu);
 
+    /*
+     * Bindings to nested HWPT in host is set up dynamically depending
+     * on pasid entry configuration from guest. After migration, we
+     * need to re-establish the bindings before restore device's DMA.
+     */
+    vtd_replay_pasid_bindings_all(iommu);
+
     return 0;
 }
 
-- 
2.47.1
Re: [PATCH v7 21/23] intel_iommu: Add migration support with x-flts=on
Posted by Eric Auger 3 months, 1 week ago

On 10/24/25 10:43 AM, Zhenzhong Duan wrote:
> When x-flts=on, we set up bindings to nested HWPT in host, after
> migration, VFIO device binds to nesting parent HWPT by default.
> We need to re-establish the bindings to nested HWPT, or else device
s/else/otherwise
> DMA will break.
>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>

> ---
>  hw/i386/intel_iommu.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> index edd1416382..8fec61be3e 100644
> --- a/hw/i386/intel_iommu.c
> +++ b/hw/i386/intel_iommu.c
> @@ -4360,6 +4360,13 @@ static int vtd_post_load(void *opaque, int version_id)
>       */
>      vtd_switch_address_space_all(iommu);
>  
> +    /*
> +     * Bindings to nested HWPT in host is set up dynamically depending
> +     * on pasid entry configuration from guest. After migration, we
> +     * need to re-establish the bindings before restore device's DMA.
restoring
> +     */
> +    vtd_replay_pasid_bindings_all(iommu);
> +
>      return 0;
>  }
>  
Reviewed-by: Eric Auger <eric.auger@redhat.com>

Eric