Skip to contentSkip to conversation

amd_iommu: IO_PAGE_FAULTs on unity mapped regions during amd_iommu_init()

PATCH New Shuah Khan 3 participants 5 messages Feb 7, 2013 – Feb 28, 2013 IOMMU

lore
Share & tools
lore

Shuah Khan

author
#0 lore raw

PATCH 1/1 amd_iommu: IO_PAGE_FAULTs on unity mapped regions during amd_iommu_init()

When dma_ops are initialized the unity mappings are created. The init_device_table_dma() function makes sure DMA from all devices is blocked by default. This opens a short window in time where DMA to unity mapped regions is blocked by the IOMMU. Make sure this does not happen by initializing the device table after dma_ops.

---
 drivers/iommu/amd_iommu_init.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/iommu/amd_iommu_init.c +7 -2
index ef0ae93..b573f80 100644
@@ -1572,8 +1572,6 @@ int __init amd_iommu_init_hardware(void)
 	if (amd_iommu_pd_alloc_bitmap == NULL)
 		goto free;
 
-	/* init the device table */
-	init_device_table();
 
 	/*
 	 * let all alias entries point to itself
@@ -1655,6 +1653,7 @@ out:
  */
 static int __init amd_iommu_init(void)
 {
+	struct amd_iommu *iommu;
 	int ret = 0;
 
 	ret = amd_iommu_init_hardware();
@@ -1673,6 +1672,12 @@ static int __init amd_iommu_init(void)
 	if (ret)
 		goto free;
 
+	/* init the device table */
+	init_device_table();
+
+	for_each_iommu(iommu)
+		iommu_flush_all_caches(iommu);
+
 	amd_iommu_init_api();
 
 	x86_platform.iommu_shutdown = disable_iommus;
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 iommu/amd: Initialize device table after dma_ops

When dma_ops are initialized the unity mappings are created. The init_device_table_dma() function makes sure DMA from all devices is blocked by default. This opens a short window in time where DMA to unity mapped regions is blocked by the IOMMU. Make sure this does not happen by initializing the device table after dma_ops.

Back-port upstream commit: f528d980c17b8714aedc918ba86e058af914d66b

---
 drivers/iommu/amd_iommu_init.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/iommu/amd_iommu_init.c +7 -2
index ef0ae93..b573f80 100644
@@ -1572,8 +1572,6 @@ int __init amd_iommu_init_hardware(void)
 	if (amd_iommu_pd_alloc_bitmap == NULL)
 		goto free;
 
-	/* init the device table */
-	init_device_table();
 
 	/*
 	 * let all alias entries point to itself
@@ -1655,6 +1653,7 @@ out:
  */
 static int __init amd_iommu_init(void)
 {
+	struct amd_iommu *iommu;
 	int ret = 0;
 
 	ret = amd_iommu_init_hardware();
@@ -1673,6 +1672,12 @@ static int __init amd_iommu_init(void)
 	if (ret)
 		goto free;
 
+	/* init the device table */
+	init_device_table();
+
+	for_each_iommu(iommu)
+		iommu_flush_all_caches(iommu);
+
 	amd_iommu_init_api();
 
 	x86_platform.iommu_shutdown = disable_iommus;
Signature · 1 line
1.7.9.5
author
#2 lore raw

Re: [PATCH 3.4] iommu/amd: Initialize device table after dma_ops

Quoted 11 lines · Shuah Khan

When dma_ops are initialized the unity mappings are created. The init_device_table_dma() function makes sure DMA from all devices is blocked by default. This opens a short window in time where DMA to unity mapped regions is blocked by the IOMMU. Make sure this does not happen by initializing the device table after dma_ops.

Back-port upstream commit: f528d980c17b8714aedc918ba86e058af914d66b

Please consider this for 3.5 as well.

-- Shuah

Quoted 38 lines
---
 drivers/iommu/amd_iommu_init.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/iommu/amd_iommu_init.c +7 -2
index ef0ae93..b573f80 100644
@@ -1572,8 +1572,6 @@ int __init amd_iommu_init_hardware(void)
 	if (amd_iommu_pd_alloc_bitmap == NULL)
 		goto free;
 
-	/* init the device table */
-	init_device_table();
 
 	/*
 	 * let all alias entries point to itself
@@ -1655,6 +1653,7 @@ out:
  */
 static int __init amd_iommu_init(void)
 {
+	struct amd_iommu *iommu;
 	int ret = 0;
 
 	ret = amd_iommu_init_hardware();
@@ -1673,6 +1672,12 @@ static int __init amd_iommu_init(void)
 	if (ret)
 		goto free;
 
+	/* init the device table */
+	init_device_table();
+
+	for_each_iommu(iommu)
+		iommu_flush_all_caches(iommu);
+
 	amd_iommu_init_api();
 
 	x86_platform.iommu_shutdown = disable_iommus;
author
#3 lore raw

Re: [PATCH 3.4] iommu/amd: Initialize device table after dma_ops

Quoted 9 lines · Shuah Khan
Quoted 8 lines · Shuah Khan

When dma_ops are initialized the unity mappings are created. The init_device_table_dma() function makes sure DMA from all devices is blocked by default. This opens a short window in time where DMA to unity mapped regions is blocked by the IOMMU. Make sure this does not happen by initializing the device table after dma_ops.

Back-port upstream commit: f528d980c17b8714aedc918ba86e058af914d66b

Quoted 7 lines
Quoted 3 lines

Please consider this for 3.5 as well.

-- Shuah

Please consider this for 3.5. Patch applies and fix works on 3.5.7. My previous reply to Herton Ronaldo Krzesinski bounced. Including Luis Henriques on this one.

-- Shuah

#4 lore raw

Re: [PATCH 3.4] iommu/amd: Initialize device table after dma_ops

In reply to Shuah Khan

Hi Shuah,

Quoted 7 lines · Shuah Khan
Quoted 6 lines · Shuah Khan

When dma_ops are initialized the unity mappings are created. The init_device_table_dma() function makes sure DMA from all devices is blocked by default. This opens a short window in time where DMA to unity mapped regions is blocked by the IOMMU. Make sure this does not happen by initializing the device table after dma_ops.

Quoted 7 lines
Quoted 5 lines

Back-port upstream commit: f528d980c17b8714aedc918ba86e058af914d66b

Please consider this for 3.5 as well.

Thank you, I will queue this for the 3.5 kernel.

Cheers,
--
Luis

Quoted 46 lines

-- Shuah

Quoted 28 lines
---
 drivers/iommu/amd_iommu_init.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/iommu/amd_iommu_init.c +1 -2
index ef0ae93..b573f80 100644
@@ -1572,8 +1572,6 @@ int __init amd_iommu_init_hardware(void)
 	if (amd_iommu_pd_alloc_bitmap == NULL)
 		goto free;
 
-	/* init the device table */
-	init_device_table();
 
 	/*
 	 * let all alias entries point to itself
@@ -1655,6 +1653,7 @@ out:
  */
 static int __init amd_iommu_init(void)
 {
+	struct amd_iommu *iommu;
 	int ret = 0;
 
 	ret = amd_iommu_init_hardware();
@@ -1673,6 +1672,12 @@ static int __init amd_iommu_init(void)
 	if (ret)
 		goto free;

drivers/iommu/amd_iommu_init.c static int __init amd_iommu_init(void) · line 1683

Quoted 10 lines
drivers/iommu/amd_iommu_init.c +6 -0
 
+	/* init the device table */
+	init_device_table();
+
+	for_each_iommu(iommu)
+		iommu_flush_all_caches(iommu);
+
 	amd_iommu_init_api();
 
 	x86_platform.iommu_shutdown = disable_iommus;

--
To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html