RE: [PATCH v3 07/10] iommu/vt-d: Add iotlb flush for nested domain

Liu, Yi L
2023-06-20T06:22:32Z

> From: Baolu Lu <baolu.lu@linux.intel.com>
> Sent: Thursday, June 8, 2023 4:08 PM
>
> On 2023/6/8 15:14, Liu, Yi L wrote:
> >>> + * stage-1 page table cache
> >>> + * invalidation
> >>> + * @IOMMU_VTD_QI_FLAGS_LEAF: The LEAF flag indicates whether only the
> >>> + * leaf PTE caching needs to be invalidated
> >>> + * and other paging structure caches can be
> >>> + * preserved.
> >>> + */
> >> what about "Drain Reads" and "Drain Writes"? Is the user allowed/required
> >> to provide those hints?
> > All other comments got. For these two hints, the two flags are from the IOTLB
> > Invalidation descriptor. Per below description, the hardware that supports nested
> > should support drain and does not require software to ask for it. So it appears no
> > need to define them in uapi.
> >
> > "Hardware implementation with Major Version 2 or higher (VER_REG),
> > always performs required drain without software explicitly requesting
> > a drain in IOTLB invalidation. This field is deprecated and hardware
> > will always report it as 1 to maintain backward compatibility with
> > software"
>
> Make sense. Perhaps we can also remove below code in
> __iommu_flush_iotlb():
>
> /* Note: set drain read/write */
> #if 0
> /*
> * This is probably to be super secure.. Looks like we can
> * ignore it without any impact.
> */
> if (cap_read_drain(iommu->cap))
> val |= DMA_TLB_READ_DRAIN;
> #endif

This seems dead code. But it is there for a long time since below commit.

ba39592764ed20cee09aae5352e603a27bf56b0d

Regards,
Yi Liu