Commit 6f1cc993 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm/i915: Avoid dereference past end of page array in gen8_ppgtt_insert_entries()

The bug from gen6_ppgtt_insert_entries() was replicated into
gen8_ppgtt_insert_entries(). This applies the fix for the OOPS from the
previous patch to the gen8 routine.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ben Widawsky <benjamin.widawsky@intel.com>
Reviewed-by: default avatarBen Widawsky <ben@bwidawsk.net>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent cc79714f
...@@ -297,22 +297,22 @@ static void gen8_ppgtt_insert_entries(struct i915_address_space *vm, ...@@ -297,22 +297,22 @@ static void gen8_ppgtt_insert_entries(struct i915_address_space *vm,
unsigned act_pte = first_entry % GEN8_PTES_PER_PAGE; unsigned act_pte = first_entry % GEN8_PTES_PER_PAGE;
struct sg_page_iter sg_iter; struct sg_page_iter sg_iter;
pt_vaddr = kmap_atomic(&ppgtt->gen8_pt_pages[act_pt]); pt_vaddr = NULL;
for_each_sg_page(pages->sgl, &sg_iter, pages->nents, 0) { for_each_sg_page(pages->sgl, &sg_iter, pages->nents, 0) {
dma_addr_t page_addr; if (pt_vaddr == NULL)
pt_vaddr = kmap_atomic(&ppgtt->gen8_pt_pages[act_pt]);
page_addr = sg_dma_address(sg_iter.sg) + pt_vaddr[act_pte] =
(sg_iter.sg_pgoffset << PAGE_SHIFT); gen8_pte_encode(sg_page_iter_dma_address(&sg_iter),
pt_vaddr[act_pte] = gen8_pte_encode(page_addr, cache_level, cache_level, true);
true);
if (++act_pte == GEN8_PTES_PER_PAGE) { if (++act_pte == GEN8_PTES_PER_PAGE) {
kunmap_atomic(pt_vaddr); kunmap_atomic(pt_vaddr);
pt_vaddr = NULL;
act_pt++; act_pt++;
pt_vaddr = kmap_atomic(&ppgtt->gen8_pt_pages[act_pt]);
act_pte = 0; act_pte = 0;
} }
} }
if (pt_vaddr)
kunmap_atomic(pt_vaddr); kunmap_atomic(pt_vaddr);
} }
......
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