linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] iommu: Fix a few issues related to PRQ
@ 2020-10-30  2:37 Yi Sun
  2020-10-30  2:37 ` [PATCH v2 1/2] iommu/vt-d: Fix sid not set issue in intel_svm_bind_gpasid() Yi Sun
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Yi Sun @ 2020-10-30  2:37 UTC (permalink / raw)
  To: joro, dwmw2, baolu.lu, jean-philippe
  Cc: iommu, linux-kernel, yi.l.liu, jacob.jun.pan, Yi Sun

We found a few issues about PRQ. So, two patches are cooked to
fix them. Please have a review. Thanks!

Changes from v1:
================
- Modify subject of patch 1 to make it more accurate.
- Move get_domain_info() up to the sanity check part in patch 1.
- Remove v1 patch 2 which is not suitable.
- Add description for current patch 2.
- Add 'Fixes:' tags for all patches.

Liu Yi L (1):
  iommu/vt-d: Fix sid not set issue in in intel_svm_bind_gpasid()

Liu, Yi L (1):
  iommu/vt-d: Fix a bug for PDP check in prq_event_thread

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

-- 
2.7.4


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/2] iommu/vt-d: Fix sid not set issue in intel_svm_bind_gpasid()
  2020-10-30  2:37 [PATCH v2 0/2] iommu: Fix a few issues related to PRQ Yi Sun
@ 2020-10-30  2:37 ` Yi Sun
  2020-10-30 12:48   ` Lu Baolu
  2020-10-30  2:37 ` [PATCH v2 2/2] iommu/vt-d: Fix a bug for PDP check in prq_event_thread Yi Sun
  2020-11-03 13:37 ` [PATCH v2 0/2] iommu: Fix a few issues related to PRQ Joerg Roedel
  2 siblings, 1 reply; 6+ messages in thread
From: Yi Sun @ 2020-10-30  2:37 UTC (permalink / raw)
  To: joro, dwmw2, baolu.lu, jean-philippe
  Cc: iommu, linux-kernel, yi.l.liu, jacob.jun.pan, Yi Sun

From: Liu Yi L <yi.l.liu@intel.com>

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 <yi.l.liu@intel.com>
Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] iommu/vt-d: Fix a bug for PDP check in prq_event_thread
  2020-10-30  2:37 [PATCH v2 0/2] iommu: Fix a few issues related to PRQ Yi Sun
  2020-10-30  2:37 ` [PATCH v2 1/2] iommu/vt-d: Fix sid not set issue in intel_svm_bind_gpasid() Yi Sun
@ 2020-10-30  2:37 ` Yi Sun
  2020-10-30 12:49   ` Lu Baolu
  2020-11-03 13:37 ` [PATCH v2 0/2] iommu: Fix a few issues related to PRQ Joerg Roedel
  2 siblings, 1 reply; 6+ messages in thread
From: Yi Sun @ 2020-10-30  2:37 UTC (permalink / raw)
  To: joro, dwmw2, baolu.lu, jean-philippe
  Cc: iommu, linux-kernel, yi.l.liu, jacob.jun.pan, Liu, Yi Sun

From: "Liu, Yi L" <yi.l.liu@intel.com>

In prq_event_thread(), the QI_PGRP_PDP is wrongly set by
'req->pasid_present' which should be replaced to
'req->priv_data_present'.

Fixes: 5b438f4ba315 ("iommu/vt-d: Support page request in scalable mode")
Signed-off-by: Liu, Yi L <yi.l.liu@intel.com>
Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>
---
 drivers/iommu/intel/svm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
index 7584669..3242ebd 100644
--- a/drivers/iommu/intel/svm.c
+++ b/drivers/iommu/intel/svm.c
@@ -1035,7 +1035,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)
 			resp.qw0 = QI_PGRP_PASID(req->pasid) |
 				QI_PGRP_DID(req->rid) |
 				QI_PGRP_PASID_P(req->pasid_present) |
-				QI_PGRP_PDP(req->pasid_present) |
+				QI_PGRP_PDP(req->priv_data_present) |
 				QI_PGRP_RESP_CODE(result) |
 				QI_PGRP_RESP_TYPE;
 			resp.qw1 = QI_PGRP_IDX(req->prg_index) |
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] iommu/vt-d: Fix sid not set issue in intel_svm_bind_gpasid()
  2020-10-30  2:37 ` [PATCH v2 1/2] iommu/vt-d: Fix sid not set issue in intel_svm_bind_gpasid() Yi Sun
