diff mbox

[2/2] drm/i915: Assert we do not overflow 4lvl page directories

Message ID 20170224201341.6249-2-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson Feb. 24, 2017, 8:13 p.m. UTC
Before looking up the page directory entry, check we are still within
bounds.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.william.auld@gmail.com>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Matthew Auld Feb. 25, 2017, 12:28 p.m. UTC | #1
On 24 February 2017 at 20:13, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> Before looking up the page directory entry, check we are still within
> bounds.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Matthew Auld <matthew.william.auld@gmail.com>
Reviewed-by: Matthew Auld <matthew.william.auld@gmail.com>
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem_gtt.c b/drivers/gpu/drm/i915/i915_gem_gtt.c
index d4ec05f58ce4..bafba9f25971 100644
--- a/drivers/gpu/drm/i915/i915_gem_gtt.c
+++ b/drivers/gpu/drm/i915/i915_gem_gtt.c
@@ -836,6 +836,7 @@  gen8_ppgtt_insert_pte_entries(struct i915_hw_ppgtt *ppgtt,
 	gen8_pte_t *vaddr;
 	bool ret;
 
+	GEM_BUG_ON(pdpe >= I915_PDPES_PER_PDP(vm));
 	pd = pdp->page_directory[pdpe];
 	vaddr = kmap_atomic_px(pd->page_table[pde]);
 	do {
@@ -860,8 +861,7 @@  gen8_ppgtt_insert_pte_entries(struct i915_hw_ppgtt *ppgtt,
 					break;
 				}
 
-				GEM_BUG_ON(!i915_vm_is_48bit(&ppgtt->base) &&
-					   pdpe >= GEN8_LEGACY_PDPES);
+				GEM_BUG_ON(pdpe >= I915_PDPES_PER_PDP(vm));
 				pd = pdp->page_directory[pdpe];
 				pde = 0;
 			}
@@ -910,7 +910,7 @@  static void gen8_ppgtt_insert_4lvl(struct i915_address_space *vm,
 
 	while (gen8_ppgtt_insert_pte_entries(ppgtt, pdps[pml4e++], &iter,
 					     start, cache_level))
-		;
+		GEM_BUG_ON(pml4e >= GEN8_PML4ES_PER_PML4);
 }
 
 static void gen8_free_page_tables(struct i915_address_space *vm,