Skip to contentSkip to conversation

iommu/vt-d: improve IOMMU fault information

PATCH Superseded Guanghui Feng 2 participants 5 messages May 25 – Jun 1

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/vt-d: improve IOMMU fault information

In some environments, multiple PCIe segments exist, and PCIe device information needs to be differentiated and identified based on the segment. When an IOMMU fault event occurs, the IOMMU and device segment information should be output in detail in dmar_fault_do_one.

---
 drivers/iommu/intel/dmar.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/iommu/intel/dmar.c +8 -3
index d33c119a935e..ca9afbb55e76 100644
@@ -1894,7 +1894,8 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,
 	reason = dmar_get_fault_reason(fault_reason, &fault_type);
 
 	if (fault_type == INTR_REMAP) {
-		pr_err("[INTR-REMAP] Request device [%02x:%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
+		pr_err("[DMAR:%s] [INTR-REMAP] Request device [%04x:%02x:%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
+		       iommu->name, iommu->segment,
 		       source_id >> 8, PCI_SLOT(source_id & 0xFF),
 		       PCI_FUNC(source_id & 0xFF), addr >> 48,
 		       fault_reason, reason);
@@ -1903,14 +1904,18 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,
 	}
 
 	if (pasid == IOMMU_PASID_INVALID)
-		pr_err("[%s NO_PASID] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+		pr_err("[DMAR:%s] [%s NO_PASID] Request device [%04x:%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+		       iommu->name,
 		       type ? "DMA Read" : "DMA Write",
+		       iommu->segment,
 		       source_id >> 8, PCI_SLOT(source_id & 0xFF),
 		       PCI_FUNC(source_id & 0xFF), addr,
 		       fault_reason, reason);
 	else
-		pr_err("[%s PASID 0x%x] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+		pr_err("[DMAR:%s] [%s PASID 0x%x] Request device [%04x:%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+		       iommu->name,
 		       type ? "DMA Read" : "DMA Write", pasid,
+		       iommu->segment,
 		       source_id >> 8, PCI_SLOT(source_id & 0xFF),
 		       PCI_FUNC(source_id & 0xFF), addr,
 		       fault_reason, reason);
Signature · 1 line
2.43.7
maintainer
#1 lore raw
Quoted 25 lines · Guanghui Feng

In some environments, multiple PCIe segments exist, and PCIe device information needs to be differentiated and identified based on the segment. When an IOMMU fault event occurs, the IOMMU and device segment information should be output in detail in dmar_fault_do_one.

---
  drivers/iommu/intel/dmar.c | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)
drivers/iommu/intel/dmar.c +2 -1
index d33c119a935e..ca9afbb55e76 100644
@@ -1894,7 +1894,8 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,
  	reason = dmar_get_fault_reason(fault_reason, &fault_type);
 
  	if (fault_type == INTR_REMAP) {
-		pr_err("[INTR-REMAP] Request device [%02x:%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
+		pr_err("[DMAR:%s] [INTR-REMAP] Request device [%04x:%02x:%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
+		       iommu->name, iommu->segment,
  		       source_id >> 8, PCI_SLOT(source_id & 0xFF),
  		       PCI_FUNC(source_id & 0xFF), addr >> 48,
  		       fault_reason, reason);

drivers/iommu/intel/dmar.c static int dmar_fault_do_one(struct intel_iommu *iommu, int type, · line 1908

Quoted 6 lines
drivers/iommu/intel/dmar.c +2 -1
@@ -1903,14 +1904,18 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,
  	}
 
  	if (pasid == IOMMU_PASID_INVALID)
-		pr_err("[%s NO_PASID] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+		pr_err("[DMAR:%s] [%s NO_PASID] Request device [%04x:%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+		       iommu->name,

Do you really need to dump "iommu->name"? It is purely assigned by the IOMMU driver software. Do you mind explaining what kind of information you want to get from it?

Quoted 4 lines
drivers/iommu/intel/dmar.c +1 -0
  		       type ? "DMA Read" : "DMA Write",
+		       iommu->segment,
  		       source_id >> 8, PCI_SLOT(source_id & 0xFF),
  		       PCI_FUNC(source_id & 0xFF), addr,

drivers/iommu/intel/dmar.c static int dmar_fault_do_one(struct intel_iommu *iommu, int type, · line 1921

Quoted 10 lines
drivers/iommu/intel/dmar.c +3 -1
  		       fault_reason, reason);
  	else
-		pr_err("[%s PASID 0x%x] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+		pr_err("[DMAR:%s] [%s PASID 0x%x] Request device [%04x:%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+		       iommu->name,
  		       type ? "DMA Read" : "DMA Write", pasid,
+		       iommu->segment,
  		       source_id >> 8, PCI_SLOT(source_id & 0xFF),
  		       PCI_FUNC(source_id & 0xFF), addr,
  		       fault_reason, reason);

Thanks,
baolu

#2 lore raw
Quoted 32 lines · Baolu Lu
Quoted 31 lines · Guanghui Feng

In some environments, multiple PCIe segments exist, and PCIe device information needs to be differentiated and identified based on the segment. When an IOMMU fault event occurs, the IOMMU and device segment information should be output in detail in dmar_fault_do_one.

---
  drivers/iommu/intel/dmar.c | 11 ++++++++---

  1 file changed, 8 insertions(+), 3 deletions(-)
drivers/iommu/intel/dmar.c +2 -1
index d33c119a935e..ca9afbb55e76 100644
@@ -1894,7 +1894,8 @@ static int dmar_fault_do_one(struct intel_iommu 
 *iommu, int type,
       reason = dmar_get_fault_reason(fault_reason, &fault_type);
         if (fault_type == INTR_REMAP) {
-        pr_err("[INTR-REMAP] Request device [%02x:%02x.%d] fault 
 index 0x%llx [fault reason 0x%02x] %s\n",
+        pr_err("[DMAR:%s] [INTR-REMAP] Request device 
 [%04x:%02x:%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
+               iommu->name, iommu->segment,
                  source_id >> 8, PCI_SLOT(source_id & 0xFF),

                 PCI_FUNC(source_id & 0xFF), addr >> 48, fault_reason, reason);

drivers/iommu/intel/dmar.c +0 -1
@@ -1903,14 +1904,18 @@ static int dmar_fault_do_one(struct 
 intel_iommu *iommu, int type,
       }
         if (pasid == IOMMU_PASID_INVALID)
-        pr_err("[%s NO_PASID] Request device [%02x:%02x.%d] fault 
Quoted 9 lines

drivers/iommu/intel/dmar.c static int dmar_fault_do_one(struct · line 1910

Quoted 4 lines
drivers/iommu/intel/dmar.c +2 -0
 addr 0x%llx [fault reason 0x%02x] %s\n",
+        pr_err("[DMAR:%s] [%s NO_PASID] Request device 
 [%04x:%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+               iommu->name,

Do you really need to dump "iommu->name"? It is purely assigned by the IOMMU driver software. Do you mind explaining what kind of information you want to get from it?

Thanks for your reply.

1. In environments with multiple PCIe segments/domains, precise differentiation based on device information

is needed when an IOMMU fault occurs. Therefore, segment information was added.

2. Adding IOMMU information to an IOMMU fault is not mandatory. Related IOMMU information

can be obtained through various methods such as /sys/bus/pci/devices/[bdf]/iommu.

A new patch will be resubmitted for modification.

Quoted 19 lines
Quoted 8 lines
drivers/iommu/intel/dmar.c +1 -0
                  type ? "DMA Read" : "DMA Write",
+               iommu->segment,
                  source_id >> 8, PCI_SLOT(source_id & 0xFF),
                  PCI_FUNC(source_id & 0xFF), addr,
                  fault_reason, reason);

      else
-        pr_err("[%s PASID 0x%x] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",

Quoted 8 lines

+        pr_err("[DMAR:%s] [%s PASID 0x%x] Request device [%04x:%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n", +               iommu->name,
                 type ? "DMA Read" : "DMA Write", pasid, +               iommu->segment,
                 source_id >> 8, PCI_SLOT(source_id & 0xFF), PCI_FUNC(source_id & 0xFF), addr, fault_reason, reason);

Thanks,
baolu

#3 lore raw

PATCH v2 1/1 iommu/vt-d: improve IOMMU fault information

In some environments, multiple PCIe segments exist, and PCIe device information needs to be differentiated and identified based on the segment. When an IOMMU fault event occurs, the IOMMU and device segment information should be output in detail in dmar_fault_do_one.

---
 drivers/iommu/intel/dmar.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/iommu/intel/dmar.c +6 -3
index d33c119a935e..767ec092accd 100644
@@ -1894,7 +1894,8 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,
 	reason = dmar_get_fault_reason(fault_reason, &fault_type);
 
 	if (fault_type == INTR_REMAP) {
-		pr_err("[INTR-REMAP] Request device [%02x:%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
+		pr_err("[INTR-REMAP] Request device [%04x:%02x:%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n",
+		       iommu->segment,
 		       source_id >> 8, PCI_SLOT(source_id & 0xFF),
 		       PCI_FUNC(source_id & 0xFF), addr >> 48,
 		       fault_reason, reason);
@@ -1903,14 +1904,16 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,
 	}
 
 	if (pasid == IOMMU_PASID_INVALID)
-		pr_err("[%s NO_PASID] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+		pr_err("[%s NO_PASID] Request device [%04x:%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
 		       type ? "DMA Read" : "DMA Write",
+		       iommu->segment,
 		       source_id >> 8, PCI_SLOT(source_id & 0xFF),
 		       PCI_FUNC(source_id & 0xFF), addr,
 		       fault_reason, reason);
 	else
-		pr_err("[%s PASID 0x%x] Request device [%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
+		pr_err("[%s PASID 0x%x] Request device [%04x:%02x:%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n",
 		       type ? "DMA Read" : "DMA Write", pasid,
+		       iommu->segment,
 		       source_id >> 8, PCI_SLOT(source_id & 0xFF),
 		       PCI_FUNC(source_id & 0xFF), addr,
 		       fault_reason, reason);
Signature · 1 line
2.43.7
maintainer Applied
#4 lore raw
Quoted 9 lines · Guanghui Feng

In some environments, multiple PCIe segments exist, and PCIe device information needs to be differentiated and identified based on the segment. When an IOMMU fault event occurs, the IOMMU and device segment information should be output in detail in dmar_fault_do_one.

---
  drivers/iommu/intel/dmar.c | 9 ++++++---
  1 file changed, 6 insertions(+), 3 deletions(-)

Queued for linux-next. Thank you!