Skip to content

Commit 6fc4e48

Browse files
committed
drm/i915: Compare user's 64b GTT offset even on 32b
Beware mixing unsigned long constants and 64b values, as on 32b the constant will be zero extended and discard the high 32b when used as a mask! Reported-by: Sergii Romantsov <sergii.romantsov@globallogic.com> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108282 Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Cc: stable@vger.kernel.org Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20181025091823.20571-2-chris@chris-wilson.co.uk
1 parent 9125963 commit 6fc4e48

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

drivers/gpu/drm/i915/gvt/gtt.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#define _GVT_GTT_H_
3636

3737
#define I915_GTT_PAGE_SHIFT 12
38-
#define I915_GTT_PAGE_MASK (~(I915_GTT_PAGE_SIZE - 1))
3938

4039
struct intel_vgpu_mm;
4140

drivers/gpu/drm/i915/i915_gem_execbuffer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ eb_validate_vma(struct i915_execbuffer *eb,
460460
* any non-page-aligned or non-canonical addresses.
461461
*/
462462
if (unlikely(entry->flags & EXEC_OBJECT_PINNED &&
463-
entry->offset != gen8_canonical_addr(entry->offset & PAGE_MASK)))
463+
entry->offset != gen8_canonical_addr(entry->offset & I915_GTT_PAGE_MASK)))
464464
return -EINVAL;
465465

466466
/* pad_to_size was once a reserved field, so sanitize it */

drivers/gpu/drm/i915/i915_gem_gtt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
#define I915_GTT_PAGE_SIZE I915_GTT_PAGE_SIZE_4K
5050
#define I915_GTT_MAX_PAGE_SIZE I915_GTT_PAGE_SIZE_2M
5151

52+
#define I915_GTT_PAGE_MASK -I915_GTT_PAGE_SIZE
53+
5254
#define I915_GTT_MIN_ALIGNMENT I915_GTT_PAGE_SIZE
5355

5456
#define I915_FENCE_REG_NONE -1

0 commit comments

Comments
 (0)