From: Yi Liu <yi.l.liu@intel.com>
To: Lu Baolu <baolu.lu@linux.intel.com>,
Joerg Roedel <joro@8bytes.org>, "Will Deacon" <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
Kevin Tian <kevin.tian@intel.com>
Cc: <iommu@lists.linux.dev>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/1] iommu/vt-d: Unconditionally flush device TLB for pasid table updates
Date: Tue, 20 Aug 2024 15:09:03 +0800 [thread overview]
Message-ID: <9047e540-a993-473c-9d24-8359cec67b5b@intel.com> (raw)
In-Reply-To: <20240820030208.20020-1-baolu.lu@linux.intel.com>
Hi Baolu,
On 2024/8/20 11:02, Lu Baolu wrote:
> The caching mode of an IOMMU is irrelevant to the behavior of the device
> TLB. Previously, commit <304b3bde24b5> ("iommu/vt-d: Remove caching mode
> check before device TLB flush") removed this redundant check in the
> domain unmap path.
>
> Checking the caching mode before flushing the device TLB after a pasid
> table entry is updated is unnecessary and can lead to inconsistent
> behavior.
>
> Extends this consistency by removing the caching mode check in the pasid
> table update path.
I'm wondering if a fix tag is needed here. Before this patch, the guest
kernel does not issue device TLB invalidation. This may be a problem for
the emulated devices that support ATS capability. The cache in device
side would be stale. Although some vIOMMU like QEMU virtual VT-d would
notify the emulated devices to flush their cache when handling the unmap
event. [1]. But this is not required by VT-d spec. So it's possible that
other vIOMMU may not do it. So this patch appears to fix an issue, so a fix
tag may be necessary. How about your thought?
[1]
https://lore.kernel.org/qemu-devel/20240805062727.2307552-14-zhenzhong.duan@intel.com/
> Suggested-by: Yi Liu <yi.l.liu@intel.com>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> ---
> drivers/iommu/intel/pasid.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
> index 5792c817cefa..dc00eac6be31 100644
> --- a/drivers/iommu/intel/pasid.c
> +++ b/drivers/iommu/intel/pasid.c
> @@ -264,9 +264,7 @@ void intel_pasid_tear_down_entry(struct intel_iommu *iommu, struct device *dev,
> else
> iommu->flush.flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH);
>
> - /* Device IOTLB doesn't need to be flushed in caching mode. */
> - if (!cap_caching_mode(iommu->cap))
> - devtlb_invalidation_with_pasid(iommu, dev, pasid);
> + devtlb_invalidation_with_pasid(iommu, dev, pasid);
> }
>
> /*
> @@ -493,9 +491,7 @@ int intel_pasid_setup_dirty_tracking(struct intel_iommu *iommu,
>
> iommu->flush.flush_iotlb(iommu, did, 0, 0, DMA_TLB_DSI_FLUSH);
>
> - /* Device IOTLB doesn't need to be flushed in caching mode. */
> - if (!cap_caching_mode(iommu->cap))
> - devtlb_invalidation_with_pasid(iommu, dev, pasid);
> + devtlb_invalidation_with_pasid(iommu, dev, pasid);
>
> return 0;
> }
> @@ -572,9 +568,7 @@ void intel_pasid_setup_page_snoop_control(struct intel_iommu *iommu,
> pasid_cache_invalidation_with_pasid(iommu, did, pasid);
> qi_flush_piotlb(iommu, did, pasid, 0, -1, 0);
>
> - /* Device IOTLB doesn't need to be flushed in caching mode. */
> - if (!cap_caching_mode(iommu->cap))
> - devtlb_invalidation_with_pasid(iommu, dev, pasid);
> + devtlb_invalidation_with_pasid(iommu, dev, pasid);
> }
>
> /**
--
Regards,
Yi Liu
next prev parent reply other threads:[~2024-08-20 7:04 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-20 3:02 Lu Baolu
2024-08-20 7:09 ` Yi Liu [this message]
2024-08-20 7:37 ` Baolu Lu
2024-08-21 7:54 ` Yi Liu
2024-09-02 2:38 ` Baolu Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9047e540-a993-473c-9d24-8359cec67b5b@intel.com \
--to=yi.l.liu@intel.com \
--cc=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®