Hi Zhenzhong,

On 6/20/25 9:18 AM, Zhenzhong Duan wrote:
> From: Yi Liu <yi.l....@intel.com>
>
> When either 'Set Root Table Pointer' or 'Translation Enable' bit is changed,
> the pasid bindings on host side become stale and need to be updated.
>
> Introduce a helper function vtd_refresh_pasid_bind() for that purpose.
nit I would avoid introducing yet another terminology, ie. refresh. If
it is a replay let's keep replay and precisely explain what the replay does.
vtd_replay_pasid_bindings?


>
> Signed-off-by: Yi Liu <yi.l....@intel.com>
> Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com>
> ---
>  hw/i386/intel_iommu.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> index d1fa395274..0b322078cc 100644
> --- a/hw/i386/intel_iommu.c
> +++ b/hw/i386/intel_iommu.c
> @@ -90,6 +90,7 @@ struct vtd_iotlb_key {
>  
>  static void vtd_address_space_refresh_all(IntelIOMMUState *s);
>  static void vtd_address_space_unmap(VTDAddressSpace *as, IOMMUNotifier *n);
> +static void vtd_refresh_pasid_bind(IntelIOMMUState *s);
>  
>  static void vtd_pasid_cache_reset_locked(IntelIOMMUState *s);
>  static void vtd_pasid_cache_sync(IntelIOMMUState *s,
> @@ -3066,6 +3067,7 @@ static void vtd_handle_gcmd_srtp(IntelIOMMUState *s)
>      vtd_set_clear_mask_long(s, DMAR_GSTS_REG, 0, VTD_GSTS_RTPS);
>      vtd_reset_caches(s);
>      vtd_address_space_refresh_all(s);
> +    vtd_refresh_pasid_bind(s);
>  }
>  
>  /* Set Interrupt Remap Table Pointer */
> @@ -3100,6 +3102,7 @@ static void vtd_handle_gcmd_te(IntelIOMMUState *s, bool 
> en)
>  
>      vtd_reset_caches(s);
>      vtd_address_space_refresh_all(s);
> +    vtd_refresh_pasid_bind(s);
>  }
>  
>  /* Handle Interrupt Remap Enable/Disable */
> @@ -3813,6 +3816,26 @@ static void 
> vtd_replay_guest_pasid_bindings(IntelIOMMUState *s,
>      }
>  }
>  
> +static void vtd_refresh_pasid_bind(IntelIOMMUState *s)
> +{
> +    VTDPASIDCacheInfo pc_info = { .error_happened = false,
> +                                  .type = VTD_PASID_CACHE_GLOBAL_INV };
> +
> +    /*
> +     * Only when dmar is enabled, should pasid bindings replayed,
> +     * otherwise no need to replay.
> +     */
I am not sure the above comment is necessary.
> +    if (!s->dmar_enabled) {
> +        return;
> +    }
> +
> +    if (!s->flts || !s->root_scalable) {
> +        return;
> +    }
> +
> +    vtd_replay_guest_pasid_bindings(s, &pc_info);
> +}
> +
>  /*
>   * This function syncs the pasid bindings between guest and host.
>   * It includes updating the pasid cache in vIOMMU and updating the
Thanks

Eric


Reply via email to