RE: [PATCH 1/1] iommu/vt-d: Omit devTLB invalidation requests when TES=0

From: Tian, Kevin
Date: Mon Nov 13 2023 - 23:45:50 EST


> From: Baolu Lu <baolu.lu@xxxxxxxxxxxxxxx>
> Sent: Tuesday, November 14, 2023 11:14 AM
>
> On 11/14/23 11:14 AM, Tian, Kevin wrote:
> >> From: Lu Baolu<baolu.lu@xxxxxxxxxxxxxxx>
> >> Sent: Tuesday, November 14, 2023 9:11 AM
> >>
> >> The latest VT-d spec indicates that when remapping hardware is disabled
> >> (TES=0 in Global Status Register), upstream ATS Invalidation Completion
> >> requests are treated as UR (Unsupported Request).
> >>
> >> Consequently, the spec recommends in section 4.3 Handling of Device-TLB
> >> Invalidations that software refrain from submitting any Device-TLB
> >> invalidation requests when address remapping hardware is disabled.
> >>
> >> Verify address remapping hardware is enabled prior to submitting Device-
> >> TLB invalidation requests.
> >>
> >> Fixes: 792fb43ce2c9 ("iommu/vt-d: Enable Intel IOMMU scalable mode by
> >> default")
> >> Signed-off-by: Lu Baolu<baolu.lu@xxxxxxxxxxxxxxx>
> >> ---
> >> drivers/iommu/intel/dmar.c | 18 ++++++++++++++++++
> >> 1 file changed, 18 insertions(+)
> >>
> >> diff --git a/drivers/iommu/intel/dmar.c b/drivers/iommu/intel/dmar.c
> >> index a3414afe11b0..23cb80d62a9a 100644
> >> --- a/drivers/iommu/intel/dmar.c
> >> +++ b/drivers/iommu/intel/dmar.c
> >> @@ -1522,6 +1522,15 @@ void qi_flush_dev_iotlb(struct intel_iommu
> >> *iommu, u16 sid, u16 pfsid,
> >> {
> >> struct qi_desc desc;
> >>
> >> + /*
> >> + * VT-d spec, section 4.3:
> >> + *
> >> + * Software is recommended to not submit any Device-TLB
> >> invalidation
> >> + * requests while address remapping hardware is disabled.
> >> + */
> >> + if (!(iommu->gcmd & DMA_GCMD_TE))
> >> + return;
> >> +
> > Is it a valid case to see such request when the iommu is disabled?
> > If not then let's add a WARN.
>
> There might be valid cases. The VT-d translation is turned on after all
> devices get probed.
>

but I didn't get why there will be actual mapping changes before
vtd translation is enabled...