diff options
author | Chris Wright <chrisw@sous-sol.org> | 2011-05-28 14:15:02 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2011-06-01 07:47:34 -0400 |
commit | 8fcc5372fbac085199d84a880503ed67aba3fe49 (patch) | |
tree | aab84e5ac18fa8028efa49e2cc47a5b97d873916 /drivers/pci | |
parent | 9b4554b21ed07e8556405510638171f0c787742a (diff) |
intel-iommu: 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.
Signed-off-by: Mike Travis <travis@sgi.com>
Reviewed-by: Mike Habeck <habeck@sgi.com>
Cc: stable@kernel.org
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/intel-iommu.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index 4eaec2fa1369..dcf051d53b74 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c | |||
@@ -2316,8 +2316,19 @@ static int iommu_should_identity_map(struct pci_dev *pdev, int startup) | |||
2316 | * Assume that they will -- if they turn out not to be, then we can | 2316 | * Assume that they will -- if they turn out not to be, then we can |
2317 | * take them out of the 1:1 domain later. | 2317 | * take them out of the 1:1 domain later. |
2318 | */ | 2318 | */ |
2319 | if (!startup) | 2319 | if (!startup) { |
2320 | return pdev->dma_mask > DMA_BIT_MASK(32); | 2320 | /* |
2321 | * If the device's dma_mask is less than the system's memory | ||
2322 | * size then this is not a candidate for identity mapping. | ||
2323 | */ | ||
2324 | u64 dma_mask = pdev->dma_mask; | ||
2325 | |||
2326 | if (pdev->dev.coherent_dma_mask && | ||
2327 | pdev->dev.coherent_dma_mask < dma_mask) | ||
2328 | dma_mask = pdev->dev.coherent_dma_mask; | ||
2329 | |||
2330 | return dma_mask >= dma_get_required_mask(&pdev->dev); | ||
2331 | } | ||
2321 | 2332 | ||
2322 | return 1; | 2333 | return 1; |
2323 | } | 2334 | } |