public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -stable] amd_iommu: attach device fails on the last pci device
@ 2012-10-12 16:29 Shuah Khan
  2012-10-12 17:28 ` Alex Williamson
  2012-10-12 18:38 ` Jonathan Nieder
  0 siblings, 2 replies; 6+ messages in thread
From: Shuah Khan @ 2012-10-12 16:29 UTC (permalink / raw)
  To: joerg.roedel, tglx, mingo, hpa, Greg KH
  Cc: iommu, stable, x86, LKML, shuahkhan

amd_iommu_attach_device() checks if device id is within the limits
of amd_iommu_last_bdf and instead checking if devid > amd_iommu_last_bdf,
it checks devid >= amd_iommu_last_bdf. As a result the last device attach
fails because amd_iommu_attach_device() returns an -EINVAL.

This bug is in linux-2.6.32 and an equivalent fix in linux-2.6.33 and has been
carried forward to later kernels and is in the upstream kernel. This equivalent
fix includes restructuring and consolidating device checks into a routine
check_device(). Instead of back-porting all of that work, spot-fixed the bug in
amd_iommu_attach_device() for linux-2.6.32.

Signed-off-by: Shuah Khan <shuah.khan@hp.com>
CC: <stable@vger.kernel.org> v2.6.32
---
 arch/x86/kernel/amd_iommu.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index 3a44b75..67de7d7 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -2288,7 +2288,7 @@ static int amd_iommu_attach_device(struct iommu_domain *dom,
 
 	devid = calc_devid(pdev->bus->number, pdev->devfn);
 
-	if (devid >= amd_iommu_last_bdf ||
+	if (devid > amd_iommu_last_bdf ||
 			devid != amd_iommu_alias_table[devid])
 		return -EINVAL;
 
-- 
1.7.9.5




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH -stable] amd_iommu: attach device fails on the last pci device
  2012-10-12 16:29 [PATCH -stable] amd_iommu: attach device fails on the last pci device Shuah Khan
@ 2012-10-12 17:28 ` Alex Williamson
  2012-10-12 18:38 ` Jonathan Nieder
  1 sibling, 0 replies; 6+ messages in thread
From: Alex Williamson @ 2012-10-12 17:28 UTC (permalink / raw)
  To: shuah.khan
  Cc: joerg.roedel, tglx, mingo, hpa, Greg KH, iommu, x86, LKML, stable,
	shuahkhan

On Fri, 2012-10-12 at 10:29 -0600, Shuah Khan wrote:
> amd_iommu_attach_device() checks if device id is within the limits
> of amd_iommu_last_bdf and instead checking if devid > amd_iommu_last_bdf,
> it checks devid >= amd_iommu_last_bdf. As a result the last device attach
> fails because amd_iommu_attach_device() returns an -EINVAL.
> 
> This bug is in linux-2.6.32 and an equivalent fix in linux-2.6.33 and has been
> carried forward to later kernels and is in the upstream kernel. This equivalent
> fix includes restructuring and consolidating device checks into a routine
> check_device(). Instead of back-porting all of that work, spot-fixed the bug in
> amd_iommu_attach_device() for linux-2.6.32.
> 
> Signed-off-by: Shuah Khan <shuah.khan@hp.com>
> CC: <stable@vger.kernel.org> v2.6.32
> ---
>  arch/x86/kernel/amd_iommu.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
> index 3a44b75..67de7d7 100644
> --- a/arch/x86/kernel/amd_iommu.c
> +++ b/arch/x86/kernel/amd_iommu.c
> @@ -2288,7 +2288,7 @@ static int amd_iommu_attach_device(struct iommu_domain *dom,
>  
>  	devid = calc_devid(pdev->bus->number, pdev->devfn);
>  
> -	if (devid >= amd_iommu_last_bdf ||
> +	if (devid > amd_iommu_last_bdf ||
>  			devid != amd_iommu_alias_table[devid])
>  		return -EINVAL;
>  

Looks correct to me, this case was clearly inconsistent with other users
of amd_iommu_last_bdf.

Reviewed-by: Alex Williamson <alex.williamson@redhat.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -stable] amd_iommu: attach device fails on the last pci device
  2012-10-12 16:29 [PATCH -stable] amd_iommu: attach device fails on the last pci device Shuah Khan
  2012-10-12 17:28 ` Alex Williamson
@ 2012-10-12 18:38 ` Jonathan Nieder
  2012-10-12 18:44   ` Shuah Khan
  1 sibling, 1 reply; 6+ messages in thread
From: Jonathan Nieder @ 2012-10-12 18:38 UTC (permalink / raw)
  To: Shuah Khan
  Cc: joerg.roedel, tglx, mingo, hpa, Greg KH, iommu, stable, x86, LKML,
	shuahkhan

Shuah Khan wrote:

> This bug is in linux-2.6.32 and an equivalent fix in linux-2.6.33 and has been
> carried forward to later kernels and is in the upstream kernel. This equivalent
> fix includes restructuring and consolidating device checks into a routine
> check_device(). Instead of back-porting all of that work, spot-fixed the bug in
> amd_iommu_attach_device() for linux-2.6.32.

To save Willy time: am I correct in guessing the upstream commit you
are referring to is 98fc5a693bbdda498a556654c70d1e31a186c988
(x86/amd-iommu: Use get_device_id and check_device where appropriate,
2009-11-24)?

Thanks,
Jonathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -stable] amd_iommu: attach device fails on the last pci device
  2012-10-12 18:38 ` Jonathan Nieder
@ 2012-10-12 18:44   ` Shuah Khan
  2012-10-12 19:35     ` Jonathan Nieder
  0 siblings, 1 reply; 6+ messages in thread
From: Shuah Khan @ 2012-10-12 18:44 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: joerg.roedel, tglx, mingo, hpa, Greg KH, iommu, stable, x86, LKML,
	shuahkhan

On Fri, 2012-10-12 at 11:38 -0700, Jonathan Nieder wrote:
> Shuah Khan wrote:
> 
> > This bug is in linux-2.6.32 and an equivalent fix in linux-2.6.33 and has been
> > carried forward to later kernels and is in the upstream kernel. This equivalent
> > fix includes restructuring and consolidating device checks into a routine
> > check_device(). Instead of back-porting all of that work, spot-fixed the bug in
> > amd_iommu_attach_device() for linux-2.6.32.
> 
> To save Willy time: am I correct in guessing the upstream commit you
> are referring to is 98fc5a693bbdda498a556654c70d1e31a186c988
> (x86/amd-iommu: Use get_device_id and check_device where appropriate,
> 2009-11-24)?

Yes that is one. I looked that up again and it has the change to
amd_iommu_attach_device() to use check_device() and removes the check 

-	if (devid >= amd_iommu_last_bdf ||
-			devid != amd_iommu_alias_table[devid])
-		return -EINVAL;
+	devid = get_device_id(dev);

Ref: http://www.spinics.net/lists/linux-tip-commits/msg06129.html


Thanks,
-- Shuah



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -stable] amd_iommu: attach device fails on the last pci device
  2012-10-12 18:44   ` Shuah Khan
@ 2012-10-12 19:35     ` Jonathan Nieder
  2012-10-23 15:07       ` Shuah Khan
  0 siblings, 1 reply; 6+ messages in thread
From: Jonathan Nieder @ 2012-10-12 19:35 UTC (permalink / raw)
  To: Shuah Khan
  Cc: joerg.roedel, tglx, mingo, hpa, Greg KH, iommu, stable, x86, LKML,
	shuahkhan

Shuah Khan wrote:
> On Fri, 2012-10-12 at 11:38 -0700, Jonathan Nieder wrote:

>> To save Willy time: am I correct in guessing the upstream commit you
>> are referring to is 98fc5a693bbdda498a556654c70d1e31a186c988
>> (x86/amd-iommu: Use get_device_id and check_device where appropriate,
>> 2009-11-24)?
>
> Yes that is one.

Great, thanks for the quick confirmation.

Ciao,
Jonathan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH -stable] amd_iommu: attach device fails on the last pci device
  2012-10-12 19:35     ` Jonathan Nieder
@ 2012-10-23 15:07       ` Shuah Khan
  0 siblings, 0 replies; 6+ messages in thread
From: Shuah Khan @ 2012-10-23 15:07 UTC (permalink / raw)
  To: Jonathan Nieder
  Cc: joerg.roedel, tglx, mingo, hpa, Greg KH, iommu, stable, x86, LKML,
	shuahkhan

On Fri, 2012-10-12 at 12:35 -0700, Jonathan Nieder wrote:
> Shuah Khan wrote:
> > On Fri, 2012-10-12 at 11:38 -0700, Jonathan Nieder wrote:
> 
> >> To save Willy time: am I correct in guessing the upstream commit you
> >> are referring to is 98fc5a693bbdda498a556654c70d1e31a186c988
> >> (x86/amd-iommu: Use get_device_id and check_device where appropriate,
> >> 2009-11-24)?
> >
> > Yes that is one.
> 
> Great, thanks for the quick confirmation.

Is this patch in the queue to be pulled into 2.6.32 tree?

Thanks,
-- Shuah


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-10-23 15:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-12 16:29 [PATCH -stable] amd_iommu: attach device fails on the last pci device Shuah Khan
2012-10-12 17:28 ` Alex Williamson
2012-10-12 18:38 ` Jonathan Nieder
2012-10-12 18:44   ` Shuah Khan
2012-10-12 19:35     ` Jonathan Nieder
2012-10-23 15:07       ` Shuah Khan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox