提交 66eae846 编写于 作者: D David Woodhouse

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

Signed-off-by: NDavid Woodhouse <David.Woodhouse@intel.com>
上级 a75f7cf9
...@@ -700,8 +700,7 @@ static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr) ...@@ -700,8 +700,7 @@ static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr)
unsigned long flags; unsigned long flags;
BUG_ON(!domain->pgd); BUG_ON(!domain->pgd);
BUG_ON(addr >> addr_width);
addr &= (((u64)1) << addr_width) - 1;
parent = domain->pgd; parent = domain->pgd;
spin_lock_irqsave(&domain->mapping_lock, flags); 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) ...@@ -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 addr_width = agaw_to_width(domain->agaw);
int npages; int npages;
start &= (((u64)1) << addr_width) - 1; BUG_ON(start >> addr_width);
end &= (((u64)1) << addr_width) - 1; BUG_ON((end-1) >> addr_width);
/* in case it's partial page */ /* in case it's partial page */
start &= PAGE_MASK; start &= PAGE_MASK;
end = PAGE_ALIGN(end); end = PAGE_ALIGN(end);
...@@ -807,8 +807,8 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain, ...@@ -807,8 +807,8 @@ static void dma_pte_free_pagetable(struct dmar_domain *domain,
int level; int level;
u64 tmp; u64 tmp;
start &= (((u64)1) << addr_width) - 1; BUG_ON(start >> addr_width);
end &= (((u64)1) << addr_width) - 1; BUG_ON(end >> addr_width);
/* we don't need lock here, nobody else touches the iova range */ /* we don't need lock here, nobody else touches the iova range */
level = 2; level = 2;
...@@ -1654,7 +1654,7 @@ domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova, ...@@ -1654,7 +1654,7 @@ domain_page_mapping(struct dmar_domain *domain, dma_addr_t iova,
int index; int index;
int addr_width = agaw_to_width(domain->agaw); 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) if ((prot & (DMA_PTE_READ|DMA_PTE_WRITE)) == 0)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册