Re: [PATCH] iommu/dma: Respect SWIOTLB force_bounce
From: Robin Murphy
Date: Thu May 02 2024 - 08:51:00 EST
On 02/05/2024 6:07 am, Christoph Hellwig wrote:
On Wed, May 01, 2024 at 08:13:18PM +0000, T.J. Mercier wrote:
iommu_dma_map_page and iommu_dma_map_sg conditionally use SWIOTLB, but
checking if force_bounce is set for the device is not part of that
condition. Check if devices have requested to force SWIOTLB use as part
of deciding to take the existing SWIOTLB paths.
This fails to explain why you'd want this somewhat surprising behavior,
and why you consider it a bug fix.
Indeed, it's rather intentional that the "swiotlb=force" argument
doesn't affect iommu-dma, since that's primarily for weeding out drivers
making dodgy assumptions about DMA addresses, and iommu-dma is
inherently even better at that already.
Beyond that I think this change also seems likely to interact badly with
CC_ATTR_GUEST_MEM_ENCRYPT on x86, where we invoke the SWIOTLB_FORCE flag
for dma-direct, but expect that an IOMMU can provide a decrypted view
in-place, thus bouncing in that path would be unnecessarily detrimental.
Thanks,
Robin.