drm/i915: Avoid overflow in computing pot_hole loop termination
authorChris Wilson <[email protected]>
Tue, 14 Feb 2017 09:23:44 +0000 (09:23 +0000)
committerChris Wilson <[email protected]>
Tue, 14 Feb 2017 22:30:20 +0000 (22:30 +0000)
When using the mock_ppgtt selftest, the GTT is large enough to cause an
overflow in pot_hole() when adding 2 pages to the address. Avoid the
overflow by computing the final valid address and iterating up to that
address.

Signed-off-by: Chris Wilson <[email protected]>
Cc: Matthew Auld <[email protected]>
Link: http://patchwork.freedesktop.org/patch/msgid/[email protected]
Reviewed-by: Matthew Auld <[email protected]>
drivers/gpu/drm/i915/selftests/i915_gem_gtt.c

index 5af9339087b7c27a773864faa57ea5c25fdc609b..468f0992db39b071c66fde525436a4948e8a4027 100644 (file)
@@ -615,7 +615,7 @@ static int pot_hole(struct drm_i915_private *i915,
                u64 addr;
 
                for (addr = round_up(hole_start + I915_GTT_PAGE_SIZE, step) - I915_GTT_PAGE_SIZE;
-                    addr + vma->size <= hole_end;
+                    addr <= round_down(hole_end - 2*I915_GTT_PAGE_SIZE, step) - I915_GTT_PAGE_SIZE;
                     addr += step) {
                        err = i915_vma_pin(vma, 0, 0, addr | flags);
                        if (err) {