Skip to contentSkip to conversation

Intel IOMMU updates for Linux v6.5

GIT PULL New Lu Baolu 2 participants 6 messages Jun 14, 2023 – Jun 16, 2023

Subsystems (2)
lore
Share & tools
lore

Lu Baolu

author maintainer
#0 lore raw

Hi Joerg,

This includes patches queued for v6.5. They are:

- Small and misc cleanups

The whole series is based on v6.4-rc6 and also available at:
https://github.com/LuBaolu/intel-iommu/commits/vtd-update-for-v6.5

Please pull them for x86/vt-d branch.

Best regards,
Baolu

Lu Baolu (1):
iommu/vt-d: Remove commented-out code

Suhui (1):
iommu/vt-d: Remove unnecessary (void*) conversions

Yanfei Xu (2):
iommu/vt-d: Handle the failure case of dmar_reenable_qi() iommu/vt-d: Remove two WARN_ON in domain_context_mapping_one()

 drivers/iommu/intel/iommu.c | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)
Signature · 1 line
2.34.1
author maintainer
#1 lore raw

PATCH 1/4 iommu/vt-d: Remove unnecessary (void*) conversions

From: Suhui <[email protected]>

No need cast (void*) to (struct root_entry *).

---
 drivers/iommu/intel/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel/iommu.c +1 -1
index b871a6afd803..323fa1a93765 100644
@@ -1185,7 +1185,7 @@ static int iommu_alloc_root_entry(struct intel_iommu *iommu)
 {
 	struct root_entry *root;
 
-	root = (struct root_entry *)alloc_pgtable_page(iommu->node, GFP_ATOMIC);
+	root = alloc_pgtable_page(iommu->node, GFP_ATOMIC);
 	if (!root) {
 		pr_err("Allocating root entry for %s failed\n",
 			iommu->name);
Signature · 1 line
2.34.1
author maintainer
#2 lore raw

PATCH 2/4 iommu/vt-d: Handle the failure case of dmar_reenable_qi()

In reply to Lu Baolu

From: Yanfei Xu <[email protected]>

dmar_reenable_qi() may not succeed. Check and return when it fails.

---
 drivers/iommu/intel/iommu.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/iommu/intel/iommu.c +8 -3
index 323fa1a93765..e83fe243680b 100644
@@ -2967,10 +2967,15 @@ static int init_iommu_hw(void)
 {
 	struct dmar_drhd_unit *drhd;
 	struct intel_iommu *iommu = NULL;
+	int ret;
 
-	for_each_active_iommu(iommu, drhd)
-		if (iommu->qi)
-			dmar_reenable_qi(iommu);
+	for_each_active_iommu(iommu, drhd) {
+		if (iommu->qi) {
+			ret = dmar_reenable_qi(iommu);
+			if (ret)
+				return ret;
+		}
+	}
 
 	for_each_iommu(iommu, drhd) {
 		if (drhd->ignored) {
Signature · 1 line
2.34.1
author maintainer
#3 lore raw

PATCH 3/4 iommu/vt-d: Remove two WARN_ON in domain_context_mapping_one()

In reply to Lu Baolu

From: Yanfei Xu <[email protected]>

Remove the WARN_ON(did == 0) as the domain id 0 is reserved and set once the domain_ids is allocated. So iommu_init_domains will never return 0.

Remove the WARN_ON(!table) as this pointer will be accessed in the following code, if empty "table" really happens, the kernel will report a NULL pointer reference warning at the first place.

---
 drivers/iommu/intel/iommu.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/iommu/intel/iommu.c +0 -4
index e83fe243680b..4c0b7424c45e 100644
@@ -1897,8 +1897,6 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
 	struct context_entry *context;
 	int ret;
 
-	WARN_ON(did == 0);
-
 	if (hw_pass_through && domain_type_is_si(domain))
 		translation = CONTEXT_TT_PASS_THROUGH;
 
@@ -1944,8 +1942,6 @@ static int domain_context_mapping_one(struct dmar_domain *domain,
 	if (sm_supported(iommu)) {
 		unsigned long pds;
 
-		WARN_ON(!table);
-
 		/* Setup the PASID DIR pointer: */
 		pds = context_get_sm_pds(table);
 		context->lo = (u64)virt_to_phys(table->table) |
Signature · 1 line
2.34.1
author maintainer
#4 lore raw

PATCH 4/4 iommu/vt-d: Remove commented-out code

In reply to Lu Baolu

These lines of code were commented out when they were first added in commit ba39592764ed ("Intel IOMMU: Intel IOMMU driver"). We do not want to restore them because the VT-d spec has deprecated the read/write draining hit.

VT-d spec (section 11.4.2):
"
Hardware implementation with Major Version 2 or higher (VER_REG), always performs required drain without software explicitly requesting a drain in IOTLB invalidation. This field is deprecated and hardware will always report it as 1 to maintain backward compatibility with software.
"

Remove the code to make the code cleaner.

---
 drivers/iommu/intel/iommu.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
drivers/iommu/intel/iommu.c +1 -9
index 4c0b7424c45e..e5c111ff4dd9 100644
@@ -1312,15 +1312,7 @@ static void __iommu_flush_iotlb(struct intel_iommu *iommu, u16 did,
 			iommu->name, type);
 		return;
 	}
-	/* Note: set drain read/write */
-#if 0
-	/*
-	 * This is probably to be super secure.. Looks like we can
-	 * ignore it without any impact.
-	 */
-	if (cap_read_drain(iommu->cap))
-		val |= DMA_TLB_READ_DRAIN;
-#endif
+
 	if (cap_write_drain(iommu->cap))
 		val |= DMA_TLB_WRITE_DRAIN;
 
Signature · 1 line
2.34.1