iommu/vt-d: Dump DMAR translation structure
Subsystems (2)
PATCH v3 1/1 iommu/vt-d: Dump DMAR translation structure
When the dmar translation fault happens, the kernel prints a single line fault reason with corresponding hexadecimal code defined in the Intel VT-d specification.
Currently, when user wants to debug the translation fault in detail, debugfs is used for dumping the dmar_translation_struct, which is not available when the kernel failed to boot.
Dump the DMAR translation structure, pagewalk the IO page table and print the page table entry when the fault happens.
This is enabled by CONFIG_IOMMU_DEBUGFS.
---
ChangeLog:
- Change from v2 to v3:
1. Add config option for dmar_fault_dump_ptes for debug.
- Change from v1 to v2:
1. fix compilation issue with different IOMMU config option.
--- drivers/iommu/intel/Kconfig | 4 ++ drivers/iommu/intel/dmar.c | 10 +++- drivers/iommu/intel/iommu.c | 109 ++++++++++++++++++++++++++++++++++++ include/linux/dmar.h | 8 +++ 4 files changed, 129 insertions(+), 2 deletions(-)
drivers/iommu/intel/Kconfig +4 -0
@@ -6,6 +6,9 @@ config DMAR_TABLE config DMAR_PERF bool +config DMAR_DEBUG + bool + config INTEL_IOMMU bool "Support for Intel IOMMU using DMA Remapping Devices" depends on PCI_MSI && ACPI && (X86 || IA64)
@@ -29,6 +32,7 @@ config INTEL_IOMMU_DEBUGFS bool "Export Intel IOMMU internals in Debugfs" depends on INTEL_IOMMU && IOMMU_DEBUGFS select DMAR_PERF + select DMAR_DEBUG help !!!WARNING!!!
drivers/iommu/intel/dmar.c +8 -2
@@ -1943,12 +1943,16 @@ 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 ) +if (fault_type ==INTR_REMAP ) {pr_err ("[INTR-REMAP] Request device [0x%02x:0x%02x.%d] fault index 0x%llx [fault reason 0x%02x] %s\n" , source_id >>8 ,PCI_SLOT (source_id &0xFF ),PCI_FUNC (source_id &0xFF ), addr >>48 , fault_reason, reason); -else if (pasid ==INVALID_IOASID ) + +return 0 ; + } + +if (pasid ==INVALID_IOASID ) pr_err("[%s NO_PASID] Request device [0x%02x:0x%02x.%d] fault addr 0x%llx [fault reason 0x%02x] %s\n", type ? "DMA Read" : "DMA Write", source_id >> 8, PCI_SLOT(source_id & 0xFF),
@@ -1961,6 +1965,8 @@ static int dmar_fault_do_one(struct intel_iommu *iommu, int type,PCI_FUNC (source_id &0xFF ), addr, fault_reason, reason); +dmar_fault_dump_ptes (iommu, source_id, addr, pasid); +return 0 ; }
drivers/iommu/intel/iommu.c +109 -0
121 lines not on this page · raw message
include/linux/dmar.h +8 -0
@@ -131,6 +131,14 @@ static inline int dmar_res_noop(struct acpi_dmar_header *hdr, void *arg)return 0 ; } +#ifdef CONFIG_DMAR_DEBUG +void dmar_fault_dump_ptes (struct intel_iommu *iommu,u16 source_id, +unsigned long long addr,u32 pasid); +#else +static inline void dmar_fault_dump_ptes (struct intel_iommu *iommu,u16 source_id, +unsigned long long addr,u32 pasid) {} +#endif +#ifdef CONFIG_INTEL_IOMMU extern int iommu_detected, no_iommu;extern int intel_iommu_init (void );
Signature · 6 lines
2.17.1 _______________________________________________ iommu mailing list [email protected] https://lists.linuxfoundation.org/mailman/listinfo/iommu