Sophie

Sophie

distrib > CentOS > 5 > x86_64 > by-pkgid > ea32411352494358b8d75a78402a4713 > files > 5283

kernel-2.6.18-238.19.1.el5.centos.plus.src.rpm

From: Bhavna Sarathy <bnagendr@redhat.com>
Date: Mon, 8 Jun 2009 15:37:12 -0400
Subject: [x86_64] amd iommu: fix an off-by-one error
Message-id: 20090608193816.7837.11346.sendpatchset@localhost.localdomain
O-Subject: [RHEL5.4 PATCH 1/5] [KVM] Fix an off-by-one error in AMD IOMMU driver
Bugzilla: 501571
RH-Acked-by: Don Dutile <ddutile@redhat.com>
RH-Acked-by: Rik van Riel <riel@redhat.com>
RH-Acked-by: Eduardo Habkost <ehabkost@redhat.com>
RH-Acked-by: Juan Quintela <quintela@redhat.com>

Resolves BZ 501571

The variable amd_iommu_last_bdf holds the maximum bdf of any device
controlled by an IOMMU, so the number of device entries needed is
amd_iommu_last_bdf+1.  The function tbl_size used amd_iommu_last_bdf
instead.  This would be a problem if the last device were a large
enough power of 2.

diff --git a/arch/x86_64/kernel/amd_iommu_init.c b/arch/x86_64/kernel/amd_iommu_init.c
index 4d60a29..d9c195e 100644
--- a/arch/x86_64/kernel/amd_iommu_init.c
+++ b/arch/x86_64/kernel/amd_iommu_init.c
@@ -173,7 +173,7 @@ static inline void update_last_devid(u16 devid)
 static inline unsigned long tbl_size(int entry_size)
 {
 	unsigned shift = PAGE_SHIFT +
-			 get_order(amd_iommu_last_bdf * entry_size);
+			 get_order(((int)amd_iommu_last_bdf+1) * entry_size);
 
 	return 1UL << shift;
 }