[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230814011759.102089-2-baolu.lu@linux.intel.com>
Date: Mon, 14 Aug 2023 09:17:57 +0800
From: Lu Baolu <baolu.lu@...ux.intel.com>
To: Joerg Roedel <joro@...tes.org>, Will Deacon <will@...nel.org>,
Robin Murphy <robin.murphy@....com>,
Jason Gunthorpe <jgg@...pe.ca>,
Kevin Tian <kevin.tian@...el.com>,
Jean-Philippe Brucker <jean-philippe@...aro.org>,
Nicolin Chen <nicolinc@...dia.com>
Cc: Yi Liu <yi.l.liu@...el.com>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>,
iommu@...ts.linux.dev, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org, Lu Baolu <baolu.lu@...ux.intel.com>
Subject: [PATCH v2 1/3] iommu: Make single-device group for PASID explicit
The PASID interfaces have always supported only single-device groups.
This was first introduced in commit 26b25a2b98e45 ("iommu: Bind process
address spaces to devices"), and has been kept consistent in subsequent
commits.
However, the core code doesn't explicitly check for this requirement
after commit 201007ef707a8 ("PCI: Enable PASID only when ACS RR & UF
enabled on upstream path"), which made this requirement implicit.
Restore the check to make it explicit that the PASID interfaces only
support devices belonging to single-device groups.
Signed-off-by: Lu Baolu <baolu.lu@...ux.intel.com>
---
drivers/iommu/iommu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 71b9c41f2a9e..f1eba60e573f 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -3408,6 +3408,11 @@ int iommu_attach_device_pasid(struct iommu_domain *domain,
return -ENODEV;
mutex_lock(&group->mutex);
+ if (list_count_nodes(&group->devices) != 1) {
+ ret = -EINVAL;
+ goto out_unlock;
+ }
+
curr = xa_cmpxchg(&group->pasid_array, pasid, NULL, domain, GFP_KERNEL);
if (curr) {
ret = xa_err(curr) ? : -EBUSY;
--
2.34.1
Powered by blists - more mailing lists