iommu/vt-d: Missing checks for pasid tables if allocation fails
PATCH 1/3 iommu/vt-d: Missing checks for pasid tables if allocation fails
intel_svm_alloc_pasid_tables() might return an error but never be checked by the callers. Later when intel_svm_bind_mm() is called, there are no checks for valid pasid tables before enabling them.
--- drivers/iommu/intel-svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-svm.c +1 -1
@@ -292,7 +292,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_int pasid_max;int ret; -if (WARN_ON (!iommu)) +if (WARN_ON (!iommu || !iommu->pasid_table))return -EINVAL ;if (dev_is_pci (dev)) {
Signature · 1 line
2.7.4
PATCH 2/3 iommu/vt-d: Clear Page Request Overflow fault bit
Currently Page Request Overflow bit in IOMMU Fault Status register is not cleared. Not clearing this bit would mean that any future page-request is going to be automatically dropped by IOMMU.
--- drivers/iommu/dmar.c | 3 ++- include/linux/intel-iommu.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/dmar.c +2 -1
@@ -1679,7 +1679,8 @@ irqreturn_t dmar_fault(int irq, void *dev_id)raw_spin_lock_irqsave (&iommu->register_lock, flag); } -writel (DMA_FSTS_PFO |DMA_FSTS_PPF , iommu->reg +DMAR_FSTS_REG ); +writel (DMA_FSTS_PFO |DMA_FSTS_PPF |DMA_FSTS_PRO , + iommu->reg +DMAR_FSTS_REG ); unlock_exit:raw_spin_unlock_irqrestore (&iommu->register_lock, flag);
include/linux/intel-iommu.h +1 -0
@@ -212,6 +212,7 @@#define DMA_FSTS_IQE (1 << 4)#define DMA_FSTS_ICE (1 << 5)#define DMA_FSTS_ITE (1 << 6) +#define DMA_FSTS_PRO (1 << 7)#define dma_fsts_fault_record_index (s) (((s) >> 8) & 0xff)/* FRCD_REG, 32 bits access */
Signature · 1 line
2.7.4
PATCH 3/3 iommu/vt-d: Clear pasid table entry when memory unbound
In reply to Lu BaoluIn intel_svm_unbind_mm(), pasid table entry must be cleared during svm free. Otherwise, hardware may be set up with a wild pointer.
--- drivers/iommu/intel-svm.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/iommu/intel-svm.c +2 -0
@@ -458,6 +458,8 @@ int intel_svm_unbind_mm(struct device *dev, int pasid)kfree_rcu (sdev, rcu);if (list_empty (&svm->devs)) { + svm->iommu->pasid_table[svm->pasid].val =0 ; +wmb ();idr_remove (&svm->iommu->pasid_idr, svm->pasid);if (svm->mm)
Signature · 1 line
2.7.4
Quoted 26 lines
-----Original Message-----
From: [email protected] [mailto:iommu- [email protected]] On Behalf Of Lu Baolu
Sent: Thursday, October 19, 2017 8:39 AM
To: [email protected]; [email protected]
Cc: [email protected]; [email protected]
Subject: [PATCH 1/3] iommu/vt-d: Missing checks for pasid tables if allocation fails
intel_svm_alloc_pasid_tables()might return an error but never be checked by the callers. Later whenintel_svm_bind_mm()is called, there are no checks for valid pasid tables before enabling them.Signed-off-by Ashok Raj <[email protected]>Signed-off-by Lu Baolu <[email protected]>--- drivers/iommu/intel-svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/intel-svm.c index renamed from drivers/iommu/intel-svm.c +0
-0f6697e5..43280ca 100644
drivers/iommu/intel-svm.c +0
-0@@ -292,7 +292,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, intflags, struct
svm_dev_
drivers/iommu/intel-svm.c int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ · line 295
Quoted 5 lines
drivers/iommu/intel-svm.c +1
-1int pasid_max;int ret; -if (WARN_ON (!iommu)) +if (WARN_ON (!iommu || !iommu->pasid_table))
[Liu, Yi L] Hi Baolu, I guess there also need a check to iommu->ecap , see if the pasid bit is reported. thoughts?
Regards,
Yi L
Quoted 10 lines
drivers/iommu/intel-svm.c +0
-1return -EINVAL ;if (dev_is_pci (dev)) { --2.7.4
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu
Hi Yi,
Quoted 28 lines · Yi L
Quoted 28 lines
-----Original Message-----
From: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org [mailto:iommu- bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org] On Behalf Of Lu Baolu
Sent: Thursday, October 19, 2017 8:39 AM
To: [email protected]; [email protected]
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; [email protected]
Subject: [PATCH 1/3] iommu/vt-d: Missing checks for pasid tables if allocation fails
intel_svm_alloc_pasid_tables()might return an error but never be checked by the callers. Later whenintel_svm_bind_mm()is called, there are no checks for valid pasid tables before enabling them.Signed-off-by Ashok Raj <[email protected]>--- drivers/iommu/intel-svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/intel-svm.c index renamed from drivers/iommu/intel-svm.c +0
-0f6697e5..43280ca 100644
drivers/iommu/intel-svm.c +0
-0@@ -292,7 +292,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, intflags, struct
svm_dev_drivers/iommu/intel-svm.c +0
-0int pasid_max;int ret;
Quoted 5 lines
drivers/iommu/intel-svm.c int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ · line 295
Quoted 2 lines
drivers/iommu/intel-svm.c +1
-1-if (WARN_ON (!iommu)) +if (WARN_ON (!iommu || !iommu->pasid_table))[Liu, Yi L] Hi Baolu, I guess there also need a check to
iommu->ecap, see if the pasid bit is reported. thoughts?
If pasid bit is not set in ecap register, iommu->pasid_table won't be set.
We did this by:
if (pasid_enabled(iommu))
intel_svm_alloc_pasid_tables(iommu);Best regards,
Lu Baolu
Liu, Yi L
Reviewed-byQuoted 48 lines
-----Original Message-----
From: Lu Baolu [mailto:baolu.lu-VuQAYsv1563Yd54FQh9/[email protected]]
Sent: Friday, October 20, 2017 8:49 AM
To: Liu, Yi L <[email protected]>; [email protected]; [email protected]
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; [email protected]
Subject: Re: [PATCH 1/3] iommu/vt-d: Missing checks for pasid tables if allocation
failsHi Yi,
Quoted 29 lines · Yi L
Quoted 29 lines
-----Original Message-----
From: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org [mailto:iommu- bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org] On Behalf Of Lu Baolu
Sent: Thursday, October 19, 2017 8:39 AM
To: [email protected]; [email protected]
Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org; [email protected]
Subject: [PATCH 1/3] iommu/vt-d: Missing checks for pasid tables if
allocation fails
intel_svm_alloc_pasid_tables()might return an error but never be checked by the callers. Later whenintel_svm_bind_mm()is called, there are no checks for valid pasid tables before enabling them.Signed-off-by Ashok Raj <[email protected]>--- drivers/iommu/intel-svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/intel-svm.c +0
-0@@ -292,7 +292,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_int pasid_max;int ret;Quoted 5 lines
drivers/iommu/intel-svm.c int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ · line 295
Quoted 2 lines
drivers/iommu/intel-svm.c +1
-1-if (WARN_ON (!iommu)) +if (WARN_ON (!iommu || !iommu->pasid_table))[Liu, Yi L] Hi Baolu, I guess there also need a check to
iommu->ecap, see if the pasid bit is reported. thoughts?
Quoted 6 lines
If pasid bit is not set in ecap register,
iommu->pasid_tablewon't be set.We did this by:
if (pasid_enabled(iommu)) intel_svm_alloc_pasid_tables(iommu);
[Liu, Yi L] Sounds good. thx.
Regards,
Yi L
Alex Williamson
AppliedQuoted 15 lines · On Thu, 19 Oct 2017 08:39:14 +0800 Lu Baolu…
intel_svm_alloc_pasid_tables()might return an error but never be checked by the callers. Later whenintel_svm_bind_mm()is called, there are no checks for valid pasid tables before enabling them.Signed-off-by Ashok Raj <[email protected]>--- drivers/iommu/intel-svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/intel-svm.c +0
-0
drivers/iommu/intel-svm.c int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ · line 298
Quoted 8 lines
drivers/iommu/intel-svm.c +1
-1@@ -292,7 +292,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_int pasid_max;int ret; -if (WARN_ON (!iommu)) +if (WARN_ON (!iommu || !iommu->pasid_table))return -EINVAL ;if (dev_is_pci (dev)) {
Applied series to iommu/vt-d for v4.15. Thanks,
Alex
Hi,
Quoted 21 lines · Alex Williamson
Quoted 18 lines · On Thu, 19 Oct 2017 08:39:14 +0800 Lu Baolu…
intel_svm_alloc_pasid_tables()might return an error but never be checked by the callers. Later whenintel_svm_bind_mm()is called, there are no checks for valid pasid tables before enabling them.Signed-off-by Ashok Raj <[email protected]>--- drivers/iommu/intel-svm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/iommu/intel-svm.c +0
-0@@ -292,7 +292,7 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_int pasid_max;int ret;
Quoted 9 lines
drivers/iommu/intel-svm.c int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ · line 298
Quoted 5 lines
drivers/iommu/intel-svm.c +1
-1-if (WARN_ON (!iommu)) +if (WARN_ON (!iommu || !iommu->pasid_table))return -EINVAL ;if (dev_is_pci (dev)) {Applied series to iommu/vt-d for v4.15. Thanks,
Alex
Thank you, Alex.
Best regards,
Lu Baolu