Re: [PATCH v2 1/2] iommu/vt-d: Fix sid not set issue in intel_svm_bind_gpasid()

2020-10-30 Thread Lu Baolu

On 10/30/20 10:37 AM, Yi Sun wrote:

From: Liu Yi L 

Should get correct sid and set it into sdev. Because we execute
'sdev->sid != req->rid' in the loop of prq_event_thread().

Fixes: eb8d93ea3c1d ("iommu/vt-d: Report page request faults for guest SVA")
Signed-off-by: Liu Yi L 
Signed-off-by: Yi Sun 


Cc: sta...@ver.kernel.org
Acked-by: Lu Baolu 

Best regards,
baolu


---
  drivers/iommu/intel/svm.c | 6 ++
  1 file changed, 6 insertions(+)

diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
index f1861fa..7584669 100644
--- a/drivers/iommu/intel/svm.c
+++ b/drivers/iommu/intel/svm.c
@@ -279,6 +279,7 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, 
struct device *dev,
struct intel_iommu *iommu = device_to_iommu(dev, NULL, NULL);
struct intel_svm_dev *sdev = NULL;
struct dmar_domain *dmar_domain;
+   struct device_domain_info *info;
struct intel_svm *svm = NULL;
int ret = 0;
  
@@ -310,6 +311,10 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, struct device *dev,

if (data->hpasid <= 0 || data->hpasid >= PASID_MAX)
return -EINVAL;
  
+	info = get_domain_info(dev);

+   if (!info)
+   return -EINVAL;
+
dmar_domain = to_dmar_domain(domain);
  
  	mutex_lock(&pasid_mutex);

@@ -357,6 +362,7 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, 
struct device *dev,
goto out;
}
sdev->dev = dev;
+   sdev->sid = PCI_DEVID(info->bus, info->devfn);
  
  	/* Only count users if device has aux domains */

if (iommu_dev_feature_enabled(dev, IOMMU_DEV_FEAT_AUX))



[PATCH v2 1/2] iommu/vt-d: Fix sid not set issue in intel_svm_bind_gpasid()

2020-10-29 Thread Yi Sun
From: Liu Yi L 

Should get correct sid and set it into sdev. Because we execute
'sdev->sid != req->rid' in the loop of prq_event_thread().

Fixes: eb8d93ea3c1d ("iommu/vt-d: Report page request faults for guest SVA")
Signed-off-by: Liu Yi L 
Signed-off-by: Yi Sun 
---
 drivers/iommu/intel/svm.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
index f1861fa..7584669 100644
--- a/drivers/iommu/intel/svm.c
+++ b/drivers/iommu/intel/svm.c
@@ -279,6 +279,7 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, 
struct device *dev,
struct intel_iommu *iommu = device_to_iommu(dev, NULL, NULL);
struct intel_svm_dev *sdev = NULL;
struct dmar_domain *dmar_domain;
+   struct device_domain_info *info;
struct intel_svm *svm = NULL;
int ret = 0;
 
@@ -310,6 +311,10 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, 
struct device *dev,
if (data->hpasid <= 0 || data->hpasid >= PASID_MAX)
return -EINVAL;
 
+   info = get_domain_info(dev);
+   if (!info)
+   return -EINVAL;
+
dmar_domain = to_dmar_domain(domain);
 
mutex_lock(&pasid_mutex);
@@ -357,6 +362,7 @@ int intel_svm_bind_gpasid(struct iommu_domain *domain, 
struct device *dev,
goto out;
}
sdev->dev = dev;
+   sdev->sid = PCI_DEVID(info->bus, info->devfn);
 
/* Only count users if device has aux domains */
if (iommu_dev_feature_enabled(dev, IOMMU_DEV_FEAT_AUX))
-- 
2.7.4