Commit 77dfa56c authored by David Woodhouse's avatar David Woodhouse

intel-iommu: Change address_level_offset() to pfn_level_offset()

We're shifting the inputs for now, but that'll change...
Signed-off-by: default avatarDavid Woodhouse <David.Woodhouse@intel.com>
parent dd4e8319
...@@ -671,9 +671,9 @@ static inline unsigned int level_to_offset_bits(int level) ...@@ -671,9 +671,9 @@ static inline unsigned int level_to_offset_bits(int level)
return (12 + (level - 1) * LEVEL_STRIDE); return (12 + (level - 1) * LEVEL_STRIDE);
} }
static inline int address_level_offset(u64 addr, int level) static inline int pfn_level_offset(unsigned long pfn, int level)
{ {
return ((addr >> level_to_offset_bits(level)) & LEVEL_MASK); return (pfn >> (level_to_offset_bits(level) - 12)) & LEVEL_MASK;
} }
static inline u64 level_mask(int level) static inline u64 level_mask(int level)
...@@ -708,7 +708,7 @@ static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr) ...@@ -708,7 +708,7 @@ static struct dma_pte * addr_to_dma_pte(struct dmar_domain *domain, u64 addr)
while (level > 0) { while (level > 0) {
void *tmp_page; void *tmp_page;
offset = address_level_offset(addr, level); offset = pfn_level_offset(addr >> VTD_PAGE_SHIFT, level);
pte = &parent[offset]; pte = &parent[offset];
if (level == 1) if (level == 1)
break; break;
...@@ -749,7 +749,7 @@ static struct dma_pte *dma_addr_level_pte(struct dmar_domain *domain, u64 addr, ...@@ -749,7 +749,7 @@ static struct dma_pte *dma_addr_level_pte(struct dmar_domain *domain, u64 addr,
parent = domain->pgd; parent = domain->pgd;
while (level <= total) { while (level <= total) {
offset = address_level_offset(addr, total); offset = pfn_level_offset(addr >> VTD_PAGE_SHIFT, total);
pte = &parent[offset]; pte = &parent[offset];
if (level == total) if (level == total)
return pte; return pte;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment