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 <[email protected]>
Signed-off-by: Mike Travis <[email protected]>
Reviewed-by: Mike Habeck <[email protected]>
---
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;
}
--
On Thu, May 26, 2011 at 08:32:22PM -0500, Mike Travis wrote:
> 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 <[email protected]>
> Signed-off-by: Mike Travis <[email protected]>
> Reviewed-by: Mike Habeck <[email protected]>
> ---
> drivers/pci/intel-iommu.c | 15 +++++++++++++--
> 1 file changed, 13 insertions(+), 2 deletions(-)
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read Documentation/stable_kernel_rules.txt
for how to do this properly.
</formletter>
I'll not send this out for the other 6 patches that also do not follow
the proper format, as I'm sure you would get bored reading them.
* Greg KH <[email protected]> wrote:
> <formletter>
>
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree. Please read
> Documentation/stable_kernel_rules.txt for how to do this properly.
>
> </formletter>
>
> I'll not send this out for the other 6 patches that also do not
> follow the proper format, as I'm sure you would get bored reading
> them.
None of these patches exist upstream yet so it will take some time
until any of this can touch -stable. You can ignore it safely for
now.
Mike: please add proposed stable Cc: tags in the patch only, never
send it out to the stable email address itself!!
Thanks,
Ingo
On Fri, May 27, 2011 at 05:30:42AM -0400, Ingo Molnar wrote:
>
> * Greg KH <[email protected]> wrote:
>
> > <formletter>
> >
> > This is not the correct way to submit patches for inclusion in the
> > stable kernel tree. Please read
> > Documentation/stable_kernel_rules.txt for how to do this properly.
> >
> > </formletter>
> >
> > I'll not send this out for the other 6 patches that also do not
> > follow the proper format, as I'm sure you would get bored reading
> > them.
>
> None of these patches exist upstream yet so it will take some time
> until any of this can touch -stable. You can ignore it safely for
> now.
>
> Mike: please add proposed stable Cc: tags in the patch only, never
> send it out to the stable email address itself!!
Well, with the Cc: tag git-send-email will Cc it automatically if not
done by the user explicitly.
Joerg
--
AMD Operating System Research Center
Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo, Andrew Bowd
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632
On Fri, May 27, 2011 at 11:42:09AM +0200, Joerg Roedel wrote:
> On Fri, May 27, 2011 at 05:30:42AM -0400, Ingo Molnar wrote:
> >
> > * Greg KH <[email protected]> wrote:
> >
> > > <formletter>
> > >
> > > This is not the correct way to submit patches for inclusion in the
> > > stable kernel tree. Please read
> > > Documentation/stable_kernel_rules.txt for how to do this properly.
> > >
> > > </formletter>
> > >
> > > I'll not send this out for the other 6 patches that also do not
> > > follow the proper format, as I'm sure you would get bored reading
> > > them.
> >
> > None of these patches exist upstream yet so it will take some time
> > until any of this can touch -stable. You can ignore it safely for
> > now.
> >
> > Mike: please add proposed stable Cc: tags in the patch only, never
> > send it out to the stable email address itself!!
>
> Well, with the Cc: tag git-send-email will Cc it automatically if not
> done by the user explicitly.
And that's fine, I don't object to that at all, and it makes life easier
for me as I know it is coming eventually, and I try to watch out for it
in case the subsystem maintainer forgets to apply it.
It's when the Cc: in the signed-off-area is not there that my
form-letter kicks in to advise people that they are doing something
wrong and that their patch will not get applied to the stable tree this
way.
thanks,
greg k-h