]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915/userptr: fix size calculation
authorMatthew Auld <matthew.auld@intel.com>
Fri, 17 Jan 2020 13:24:13 +0000 (13:24 +0000)
committerJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Tue, 21 Jan 2020 07:03:00 +0000 (09:03 +0200)
commit6332100bbc89aa546890607ed5ac751a7d1ff559
tree3b7fb84d1a6beede9c69036141831b47216ffd06
parent4757a2a281f84eb4af36f8bf8f1e5ba3e4afffdf
drm/i915/userptr: fix size calculation

If we create a rather large userptr object(e.g 1ULL << 32) we might
shift past the type-width of num_pages: (int)num_pages << PAGE_SHIFT,
resulting in a totally bogus sg_table, which fortunately will eventually
manifest as:

gen8_ppgtt_insert_huge:463 GEM_BUG_ON(iter->sg->length < page_size)
kernel BUG at drivers/gpu/drm/i915/gt/gen8_ppgtt.c:463!

v2: more unsigned long
    prefer I915_GTT_PAGE_SIZE

Fixes: 1944115857b2 ("drm/i915: Introduce mapping of user pages into video memory (userptr) ioctl")
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20200117132413.1170563-2-matthew.auld@intel.com
(cherry picked from commit 8e78871bc1e5efec22c950d3fd24ddb63d4ff28a)
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
drivers/gpu/drm/i915/gem/i915_gem_userptr.c
drivers/gpu/drm/i915/i915_gem_gtt.c