All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/5] drm/i915: Force the slow path after a user-write error
Date: Mon,  3 Sep 2018 09:33:35 +0100	[thread overview]
Message-ID: <20180903083337.13134-3-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20180903083337.13134-1-chris@chris-wilson.co.uk>

If we fail to write the user relocation back when it is changed, force
ourselves to take the slow relocation path where we can handle faults in
the write path. There is still an element of dubiousness as having
patched up the batch to use the correct offset, it no longer matches the
presumed_offset in the relocation, so a second pass may miss any changes
in layout.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem_execbuffer.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index a926d7d47183..931be2651f01 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -1486,8 +1486,10 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct i915_vma *vma)
 				 * can read from this userspace address.
 				 */
 				offset = gen8_canonical_addr(offset & ~UPDATE);
-				__put_user(offset,
-					   &urelocs[r-stack].presumed_offset);
+				if (unlikely(__put_user(offset, &urelocs[r-stack].presumed_offset))) {
+					remain = -EFAULT;
+					goto out;
+				}
 			}
 		} while (r++, --count);
 		urelocs += ARRAY_SIZE(stack);
@@ -1572,7 +1574,6 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb)
 
 		relocs = kvmalloc_array(size, 1, GFP_KERNEL);
 		if (!relocs) {
-			kvfree(relocs);
 			err = -ENOMEM;
 			goto err;
 		}
@@ -1586,6 +1587,7 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb)
 			if (__copy_from_user((char *)relocs + copied,
 					     (char __user *)urelocs + copied,
 					     len)) {
+end_user:
 				kvfree(relocs);
 				err = -EFAULT;
 				goto err;
@@ -1609,7 +1611,6 @@ static int eb_copy_relocations(const struct i915_execbuffer *eb)
 			unsafe_put_user(-1,
 					&urelocs[copied].presumed_offset,
 					end_user);
-end_user:
 		user_access_end();
 
 		eb->exec[i].relocs_ptr = (uintptr_t)relocs;
-- 
2.19.0.rc1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2018-09-03  8:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-03  8:33 [PATCH 1/5] drm/i915: Do a full device reset after being wedged Chris Wilson
2018-09-03  8:33 ` [PATCH 2/5] drm/i915: Flag any possible writes for a GTT fault Chris Wilson
2018-09-03 10:30   ` Joonas Lahtinen
2018-09-03  8:33 ` Chris Wilson [this message]
2018-09-03 10:08   ` [PATCH 3/5] drm/i915: Force the slow path after a user-write error Joonas Lahtinen
2018-09-03  8:33 ` [PATCH 4/5] drm/i915: Early rejection of buffer allocations larger than RAM Chris Wilson
2018-09-03 10:10   ` Joonas Lahtinen
2018-09-03  8:33 ` [PATCH 5/5] drm/i915: Forcibly flush unwanted requests in drop-caches Chris Wilson
2018-09-03 10:24   ` Joonas Lahtinen
2018-09-03  8:42 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/5] drm/i915: Do a full device reset after being wedged Patchwork
2018-09-03  8:59 ` ✓ Fi.CI.BAT: success " Patchwork
2018-09-03  9:56 ` [PATCH 1/5] " Joonas Lahtinen
2018-09-03 10:29 ` ✓ Fi.CI.IGT: success for series starting with [1/5] " Patchwork
2018-09-03 11:05   ` Chris Wilson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180903083337.13134-3-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.