On 8/22/25 8:40 AM, Zhenzhong Duan wrote:
> From: Yi Liu <yi.l....@intel.com>
>
> When either 'Set Root Table Pointer' or 'Translation Enable' bit is changed,
> all pasid bindings on host side become stale and need to be updated.
>
> Introduce a helper function vtd_replay_pasid_bindings_all() to go through all
> pasid entries in all passthrough devices to update host side bindings.
>
> Signed-off-by: Yi Liu <yi.l....@intel.com>
> Signed-off-by: Zhenzhong Duan <zhenzhong.d...@intel.com>
Reviewed-by: Eric Auger <eric.au...@redhat.com>
Eric
> ---
> hw/i386/intel_iommu.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
> index 7efa22f4ec..f9cb13e945 100644
> --- a/hw/i386/intel_iommu.c
> +++ b/hw/i386/intel_iommu.c
> @@ -89,6 +89,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_replay_pasid_bindings_all(IntelIOMMUState *s);
>
> static void vtd_pasid_cache_reset_locked(IntelIOMMUState *s);
> static void vtd_pasid_cache_sync(IntelIOMMUState *s,
> @@ -3050,6 +3051,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_replay_pasid_bindings_all(s);
> }
>
> /* Set Interrupt Remap Table Pointer */
> @@ -3084,6 +3086,7 @@ static void vtd_handle_gcmd_te(IntelIOMMUState *s, bool
> en)
>
> vtd_reset_caches(s);
> vtd_address_space_refresh_all(s);
> + vtd_replay_pasid_bindings_all(s);
> }
>
> /* Handle Interrupt Remap Enable/Disable */
> @@ -3777,6 +3780,17 @@ static void
> vtd_replay_guest_pasid_bindings(IntelIOMMUState *s,
> }
> }
>
> +static void vtd_replay_pasid_bindings_all(IntelIOMMUState *s)
> +{
> + VTDPASIDCacheInfo pc_info = { .type = VTD_PASID_CACHE_GLOBAL_INV };
> +
> + if (!s->flts || !s->root_scalable || !s->dmar_enabled) {
> + return;
> + }
> +
> + vtd_replay_guest_pasid_bindings(s, &pc_info);
> +}
> +
> /*
> * For a PASID cache invalidation, this function handles below scenarios:
> * a) a present cached pasid entry needs to be removed