Skip to contentSkip to conversation

powernv/iommu: disable IOMMU bypass with param iommu=nobypass

PATCH RESEND In review Thadeu Lima de Souza Cascardo 2 participants 4 messages Jan 21, 2015 – Jan 23, 2015

Subsystems (2)

v1 of 2 In review Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 powernv/iommu: disable IOMMU bypass with param iommu=nobypass

When IOMMU bypass is enabled, a PCI device can read and write memory that was not mapped by the driver without causing an EEH. That might cause memory corruption, for example.

When we disable bypass, DMA reads and writes to addresses not mapped by the IOMMU will cause an EEH, allowing us to debug such issues.

---
 Documentation/kernel-parameters.txt       |    2 ++
 arch/powerpc/platforms/powernv/pci-ioda.c |   24 +++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)
Documentation/kernel-parameters.txt +2 -0
index 4df73da..7dedfe5 100644
@@ -1493,6 +1493,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 		forcesac
 		soft
 		pt		[x86, IA-64]
+		nobypass	[PPC/POWERNV]
+			Disable IOMMU bypass, using IOMMU for PCI devices.
 
 
 	io7=		[HW] IO7 for Marvel based alpha systems
arch/powerpc/platforms/powernv/pci-ioda.c +23 -1
index fac88ed..f942a19 100644
@@ -75,6 +75,27 @@ static void pe_level_printk(const struct pnv_ioda_pe *pe, const char *level,
 #define pe_info(pe, fmt, ...)					\
 	pe_level_printk(pe, KERN_INFO, fmt, ##__VA_ARGS__)
 
+static bool pnv_iommu_bypass_disabled __read_mostly;
+
+static int __init iommu_setup(char *str)
+{
+	if (!str)
+		return -EINVAL;
+	while (*str) {
+		if (!strncmp(str, "nobypass", 8)) {
+			pnv_iommu_bypass_disabled = true;
+			pr_info("PowerNV: IOMMU bypass window disabled.\n");
+		}
+		str += strcspn(str, ",");
+		if (*str == ',')
+			str++;
+	}
+
+	return 0;
+}
+
+early_param("iommu", iommu_setup);
+
 /*
  * stdcix is only supposed to be used in hypervisor real mode as per
  * the architecture spec
@@ -1348,7 +1369,8 @@ static void pnv_pci_ioda2_setup_dma_pe(struct pnv_phb *phb,
 		pnv_ioda_setup_bus_dma(pe, pe->pbus, true);
 
 	/* Also create a bypass window */
-	pnv_pci_ioda2_setup_bypass_pe(phb, pe);
+	if (!pnv_iommu_bypass_disabled)
+		pnv_pci_ioda2_setup_bypass_pe(phb, pe);
 	return;
 fail:
 	if (pe->tce32_seg >= 0)
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 7 lines · Thadeu Lima de Souza Cascardo

When IOMMU bypass is enabled, a PCI device can read and write memory that was not mapped by the driver without causing an EEH. That might cause memory corruption, for example.

When we disable bypass, DMA reads and writes to addresses not mapped by the IOMMU will cause an EEH, allowing us to debug such issues.

Quoted 6 lines
---
 Documentation/kernel-parameters.txt       |    2 ++
 arch/powerpc/platforms/powernv/pci-ioda.c |   24 +++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

Is this unchanged since v2?

It's marked as under review in patchwork which means I'm looking at it:

http://patchwork.ozlabs.org/patch/402682/

Please check patchwork in future.

cheers

#2 lore raw
Quoted 8 lines · Michael Ellerman
Quoted 7 lines · Thadeu Lima de Souza Cascardo

When IOMMU bypass is enabled, a PCI device can read and write memory that was not mapped by the driver without causing an EEH. That might cause memory corruption, for example.

When we disable bypass, DMA reads and writes to addresses not mapped by the IOMMU will cause an EEH, allowing us to debug such issues.

Quoted 9 lines
Quoted 6 lines
---
 Documentation/kernel-parameters.txt       |    2 ++
 arch/powerpc/platforms/powernv/pci-ioda.c |   24 +++++++++++++++++++++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

Is this unchanged since v2?

Yes, it's unchanged, just rebased.

Cascardo.

Quoted 14 lines

It's marked as under review in patchwork which means I'm looking at it:

http://patchwork.ozlabs.org/patch/402682/

Please check patchwork in future.

cheers

_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://lists.ozlabs.org/listinfo/linuxppc-dev

#3 lore raw
In reply to Thadeu Lima de Souza Cascardo
Quoted 8 lines · Thadeu Lima de Souza Cascardo
arch/powerpc/platforms/powernv/pci-ioda.c +0 -0
index fac88ed..f942a19 100644
@@ -75,6 +75,27 @@ static void pe_level_printk(const struct pnv_ioda_pe *pe, const char *level,
 #define pe_info(pe, fmt, ...)					\
 	pe_level_printk(pe, KERN_INFO, fmt, ##__VA_ARGS__)
 

arch/powerpc/platforms/powernv/pci-ioda.c static void pe_level_printk(const struct pnv_ioda_pe *pe, const char *level, · line 87

Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +10 -0
+static bool pnv_iommu_bypass_disabled __read_mostly;
+
+static int __init iommu_setup(char *str)
+{
+	if (!str)
+		return -EINVAL;
+	while (*str) {
+		if (!strncmp(str, "nobypass", 8)) {
+			pnv_iommu_bypass_disabled = true;
+			pr_info("PowerNV: IOMMU bypass window disabled.\n");

I added a break here.

arch/powerpc/platforms/powernv/pci-ioda.c static void pe_level_printk(const struct pnv_ioda_pe *pe, const char *level, · line 97

Quoted 10 lines
arch/powerpc/platforms/powernv/pci-ioda.c +10 -0
+		}
+		str += strcspn(str, ",");
+		if (*str == ',')
+			str++;
+	}
+
+	return 0;
+}
+
+early_param("iommu", iommu_setup);

cheers