[PATCH 04/17] iommu/vt-d: Load old data structures only in kdump kernel

Joerg Roedel joro at 8bytes.org
Fri Jun 5 14:10:50 UTC 2015


From: Joerg Roedel <jroedel at suse.de>

If we are not in a kdump kernel anybody could have left the
iommu enabled. We have no reason at all to trust the data
the data structures in this case, so don't even try to
preserve anything.

Tested-by: Baoquan He <bhe at redhat.com>
Signed-off-by: Joerg Roedel <jroedel at suse.de>
---
 drivers/iommu/intel-iommu.c         | 14 ++++++++++++++
 drivers/iommu/intel_irq_remapping.c | 12 +++++++-----
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index 982b8c8..d66bec6 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -40,6 +40,7 @@
 #include <linux/pci-ats.h>
 #include <linux/memblock.h>
 #include <linux/dma-contiguous.h>
+#include <linux/crash_dump.h>
 #include <asm/irq_remapping.h>
 #include <asm/cacheflush.h>
 #include <asm/iommu.h>
@@ -2943,6 +2944,19 @@ static int __init init_dmars(void)
 			goto free_iommu;
 
 		iommu_check_pre_te_status(iommu);
+
+		/*
+		 * We don't even try to preserve anything when we are not in a
+		 * kdump kernel.
+		 */
+		if (!is_kdump_kernel() && iommu->pre_enabled_trans) {
+			iommu_disable_translation(iommu);
+			iommu->pre_enabled_trans = 0;
+			g_translation_pre_enabled = 0;
+			pr_warn("Translation was enabled for %s but we are not in kdump mode\n",
+					iommu->name);
+		}
+
 		if (iommu->pre_enabled_trans) {
 			pr_info("IOMMU Copying translate tables from panicked kernel\n");
 			ret = intel_iommu_load_translation_tables(iommu);
diff --git a/drivers/iommu/intel_irq_remapping.c b/drivers/iommu/intel_irq_remapping.c
index 46d80ad..c3f0686 100644
--- a/drivers/iommu/intel_irq_remapping.c
+++ b/drivers/iommu/intel_irq_remapping.c
@@ -8,6 +8,7 @@
 #include <linux/irq.h>
 #include <linux/intel-iommu.h>
 #include <linux/acpi.h>
+#include <linux/crash_dump.h>
 #include <asm/io_apic.h>
 #include <asm/smp.h>
 #include <asm/cpu.h>
@@ -666,11 +667,12 @@ static int __init intel_enable_irq_remapping(void)
 
 		iommu_check_pre_ir_status(iommu);
 
-		/*
-		 * Here we do not disable intr remapping,
-		 * if already enabled prior to OS handover.
-		 */
-		/* iommu_disable_irq_remapping(iommu); */
+		if (!is_kdump_kernel() && iommu->pre_enabled_ir) {
+			iommu_disable_irq_remapping(iommu);
+			iommu->pre_enabled_ir = 0;
+			pr_warn("IRQ remapping was enabled on %s but we are not in kdump mode\n",
+				iommu->name);
+		}
 
 		dmar_disable_qi(iommu);
 	}
-- 
1.9.1



More information about the iommu mailing list