From: Baolu Lu <baolu.lu@linux.intel.com>
To: "Tian, Kevin" <kevin.tian@intel.com>,
Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
"Liu, Yi L" <yi.l.liu@intel.com>
Cc: baolu.lu@linux.intel.com,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH 1/1] iommu/vt-d: Make intel_iommu_drain_pasid_prq() cover faults for RID
Date: Mon, 20 Jan 2025 17:54:49 +0800 [thread overview]
Message-ID: <a58b8c10-2d7d-4b26-9e9b-fa0f1cb90d2e@linux.intel.com> (raw)
In-Reply-To: <BN9PR11MB5276B3F78599A00476AA2CDC8CE72@BN9PR11MB5276.namprd11.prod.outlook.com>
On 2025/1/20 17:26, Tian, Kevin wrote:
>> From: Lu Baolu <baolu.lu@linux.intel.com>
>> Sent: Monday, January 20, 2025 4:02 PM
>>
>> This driver supports page faults on PCI RID since commit <9f831c16c69e>
>> ("iommu/vt-d: Remove the pasid present check in prq_event_thread") by
>> allowing the reporting of page faults with the pasid_present field cleared
>> to the upper layer for further handling. The fundamental assumption here
>> is that the detach or replace operations act as a fence for page faults.
>> This implies that all pending page faults associated with a specific RID
>> or PASID are flushed when a domain is detached or replaced from a device
>> RID or PASID.
>>
>> However, the intel_iommu_drain_pasid_prq() helper does not correctly
>> handle faults for RID. This leads to faults potentially remaining pending
>> in the iommu hardware queue even after the domain is detached, thereby
>> violating the aforementioned assumption.
>>
>> Fix this issue by extending intel_iommu_drain_pasid_prq() to cover faults
>> for RID.
>>
>> Fixes: 9f831c16c69e ("iommu/vt-d: Remove the pasid present check in
>> prq_event_thread")
>> Cc: stable@vger.kernel.org
>> Suggested-by: Kevin Tian <kevin.tian@intel.com>
>> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
>> ---
>> drivers/iommu/intel/prq.c | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/iommu/intel/prq.c b/drivers/iommu/intel/prq.c
>> index c2d792db52c3..043f02d7b460 100644
>> --- a/drivers/iommu/intel/prq.c
>> +++ b/drivers/iommu/intel/prq.c
>> @@ -87,7 +87,8 @@ void intel_iommu_drain_pasid_prq(struct device *dev,
>> u32 pasid)
>> struct page_req_dsc *req;
>>
>> req = &iommu->prq[head / sizeof(*req)];
>> - if (!req->pasid_present || req->pasid != pasid) {
>> + if (req->rid != sid ||
>> + (req->pasid_present && req->pasid != pasid)) {
>> head = (head + sizeof(*req)) & PRQ_RING_MASK;
>> continue;
>> }
>
> Ah you'd also want to skip (!req->pasid_present &&
> pasid != IOMMU_NO_PASID)
>
Yes. Will make it like this,
diff --git a/drivers/iommu/intel/prq.c b/drivers/iommu/intel/prq.c
index c2d792db52c3..064194399b38 100644
--- a/drivers/iommu/intel/prq.c
+++ b/drivers/iommu/intel/prq.c
@@ -87,7 +87,9 @@ void intel_iommu_drain_pasid_prq(struct device *dev,
u32 pasid)
struct page_req_dsc *req;
req = &iommu->prq[head / sizeof(*req)];
- if (!req->pasid_present || req->pasid != pasid) {
+ if (req->rid != sid ||
+ (req->pasid_present && pasid != req->pasid) ||
+ (!req->pasid_present && pasid != IOMMU_NO_PASID)) {
head = (head + sizeof(*req)) & PRQ_RING_MASK;
continue;
}
Thanks,
baolu
next prev parent reply other threads:[~2025-01-20 9:55 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-20 8:01 [PATCH 1/1] iommu/vt-d: Make intel_iommu_drain_pasid_prq() cover faults for RID Lu Baolu
2025-01-20 8:59 ` Tian, Kevin
2025-01-20 9:26 ` Tian, Kevin
2025-01-20 9:54 ` Baolu Lu [this message]
-- strict thread matches above, loose matches on Subject: below --
2025-02-11 0:55 [PATCH 0/1][PULL REQUEST] iommu/vt-d: Fixes for v6.14-rc Lu Baolu
2025-02-11 0:55 ` [PATCH 1/1] iommu/vt-d: Make intel_iommu_drain_pasid_prq() cover faults for RID Lu Baolu
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=a58b8c10-2d7d-4b26-9e9b-fa0f1cb90d2e@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=robin.murphy@arm.com \
--cc=stable@vger.kernel.org \
--cc=will@kernel.org \
--cc=yi.l.liu@intel.com \
/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