lkml.org 
[lkml]   [2011]   [May]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
Subject[PATCH 1/7] Intel pci: Check for identity mapping candidate using system dma mask
	The identity mapping code appears to make the assumption that
if the devices dma_mask is greater than 32bits the device can
use identity mapping. But that is not true, take the case
where we have a 40bit device in a 44bit architecture. The
device can potentially receive a physical address that it
will truncate and cause incorrect addresses to be used.

Instead check to see if the device's dma_mask is large enough
to address the system's dma_mask.

From: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Mike Travis <travis@sgi.com>
Reviewed-by: Mike Habeck <habeck@sgi.com>
---
drivers/pci/intel-iommu.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)

--- linux.orig/drivers/pci/intel-iommu.c
+++ linux/drivers/pci/intel-iommu.c
@@ -2187,8 +2187,19 @@ static int iommu_should_identity_map(str
* Assume that they will -- if they turn out not to be, then we can
* take them out of the 1:1 domain later.
*/
- if (!startup)
- return pdev->dma_mask > DMA_BIT_MASK(32);
+ if (!startup) {
+ /*
+ * If the device's dma_mask is less than the system's memory
+ * size then this is not a candidate for identity mapping.
+ */
+ u64 dma_mask = pdev->dma_mask;
+
+ if (pdev->dev.coherent_dma_mask &&
+ pdev->dev.coherent_dma_mask < dma_mask)
+ dma_mask = pdev->dev.coherent_dma_mask;
+
+ return dma_mask >= dma_get_required_mask(&pdev->dev);
+ }

return 1;
}
--


\
 
 \ /
  Last update: 2011-05-27 03:35    [W:0.064 / U:8.796 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site