diff mbox series

[2/5] drm/i915: Flag any possible writes for a GTT fault

Message ID 20180903083337.13134-2-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [1/5] drm/i915: Do a full device reset after being wedged | expand

Commit Message

Chris Wilson Sept. 3, 2018, 8:33 a.m. UTC
We do not explicitly mark the PTE for the user's GTT mmap as being
wrprotect, so we don't get a refault when we would need to change a
read-only mmapping into read-write. As such, we must presume that if the
vma has PROT_WRITE it may be written to, although this is supposed to be
indicated by set-domain there are cases (e.g. after swap) where
userspace may not be aware of the implicit domain change.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_gem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Joonas Lahtinen Sept. 3, 2018, 10:30 a.m. UTC | #1
Quoting Chris Wilson (2018-09-03 11:33:34)
> We do not explicitly mark the PTE for the user's GTT mmap as being
> wrprotect, so we don't get a refault when we would need to change a
> read-only mmapping into read-write. As such, we must presume that if the
> vma has PROT_WRITE it may be written to, although this is supposed to be
> indicated by set-domain there are cases (e.g. after swap) where
> userspace may not be aware of the implicit domain change.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 7b7bbfe59697..625e07c56fe2 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2018,7 +2018,7 @@  vm_fault_t i915_gem_fault(struct vm_fault *vmf)
 	struct drm_device *dev = obj->base.dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	struct i915_ggtt *ggtt = &dev_priv->ggtt;
-	bool write = !!(vmf->flags & FAULT_FLAG_WRITE);
+	bool write = area->vm_flags & VM_WRITE;
 	struct i915_vma *vma;
 	pgoff_t page_offset;
 	int ret;