iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3
@ 2021-05-19  1:50 Lu Baolu
  2021-05-19  1:50 ` [PATCH 1/2] iommu/vt-d: Check for allocation failure in aux_detach_device() Lu Baolu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lu Baolu @ 2021-05-19  1:50 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, Dan Carpenter

Hi Joerg,

Two small fixes are queued in this series. It includes:

 - Use user privilege for RID2PASID translation
 - Check memory allocation return value

Please consider them for v5.13.

Best regards,
Lu Baolu

Dan Carpenter (1):
  iommu/vt-d: Check for allocation failure in aux_detach_device()

Lu Baolu (1):
  iommu/vt-d: Use user privilege for RID2PASID translation

 drivers/iommu/intel/iommu.c | 9 +++++++--
 drivers/iommu/intel/pasid.c | 3 ++-
 2 files changed, 9 insertions(+), 3 deletions(-)

-- 
2.25.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* [PATCH 1/2] iommu/vt-d: Check for allocation failure in aux_detach_device()
  2021-05-19  1:50 [PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3 Lu Baolu
@ 2021-05-19  1:50 ` Lu Baolu
  2021-05-19  1:50 ` [PATCH 2/2] iommu/vt-d: Use user privilege for RID2PASID translation Lu Baolu
  2021-05-19  6:52 ` [PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3 Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Lu Baolu @ 2021-05-19  1:50 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, Dan Carpenter

From: Dan Carpenter <dan.carpenter@oracle.com>

In current kernels small allocations never fail, but checking for
allocation failure is the correct thing to do.

Fixes: 18abda7a2d55 ("iommu/vt-d: Fix general protection fault in aux_detach_device()")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/YJuobKuSn81dOPLd@mwanda
---
 drivers/iommu/intel/iommu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 708f430af1c4..9a7b79b5af18 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -4606,6 +4606,8 @@ static int auxiliary_link_device(struct dmar_domain *domain,
 
 	if (!sinfo) {
 		sinfo = kzalloc(sizeof(*sinfo), GFP_ATOMIC);
+		if (!sinfo)
+			return -ENOMEM;
 		sinfo->domain = domain;
 		sinfo->pdev = dev;
 		list_add(&sinfo->link_phys, &info->subdevices);
-- 
2.25.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* [PATCH 2/2] iommu/vt-d: Use user privilege for RID2PASID translation
  2021-05-19  1:50 [PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3 Lu Baolu
  2021-05-19  1:50 ` [PATCH 1/2] iommu/vt-d: Check for allocation failure in aux_detach_device() Lu Baolu
@ 2021-05-19  1:50 ` Lu Baolu
  2021-05-19  6:52 ` [PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3 Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Lu Baolu @ 2021-05-19  1:50 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, Dan Carpenter

When first-level page tables are used for IOVA translation, we use user
privilege by setting U/S bit in the page table entry. This is to make it
consistent with the second level translation, where the U/S enforcement
is not available. Clear the SRE (Supervisor Request Enable) field in the
pasid table entry of RID2PASID so that requests requesting the supervisor
privilege are blocked and treated as DMA remapping faults.

Fixes: b802d070a52a1 ("iommu/vt-d: Use iova over first level")
Suggested-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20210512064426.3440915-1-baolu.lu@linux.intel.com
---
 drivers/iommu/intel/iommu.c | 7 +++++--
 drivers/iommu/intel/pasid.c | 3 ++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 9a7b79b5af18..be35284a2016 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -2525,9 +2525,9 @@ static int domain_setup_first_level(struct intel_iommu *iommu,
 				    struct device *dev,
 				    u32 pasid)
 {
-	int flags = PASID_FLAG_SUPERVISOR_MODE;
 	struct dma_pte *pgd = domain->pgd;
 	int agaw, level;
+	int flags = 0;
 
 	/*
 	 * Skip top levels of page tables for iommu which has
@@ -2543,7 +2543,10 @@ static int domain_setup_first_level(struct intel_iommu *iommu,
 	if (level != 4 && level != 5)
 		return -EINVAL;
 
-	flags |= (level == 5) ? PASID_FLAG_FL5LP : 0;
+	if (pasid != PASID_RID2PASID)
+		flags |= PASID_FLAG_SUPERVISOR_MODE;
+	if (level == 5)
+		flags |= PASID_FLAG_FL5LP;
 
 	if (domain->domain.type == IOMMU_DOMAIN_UNMANAGED)
 		flags |= PASID_FLAG_PAGE_SNOOP;
diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
index 72646bafc52f..72dc84821dad 100644
--- a/drivers/iommu/intel/pasid.c
+++ b/drivers/iommu/intel/pasid.c
@@ -699,7 +699,8 @@ int intel_pasid_setup_second_level(struct intel_iommu *iommu,
 	 * Since it is a second level only translation setup, we should
 	 * set SRE bit as well (addresses are expected to be GPAs).
 	 */
-	pasid_set_sre(pte);
+	if (pasid != PASID_RID2PASID)
+		pasid_set_sre(pte);
 	pasid_set_present(pte);
 	pasid_flush_caches(iommu, pte, pasid, did);
 
-- 
2.25.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3
  2021-05-19  1:50 [PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3 Lu Baolu
  2021-05-19  1:50 ` [PATCH 1/2] iommu/vt-d: Check for allocation failure in aux_detach_device() Lu Baolu
  2021-05-19  1:50 ` [PATCH 2/2] iommu/vt-d: Use user privilege for RID2PASID translation Lu Baolu
@ 2021-05-19  6:52 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2021-05-19  6:52 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu, Dan Carpenter

On Wed, May 19, 2021 at 09:50:25AM +0800, Lu Baolu wrote:
> Hi Joerg,
> 
> Two small fixes are queued in this series. It includes:
> 
>  - Use user privilege for RID2PASID translation
>  - Check memory allocation return value
> 
> Please consider them for v5.13.
> 
> Best regards,
> Lu Baolu
> 
> Dan Carpenter (1):
>   iommu/vt-d: Check for allocation failure in aux_detach_device()
> 
> Lu Baolu (1):
>   iommu/vt-d: Use user privilege for RID2PASID translation

Applied for v5.13, thanks.

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

end of thread, other threads:[~2021-05-19  6:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19  1:50 [PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3 Lu Baolu
2021-05-19  1:50 ` [PATCH 1/2] iommu/vt-d: Check for allocation failure in aux_detach_device() Lu Baolu
2021-05-19  1:50 ` [PATCH 2/2] iommu/vt-d: Use user privilege for RID2PASID translation Lu Baolu
2021-05-19  6:52 ` [PATCH 0/2] [PULL REQUEST] iommu/vt-d: Fixes for v5.13-rc3 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).