@ 2020-10-30 12:48   ` Lu Baolu
  0 siblings, 0 replies; 6+ messages in thread
From: Lu Baolu @ 2020-10-30 12:48 UTC (permalink / raw)
  To: Yi Sun, joro, dwmw2, jean-philippe
  Cc: baolu.lu, iommu, linux-kernel, yi.l.liu, jacob.jun.pan

On 10/30/20 10:37 AM, Yi Sun wrote:
> From: Liu Yi L <yi.l.liu@intel.com>
> 
> 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 <yi.l.liu@intel.com>
> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>

Cc: stable@ver.kernel.org
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>

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))
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] iommu/vt-d: Fix a bug for PDP check in prq_event_thread
  2020-10-30  2:37 ` [PATCH v2 2/2] iommu/vt-d: Fix a bug for PDP check in prq_event_thread Yi Sun
@ 2020-10-30 12:49   ` Lu Baolu
  0 siblings, 0 replies; 6+ messages in thread
From: Lu Baolu @ 2020-10-30 12:49 UTC (permalink / raw)
  To: Yi Sun, joro, dwmw2, jean-philippe
  Cc: baolu.lu, iommu, linux-kernel, yi.l.liu, jacob.jun.pan

On 10/30/20 10:37 AM, Yi Sun wrote:
> From: "Liu, Yi L" <yi.l.liu@intel.com>
> 
> In prq_event_thread(), the QI_PGRP_PDP is wrongly set by
> 'req->pasid_present' which should be replaced to
> 'req->priv_data_present'.
> 
> Fixes: 5b438f4ba315 ("iommu/vt-d: Support page request in scalable mode")
> Signed-off-by: Liu, Yi L <yi.l.liu@intel.com>
> Signed-off-by: Yi Sun <yi.y.sun@linux.intel.com>

Cc: stable@ver.kernel.org
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>

Best regards,
baolu

> ---
>   drivers/iommu/intel/svm.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
> index 7584669..3242ebd 100644
> --- a/drivers/iommu/intel/svm.c
> +++ b/drivers/iommu/intel/svm.c
> @@ -1035,7 +1035,7 @@ static irqreturn_t prq_event_thread(int irq, void *d)
>   			resp.qw0 = QI_PGRP_PASID(req->pasid) |
>   				QI_PGRP_DID(req->rid) |
>   				QI_PGRP_PASID_P(req->pasid_present) |
> -				QI_PGRP_PDP(req->pasid_present) |
> +				QI_PGRP_PDP(req->priv_data_present) |
>   				QI_PGRP_RESP_CODE(result) |
>   				QI_PGRP_RESP_TYPE;
>   			resp.qw1 = QI_PGRP_IDX(req->prg_index) |
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 0/2] iommu: Fix a few issues related to PRQ
  2020-10-30  2:37 [PATCH v2 0/2] iommu: Fix a few issues related to PRQ Yi Sun
  2020-10-30  2:37 ` [PATCH v2 1/2] iommu/vt-d: Fix sid not set issue in intel_svm_bind_gpasid() Yi Sun
  2020-10-30  2:37 ` [PATCH v2 2/2] iommu/vt-d: Fix a bug for PDP check in prq_event_thread Yi Sun
@ 2020-11-03 13:37 ` Joerg Roedel
  2 siblings, 0 replies; 6+ messages in thread
From: Joerg Roedel @ 2020-11-03 13:37 UTC (permalink / raw)
  To: Yi Sun
  Cc: dwmw2, baolu.lu, jean-philippe, iommu, linux-kernel, yi.l.liu,
	jacob.jun.pan

On Fri, Oct 30, 2020 at 10:37:22AM +0800, Yi Sun wrote:
> We found a few issues about PRQ. So, two patches are cooked to
> fix them. Please have a review. Thanks!
> 
> Changes from v1:
> ================
> - Modify subject of patch 1 to make it more accurate.
> - Move get_domain_info() up to the sanity check part in patch 1.
> - Remove v1 patch 2 which is not suitable.
> - Add description for current patch 2.
> - Add 'Fixes:' tags for all patches.
> 
> Liu Yi L (1):
>   iommu/vt-d: Fix sid not set issue in in intel_svm_bind_gpasid()
> 
> Liu, Yi L (1):
>   iommu/vt-d: Fix a bug for PDP check in prq_event_thread
> 
>  drivers/iommu/intel/svm.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)

Applied for v5.10, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-03 13:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-30  2:37 [PATCH v2 0/2] iommu: Fix a few issues related to PRQ Yi Sun
2020-10-30  2:37 ` [PATCH v2 1/2] iommu/vt-d: Fix sid not set issue in intel_svm_bind_gpasid() Yi Sun
2020-10-30 12:48   ` Lu Baolu
2020-10-30  2:37 ` [PATCH v2 2/2] iommu/vt-d: Fix a bug for PDP check in prq_event_thread Yi Sun
2020-10-30 12:49   ` Lu Baolu
2020-11-03 13:37 ` [PATCH v2 0/2] iommu: Fix a few issues related to PRQ Joerg Roedel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).