]> git.baikalelectronics.ru Git - kernel.git/commit
drm/i915: Avoid undefined behaviour of "u32 >> 32"
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 29 Jun 2017 15:04:25 +0000 (16:04 +0100)
committerJani Nikula <jani.nikula@intel.com>
Mon, 3 Jul 2017 13:12:48 +0000 (16:12 +0300)
commit3b8351d1501fc94dfe9e0a8cdff5d687adb918a6
tree854ea8aa70115e1d8b0c73f14e9417d1790d4220
parentf2a19030902191833939f35955a1c451e2dbc348
drm/i915: Avoid undefined behaviour of "u32 >> 32"

When computing a hash for looking up relocation target handles in an
execbuf, we start with a large size for the hashtable and proceed to
halve it until the allocation succeeds. The final attempt is with an
order of 0 (i.e. a single element). This means that we then pass bits=0
to hash_32() which then computes "hash >> (32 - 0)" to lookup the single
element. Right shifting a value by the width of the operand is
undefined, so limit the smallest hash table we use to order 1.

v2: Keep the retry allocation flag for the final pass

Fixes: cbd9e1045a31 ("drm/i915: Store a direct lookup from object handle to vma")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170629150425.27508-1-chris@chris-wilson.co.uk
(cherry picked from commit 4d470f7359c4bf22518baa30700ad45649371a22)
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
drivers/gpu/drm/i915/i915_gem_execbuffer.c