* [PATCH v2 1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set
@ 2019-01-29 16:12 Joonas Lahtinen
2019-01-29 16:12 ` [PATCH v2 2/2] drm/i915: Handle vm_mmap error " Joonas Lahtinen
` (3 more replies)
0 siblings, 4 replies; 6+ messages in thread
From: Joonas Lahtinen @ 2019-01-29 16:12 UTC (permalink / raw)
To: Intel graphics driver community testing & development
Make sure the underlying VMA in the process address space is the
same as it was during vm_mmap to avoid applying WC to wrong VMA.
A more long-term solution would be to have vm_mmap_locked variant
in linux/mmap.h for when caller wants to hold mmap_sem for an
extended duration.
v2:
- Refactor the compare function
Fixes: 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects")
Reported-by: Adam Zabrocki <adamza@microsoft.com>
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: <stable@vger.kernel.org> # v4.0+
Cc: Akash Goel <akash.goel@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Adam Zabrocki <adamza@microsoft.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> #v1
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> #v1
---
drivers/gpu/drm/i915/i915_gem.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 05627000b77d..7ca78c06b22c 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1681,6 +1681,16 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
return 0;
}
+static inline bool
+__vma_matches(struct vm_area_struct *vma, struct file *filp,
+ unsigned long addr, unsigned long size)
+{
+ if (vma->vm_file != filp)
+ return false;
+
+ return vma->vm_start == addr && (vma->vm_end - vma->vm_start) == size;
+}
+
/**
* i915_gem_mmap_ioctl - Maps the contents of an object, returning the address
* it is mapped to.
@@ -1739,7 +1749,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
return -EINTR;
}
vma = find_vma(mm, addr);
- if (vma)
+ if (vma && __vma_matches(vma, obj->base.filp, addr, args->size))
vma->vm_page_prot =
pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
else
--
2.17.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v2 2/2] drm/i915: Handle vm_mmap error during I915_GEM_MMAP ioctl with WC set
2019-01-29 16:12 [PATCH v2 1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set Joonas Lahtinen
@ 2019-01-29 16:12 ` Joonas Lahtinen
2019-01-29 16:19 ` Chris Wilson
2019-01-29 16:20 ` [PATCH v2 1/2] drm/i915: Prevent a race " Chris Wilson
` (2 subsequent siblings)
3 siblings, 1 reply; 6+ messages in thread
From: Joonas Lahtinen @ 2019-01-29 16:12 UTC (permalink / raw)
To: Intel graphics driver community testing & development
Add err goto label and use it when VMA can't be established or changes
underneath.
v2:
- Dropping Fixes: as it's indeed impossible to race an object to the
error address. (Chris)
Reported-by: Adam Zabrocki <adamza@microsoft.com>
Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Cc: Adam Zabrocki <adamza@microsoft.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
drivers/gpu/drm/i915/i915_gem.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 7ca78c06b22c..f2933a8a506d 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1740,6 +1740,9 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
addr = vm_mmap(obj->base.filp, 0, args->size,
PROT_READ | PROT_WRITE, MAP_SHARED,
args->offset);
+ if (IS_ERR((void *)addr))
+ goto err;
+
if (args->flags & I915_MMAP_WC) {
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma;
@@ -1755,17 +1758,22 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
else
addr = -ENOMEM;
up_write(&mm->mmap_sem);
+ if (IS_ERR((void *)addr))
+ goto err;
/* This may race, but that's ok, it only gets set */
WRITE_ONCE(obj->frontbuffer_ggtt_origin, ORIGIN_CPU);
}
i915_gem_object_put(obj);
- if (IS_ERR((void *)addr))
- return addr;
args->addr_ptr = (u64)addr;
return 0;
+
+err:
+ i915_gem_object_put(obj);
+
+ return addr;
}
static unsigned int tile_row_pages(const struct drm_i915_gem_object *obj)
--
2.17.2
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2 2/2] drm/i915: Handle vm_mmap error during I915_GEM_MMAP ioctl with WC set
2019-01-29 16:12 ` [PATCH v2 2/2] drm/i915: Handle vm_mmap error " Joonas Lahtinen
@ 2019-01-29 16:19 ` Chris Wilson
0 siblings, 0 replies; 6+ messages in thread
From: Chris Wilson @ 2019-01-29 16:19 UTC (permalink / raw)
To: Intel graphics driver community testing & development,
Joonas Lahtinen
Quoting Joonas Lahtinen (2019-01-29 16:12:37)
> Add err goto label and use it when VMA can't be established or changes
> underneath.
>
> v2:
> - Dropping Fixes: as it's indeed impossible to race an object to the
> error address. (Chris)
>
> Reported-by: Adam Zabrocki <adamza@microsoft.com>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Cc: Adam Zabrocki <adamza@microsoft.com>
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
> drivers/gpu/drm/i915/i915_gem.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 7ca78c06b22c..f2933a8a506d 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -1740,6 +1740,9 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
> addr = vm_mmap(obj->base.filp, 0, args->size,
> PROT_READ | PROT_WRITE, MAP_SHARED,
> args->offset);
> + if (IS_ERR((void *)addr))
if (IS_ERR_VALUE(addr))
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2 1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set
2019-01-29 16:12 [PATCH v2 1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set Joonas Lahtinen
2019-01-29 16:12 ` [PATCH v2 2/2] drm/i915: Handle vm_mmap error " Joonas Lahtinen
@ 2019-01-29 16:20 ` Chris Wilson
2019-01-29 17:19 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/2] " Patchwork
2019-01-29 20:13 ` ✓ Fi.CI.IGT: " Patchwork
3 siblings, 0 replies; 6+ messages in thread
From: Chris Wilson @ 2019-01-29 16:20 UTC (permalink / raw)
To: Intel graphics driver community testing & development,
Joonas Lahtinen
Quoting Joonas Lahtinen (2019-01-29 16:12:36)
> Make sure the underlying VMA in the process address space is the
> same as it was during vm_mmap to avoid applying WC to wrong VMA.
>
> A more long-term solution would be to have vm_mmap_locked variant
> in linux/mmap.h for when caller wants to hold mmap_sem for an
> extended duration.
>
> v2:
> - Refactor the compare function
>
> Fixes: 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects")
> Reported-by: Adam Zabrocki <adamza@microsoft.com>
> Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
> Signed-off-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: <stable@vger.kernel.org> # v4.0+
> Cc: Akash Goel <akash.goel@intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
> Cc: Adam Zabrocki <adamza@microsoft.com>
> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> #v1
> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> #v1
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* ✓ Fi.CI.BAT: success for series starting with [v2,1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set
2019-01-29 16:12 [PATCH v2 1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set Joonas Lahtinen
2019-01-29 16:12 ` [PATCH v2 2/2] drm/i915: Handle vm_mmap error " Joonas Lahtinen
2019-01-29 16:20 ` [PATCH v2 1/2] drm/i915: Prevent a race " Chris Wilson
@ 2019-01-29 17:19 ` Patchwork
2019-01-29 20:13 ` ✓ Fi.CI.IGT: " Patchwork
3 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2019-01-29 17:19 UTC (permalink / raw)
To: Joonas Lahtinen; +Cc: intel-gfx
== Series Details ==
Series: series starting with [v2,1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set
URL : https://patchwork.freedesktop.org/series/55919/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5501 -> Patchwork_12074
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/55919/revisions/1/mbox/
Known issues
------------
Here are the changes found in Patchwork_12074 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
- fi-byt-clapper: PASS -> FAIL [fdo#103191] / [fdo#107362] +1
#### Possible fixes ####
* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-b-frame-sequence:
- fi-byt-clapper: FAIL [fdo#103191] / [fdo#107362] -> PASS
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#108915]: https://bugs.freedesktop.org/show_bug.cgi?id=108915
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
Participating hosts (46 -> 41)
------------------------------
Additional (2): fi-icl-y fi-gdg-551
Missing (7): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_5501 -> Patchwork_12074
CI_DRM_5501: 5aac0b69f3a3085b9b8a9924cb19cb94f7860dbe @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4798: 998e0a4aedf10fb5f7c271018cd80d874668bf55 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12074: 80c1956210721a57e49cbfcae05082181d756d8d @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
80c195621072 drm/i915: Handle vm_mmap error during I915_GEM_MMAP ioctl with WC set
6de8da42fb84 drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12074/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
* ✓ Fi.CI.IGT: success for series starting with [v2,1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set
2019-01-29 16:12 [PATCH v2 1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set Joonas Lahtinen
` (2 preceding siblings ...)
2019-01-29 17:19 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/2] " Patchwork
@ 2019-01-29 20:13 ` Patchwork
3 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2019-01-29 20:13 UTC (permalink / raw)
To: Joonas Lahtinen; +Cc: intel-gfx
== Series Details ==
Series: series starting with [v2,1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set
URL : https://patchwork.freedesktop.org/series/55919/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_5501_full -> Patchwork_12074_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Known issues
------------
Here are the changes found in Patchwork_12074_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
- shard-snb: NOTRUN -> DMESG-WARN [fdo#107956]
* igt@kms_cursor_crc@cursor-128x128-dpms:
- shard-apl: PASS -> FAIL [fdo#103232] +1
* igt@kms_cursor_crc@cursor-64x21-onscreen:
- shard-glk: PASS -> FAIL [fdo#103232]
* igt@kms_flip@2x-flip-vs-expired-vblank:
- shard-glk: PASS -> FAIL [fdo#105363]
* igt@kms_flip@dpms-vs-vblank-race:
- shard-hsw: PASS -> INCOMPLETE [fdo#103540]
* igt@kms_plane_multiple@atomic-pipe-a-tiling-none:
- shard-glk: PASS -> FAIL [fdo#103166]
* igt@kms_plane_multiple@atomic-pipe-b-tiling-none:
- shard-apl: PASS -> FAIL [fdo#103166] +2
#### Possible fixes ####
* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-c:
- shard-apl: DMESG-WARN [fdo#107956] -> PASS
* igt@kms_cursor_crc@cursor-256x256-random:
- shard-glk: FAIL [fdo#103232] -> PASS +1
* igt@kms_cursor_crc@cursor-256x256-suspend:
- shard-apl: FAIL [fdo#103191] / [fdo#103232] -> PASS
* igt@kms_cursor_crc@cursor-256x85-random:
- shard-apl: FAIL [fdo#103232] -> PASS +2
* igt@kms_flip@flip-vs-expired-vblank:
- shard-glk: FAIL [fdo#102887] / [fdo#105363] -> PASS
* igt@kms_plane_alpha_blend@pipe-c-constant-alpha-max:
- shard-glk: FAIL [fdo#108145] -> PASS
* igt@kms_plane_multiple@atomic-pipe-b-tiling-x:
- shard-apl: FAIL [fdo#103166] -> PASS
* igt@kms_plane_multiple@atomic-pipe-c-tiling-y:
- shard-glk: FAIL [fdo#103166] -> PASS
* igt@prime_busy@hang-bsd:
- shard-hsw: FAIL [fdo#108807] -> PASS
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#102887]: https://bugs.freedesktop.org/show_bug.cgi?id=102887
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108807]: https://bugs.freedesktop.org/show_bug.cgi?id=108807
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
Participating hosts (7 -> 5)
------------------------------
Missing (2): shard-skl shard-iclb
Build changes
-------------
* Linux: CI_DRM_5501 -> Patchwork_12074
CI_DRM_5501: 5aac0b69f3a3085b9b8a9924cb19cb94f7860dbe @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4798: 998e0a4aedf10fb5f7c271018cd80d874668bf55 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_12074: 80c1956210721a57e49cbfcae05082181d756d8d @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_12074/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-01-29 20:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29 16:12 [PATCH v2 1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set Joonas Lahtinen
2019-01-29 16:12 ` [PATCH v2 2/2] drm/i915: Handle vm_mmap error " Joonas Lahtinen
2019-01-29 16:19 ` Chris Wilson
2019-01-29 16:20 ` [PATCH v2 1/2] drm/i915: Prevent a race " Chris Wilson
2019-01-29 17:19 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/2] " Patchwork
2019-01-29 20:13 ` ✓ Fi.CI.IGT: " Patchwork
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.