intel-iommu: Don't just mask out too-big physical addresses; BUG() instead

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <git-commits-head@...>
Date: Friday, July 3, 2009 - 5:59 pm

Gitweb:     http://git.kernel.org/linus/66eae8469e4e4ba6f4ca7ef82103c78f6d645583
Commit:     66eae8469e4e4ba6f4ca7ef82103c78f6d645583
Parent:     a75f7cf94f01717c5103138319b96752ee2a2be9
Author:     David Woodhouse <David.Woodhouse@intel.com>
AuthorDate: Sat Jun 27 19:00:32 2009 +0100
Committer:  David Woodhouse <David.Woodhouse@intel.com>
CommitDate: Mon Jun 29 12:38:42 2009 +0100

    intel-iommu: Don't just mask out too-big physical addresses; BUG() instead
    
    Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
 drivers/pci/intel-iommu.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c
index 40eae20..ad367f5 100644
--- a/drivers/pci/intel-iommu.c
+++ b/drivers/pci/intel-iommu.c
@@ -700,8 +700,7 @@ static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr)
 	unsigned long flags;
 
 	BUG_ON(!domain->pgd);
-
-	addr &= (((u64)1) << addr_width) - 1;
+	BUG_ON(addr >> addr_width);
 	parent = domain->pgd;
 
 	spin_lock_irqsave(&domain->mapping_lock, flags);
@@ -783,8 +782,9 @@ static void dma_pte_clear_range(struct dmar_domain *domain, u64 start, u64 end)
 	int addr_width = agaw_to_width(domain->agaw);
 	int npages;
 
-	start &= (((u64)1) << addr_width) - 1;
-	end &= (((u64)1) << addr_width) - 1;
+	BUG_ON(start >> addr_width);
+	BUG_ON((end-1) >> addr_width);
+
 	/* in case it's partial page */
 	start &= PAGE_MASK;
 	end = PAGE_ALIGN(end);
@@ -807,8 +807,8 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain,
 	int level;
 	u64 tmp;
 
-	start &= (((u64)1) << addr_width) - 1;
-	end &= (((u64)1) << addr_width) - 1;
+	BUG_ON(start >> addr_width);
+	BUG_ON(end >> addr_width);
 
 	/* we don't need lock here, nobody else touches the iova range */
 	level = 2;
@@ -1654,7 +1654,7 @@ domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova,
 	int index;
 	int addr_width = agaw_to_width(domain->agaw);
 
-	hpa &= (((u64)1) << addr_width) - 1;
+	BUG_ON(hpa >> addr_width);
 
 	if ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0)
 		return -EINVAL;
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
intel-iommu: Don't just mask out too-big physical addresses;..., Linux Kernel Mailing List..., (Fri Jul 3, 5:59 pm)