Skip to content

Commit b5dc608

Browse files
committed
drm/i915: Copy the updated reloc->presumed_offset back to the user
If the userspace driver is using a constant relocation array with a static buffer, they will pass the same relocation array back to the kernel. So we *do* need to update the presumed offset value in those relocations to reflect the current object so that they remain correct with future batchbuffers and we avoid the necessity of having to suspend execution and perform redundant relocations. Fixes the regression introduced by 12f889c for applications using absolute addressing on trees of buffer (i.e. the current consumers of libdrm_intel.so). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=30996 Reported-by: Wang, Jinjin <jinjin.wang@intel.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
1 parent 69dc498 commit b5dc608

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎drivers/gpu/drm/i915/i915_gem.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3399,6 +3399,15 @@ i915_gem_execbuffer_relocate(struct drm_i915_gem_object *obj,
33993399
iowrite32(reloc.delta, reloc_entry);
34003400
io_mapping_unmap_atomic(reloc_page, KM_USER0);
34013401
}
3402+
3403+
/* and update the user's relocation entry */
3404+
reloc.presumed_offset = target_offset;
3405+
if (__copy_to_user_inatomic(&user_relocs[i].presumed_offset,
3406+
&reloc.presumed_offset,
3407+
sizeof(reloc.presumed_offset))) {
3408+
ret = -EFAULT;
3409+
break;
3410+
}
34023411
}
34033412

34043413
drm_gem_object_unreference(target_obj);
@@ -3560,6 +3569,10 @@ validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
35603569
if (!access_ok(VERIFY_READ, ptr, length))
35613570
return -EFAULT;
35623571

3572+
/* we may also need to update the presumed offsets */
3573+
if (!access_ok(VERIFY_WRITE, ptr, length))
3574+
return -EFAULT;
3575+
35633576
if (fault_in_pages_readable(ptr, length))
35643577
return -EFAULT;
35653578
}

0 commit comments

Comments
 (0)