OSDN Git Service

drm/i915/userptr: fix size calculation
authorMatthew Auld <matthew.auld@intel.com>
Fri, 17 Jan 2020 13:24:13 +0000 (13:24 +0000)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 17 Jan 2020 19:14:03 +0000 (19:14 +0000)
commit8e78871bc1e5efec22c950d3fd24ddb63d4ff28a
treed1cabcbff3a357384a034d8fc730ba723343b41c
parent24860ad748688b1156472d734b88b5d8d32fa42a
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: 5cc9ed4b9a7a ("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
drivers/gpu/drm/i915/gem/i915_gem_userptr.c
drivers/gpu/drm/i915/gt/gen6_ppgtt.c
drivers/gpu/drm/i915/gt/gen8_ppgtt.c