Skip to contentSkip to conversation

drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set

PATCH Superseded Joonas Lahtinen 5 participants 11 messages Jan 7, 2019 – Feb 8, 2019

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Joonas Lahtinen

author maintainer
#0 lore raw

PATCH 1/2 drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set

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.

Fixes 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects")
Cc <[email protected]> # v4.0+
Cc Akash Goel <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Adam Zabrocki <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +10 -1
index 062c8395557c..f1d594a53978 100644
@@ -1680,6 +1680,15 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
 	return 0;
 }
 
+static inline bool
+match_gem_vma(struct vm_area_struct *vma, struct file *filp,
+	      unsigned long addr, unsigned long size)
+{
+	return vma && vma->vm_file == filp &&
+	       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.
@@ -1738,7 +1747,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
 			return -EINTR;
 		}
 		vma = find_vma(mm, addr);
-		if (vma)
+		if (match_gem_vma(vma, obj->base.filp, addr, args->size))
 			vma->vm_page_prot =
 				pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
 		else
Signature · 1 line
2.17.2
author maintainer
#1 lore raw

PATCH 2/2 drm/i915: Handle vm_mmap error during I915_GEM_MMAP ioctl with WC set

Add err goto label and use it when VMA can't be established or changes underneath.

Fixes 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects")
Cc <[email protected]> # v4.0+
Cc Akash Goel <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Adam Zabrocki <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +10 -2
index f1d594a53978..97cbc0e27e3e 100644
@@ -1738,6 +1738,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;
@@ -1753,17 +1756,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 = (uint64_t) addr;
 
 	return 0;
+
+err:
+	i915_gem_object_put(obj);
+
+	return addr;
 }
 
 static unsigned int tile_row_pages(const struct drm_i915_gem_object *obj)
Signature · 6 lines
2.17.2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [PATCH 2/2] drm/i915: Handle vm_mmap error during I915_GEM_MMAP ioctl with WC set

Quoting Joonas Lahtinen (2019-01-07 08:56:56)

Quoted 4 lines

Add err goto label and use it when VMA can't be established or changes underneath.

Fixes 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects")

Dubious. All it changes is one branch where the error is forced to -ENOMEM.

Quoted 26 lines
Cc <[email protected]> # v4.0+
Cc Akash Goel <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Adam Zabrocki <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +3 -0
index f1d594a53978..97cbc0e27e3e 100644
@@ -1738,6 +1738,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;

drivers/gpu/drm/i915/i915_gem.c i915_gem_mmap_ioctl(struct drm_device *dev, void *data, · line 1760

Quoted 5 lines
drivers/gpu/drm/i915/i915_gem.c +2 -0
@@ -1753,17 +1756,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;

The issue still remains that we are returning having called vm_mmap and leaving the vma intact. And we've established above that calling vm_munmap() is a race.
-Chris

Reviewed-by on v1 2/2
#3 lore raw

Re: [PATCH 2/2] drm/i915: Handle vm_mmap error during I915_GEM_MMAP ioctl with WC set

In reply to Joonas Lahtinen
Quoted 45 lines · Joonas Lahtinen

Add err goto label and use it when VMA can't be established or changes underneath.

Fixes 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects")
Cc <[email protected]> # v4.0+
Cc Akash Goel <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Adam Zabrocki <[email protected]>
---
  drivers/gpu/drm/i915/i915_gem.c | 12 ++++++++++--
  1 file changed, 10 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/i915_gem.c +5 -2
index f1d594a53978..97cbc0e27e3e 100644
@@ -1738,6 +1738,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;
@@ -1753,17 +1756,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 = (uint64_t) addr;

drivers/gpu/drm/i915/i915_gem.c i915_gem_mmap_ioctl(struct drm_device *dev, void *data, · line 1777

Quoted 10 lines
drivers/gpu/drm/i915/i915_gem.c +5 -0
 
  	return 0;
+
+err:
+	i915_gem_object_put(obj);
+
+	return addr;
  }
 
  static unsigned int tile_row_pages(const struct drm_i915_gem_object *obj)

Regards,

Tvrtko

Reviewed-by on v1 1/2
#4 lore raw
In reply to Joonas Lahtinen

Quoting Joonas Lahtinen (2019-01-07 08:56:55)

Quoted 25 lines

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.

Fixes 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects")
Cc <[email protected]> # v4.0+
Cc Akash Goel <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Adam Zabrocki <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +0 -0
index 062c8395557c..f1d594a53978 100644

drivers/gpu/drm/i915/i915_gem.c i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data, · line 1685

Quoted 6 lines
drivers/gpu/drm/i915/i915_gem.c +3 -0
@@ -1680,6 +1680,15 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
        return 0;
 }
 
+static inline bool
+match_gem_vma(struct vm_area_struct *vma, struct file *filp,
+             unsigned long addr, unsigned long size)

With the exception of there isn't anything gem specific here,

drivers/gpu/drm/i915/i915_gem.c i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data, · line 1689

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.c +4 -0
+{
+       return vma && vma->vm_file == filp &&
+              vma->vm_start == addr &&
+              (vma->vm_end - vma->vm_start) == size;

and we can break this up into separate ifs with a forgiving compiler,

I still couldn't see an easy way of passing pgprot bits into do_mmap to avoid the race entirely.
-Chris

Reviewed-by on v1 1/2
#5 lore raw
In reply to Joonas Lahtinen
Quoted 42 lines · Joonas Lahtinen

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.

Fixes 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects")
Cc <[email protected]> # v4.0+
Cc Akash Goel <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Adam Zabrocki <[email protected]>
---
  drivers/gpu/drm/i915/i915_gem.c | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +9 -0
index 062c8395557c..f1d594a53978 100644
@@ -1680,6 +1680,15 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
  	return 0;
  }
 
+static inline bool
+match_gem_vma(struct vm_area_struct *vma, struct file *filp,
+	      unsigned long addr, unsigned long size)
+{
+	return vma && vma->vm_file == filp &&
+	       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.

drivers/gpu/drm/i915/i915_gem.c i915_gem_mmap_ioctl(struct drm_device *dev, void *data, · line 1753

Quoted 8 lines
drivers/gpu/drm/i915/i915_gem.c +1 -1
@@ -1738,7 +1747,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
  			return -EINTR;
  		}
  		vma = find_vma(mm, addr);
-		if (vma)
+		if (match_gem_vma(vma, obj->base.filp, addr, args->size))
  			vma->vm_page_prot =
  				pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
  		else

Regards,

Tvrtko

#6 lore raw

✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set

In reply to Joonas Lahtinen
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set
URL : https://patchwork.freedesktop.org/series/54797/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5364 -> Patchwork_11198
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/54797/revisions/1/mbox/

Known issues
------------

Here are the changes found in Patchwork_11198 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@amdgpu/amd_basic@cs-compute:
- fi-kbl-8809g: NOTRUN -> FAIL [fdo#108094]

* igt@amdgpu/amd_prime@amd-to-i915:
- fi-kbl-8809g: NOTRUN -> FAIL [fdo#107341]

* igt@gem_exec_suspend@basic-s4-devices:
- fi-blb-e6850: PASS -> INCOMPLETE [fdo#107718]

* igt@i915_selftest@live_evict:
- fi-bsw-kefka: PASS -> DMESG-WARN [fdo#107709]

* igt@pm_rpm@module-reload:
- fi-icl-u2: PASS -> DMESG-WARN [fdo#108654]

#### Possible fixes ####

* igt@amdgpu/amd_basic@userptr:
- fi-kbl-8809g: DMESG-WARN [fdo#108965] -> PASS

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: FAIL [fdo#108767] -> PASS

* igt@kms_frontbuffer_tracking@basic:
- fi-byt-clapper: FAIL [fdo#103167] -> PASS

* igt@kms_pipe_crc_basic@hang-read-crc-pipe-a:
- 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#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#107341]: https://bugs.freedesktop.org/show_bug.cgi?id=107341
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#107709]: https://bugs.freedesktop.org/show_bug.cgi?id=107709
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#108094]: https://bugs.freedesktop.org/show_bug.cgi?id=108094
[fdo#108654]: https://bugs.freedesktop.org/show_bug.cgi?id=108654
[fdo#108767]: https://bugs.freedesktop.org/show_bug.cgi?id=108767
[fdo#108965]: https://bugs.freedesktop.org/show_bug.cgi?id=108965

Participating hosts (43 -> 39)
------------------------------

Additional (1): fi-kbl-7560u
Missing (5): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-glk-j4005

Build changes
-------------

* Linux: CI_DRM_5364 -> Patchwork_11198

CI_DRM_5364: 53364c9f70e33458fe848372778f8d0eba994f91 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4756: 75081c6bfb9998bd7cbf35a7ac0578c683fe55a8 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_11198: e6454c963d6c544b9395ffe92a8ac443f8e6080f @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

e6454c963d6c drm/i915: Handle vm_mmap error during I915_GEM_MMAP ioctl with WC set 877d1741097f 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_11198/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

✗ Fi.CI.IGT: failure for series starting with [1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set

In reply to Joonas Lahtinen
== Series Details ==

== Series Details ==

Series: series starting with [1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set
URL : https://patchwork.freedesktop.org/series/54797/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_5364_full -> Patchwork_11198_full
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_11198_full absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_11198_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_11198_full:

### IGT changes ###

#### Possible regressions ####

* igt@gem_userptr_blits@readonly-unsync:
- shard-apl: PASS -> TIMEOUT

* igt@kms_draw_crc@draw-method-rgb565-mmap-wc-untiled:

    - shard-apl:          PASS -> FAIL
    - shard-glk:          PASS -> FAIL
    - shard-kbl:          PASS -> FAIL

#### Warnings ####

* igt@kms_ccs@pipe-a-bad-aux-stride:
- shard-apl: SKIP -> PASS

* igt@tools_test@tools_test:
- shard-glk: PASS -> SKIP

Known issues
------------

Here are the changes found in Patchwork_11198_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@kms_atomic_transition@1x-modeset-transitions:
- shard-skl: NOTRUN -> FAIL [fdo#107815] / [fdo#108470] +1

* igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-a:
- shard-skl: NOTRUN -> DMESG-WARN [fdo#107956]

* igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-c:
- shard-apl: NOTRUN -> DMESG-WARN [fdo#107956] +1

* igt@kms_busy@extended-pageflip-hang-newfb-render-c:
- shard-glk: PASS -> DMESG-WARN [fdo#107956]

* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-a:
- shard-iclb: NOTRUN -> DMESG-WARN [fdo#107956]

* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-c:
- shard-apl: PASS -> DMESG-WARN [fdo#107956]

* igt@kms_chv_cursor_fail@pipe-b-128x128-top-edge:
- shard-skl: NOTRUN -> FAIL [fdo#104671]

* igt@kms_cursor_crc@cursor-128x128-sliding:
- shard-iclb: NOTRUN -> FAIL [fdo#103232]

* igt@kms_cursor_crc@cursor-128x42-sliding:
- shard-apl: PASS -> FAIL [fdo#103232]
- shard-glk: PASS -> FAIL [fdo#103232]

* igt@kms_fbcon_fbt@psr:
- shard-iclb: NOTRUN -> FAIL [fdo#107882]

* igt@kms_flip@flip-vs-expired-vblank:
- shard-skl: NOTRUN -> FAIL [fdo#105363]

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-pri-shrfb-draw-mmap-gtt:
- shard-skl: NOTRUN -> FAIL [fdo#103167]

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-move:
- shard-iclb: PASS -> FAIL [fdo#103167] +4

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-spr-indfb-draw-pwrite:
- shard-glk: PASS -> FAIL [fdo#103167]

* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
- shard-skl: NOTRUN -> FAIL [fdo#103191] / [fdo#107362] +1

* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
- shard-iclb: PASS -> INCOMPLETE [fdo#107713]

* igt@kms_plane@pixel-format-pipe-c-planes-source-clamping:
- shard-skl: NOTRUN -> DMESG-WARN [fdo#106885]

* igt@kms_plane@plane-position-covered-pipe-b-planes:
- shard-glk: PASS -> FAIL [fdo#103166] +1

* igt@kms_plane_alpha_blend@pipe-a-alpha-7efc:
- shard-skl: NOTRUN -> FAIL [fdo#107815] / [fdo#108145] +2

* igt@kms_plane_alpha_blend@pipe-a-constant-alpha-max:
- shard-skl: NOTRUN -> FAIL [fdo#108145] +1

* igt@kms_plane_multiple@atomic-pipe-a-tiling-y:
- shard-iclb: PASS -> FAIL [fdo#103166] +1

* igt@kms_plane_multiple@atomic-pipe-b-tiling-yf:
- shard-skl: NOTRUN -> FAIL [fdo#103166] / [fdo#107815]

* igt@kms_rotation_crc@multiplane-rotation-cropping-top:
- shard-iclb: PASS -> DMESG-WARN [fdo#107724]

* igt@kms_setmode@basic:
- shard-skl: NOTRUN -> FAIL [fdo#99912]
- shard-kbl: PASS -> FAIL [fdo#99912]

* igt@kms_vblank@pipe-c-ts-continuation-suspend:
- shard-skl: NOTRUN -> INCOMPLETE [fdo#104108] / [fdo#107773]

* igt@pm_rpm@legacy-planes:
- shard-iclb: PASS -> INCOMPLETE [fdo#108840]

* igt@pm_rps@min-max-config-loaded:
- shard-glk: PASS -> FAIL [fdo#102250]

#### Possible fixes ####

* igt@gem_exec_async@concurrent-writes-vebox:
- shard-skl: INCOMPLETE -> PASS

* igt@kms_atomic_transition@plane-all-transition-nonblocking-fencing:
- shard-apl: DMESG-WARN [fdo#103558] / [fdo#105602] / [fdo#109225] -> PASS

* igt@kms_available_modes_crc@available_mode_test_crc:
- shard-apl: FAIL [fdo#106641] -> PASS

* igt@kms_busy@extended-pageflip-modeset-hang-oldfb-render-a:
- shard-glk: DMESG-WARN [fdo#107956] -> PASS

* igt@kms_color@pipe-c-ctm-max:
- shard-apl: FAIL [fdo#108147] -> PASS

* igt@kms_cursor_crc@cursor-256x256-sliding:
- shard-skl: FAIL [fdo#103232] -> PASS

* igt@kms_cursor_crc@cursor-256x256-suspend:
- shard-apl: FAIL [fdo#103191] / [fdo#103232] -> PASS

* igt@kms_cursor_crc@cursor-256x85-onscreen:
- shard-glk: FAIL [fdo#103232] -> PASS

* igt@kms_cursor_crc@cursor-256x85-random:
- shard-apl: FAIL [fdo#103232] -> PASS +5

* igt@kms_cursor_legacy@all-pipes-torture-bo:
- shard-hsw: DMESG-WARN [fdo#107122] -> PASS

* igt@kms_fbcon_fbt@fbc-suspend:
- shard-iclb: INCOMPLETE [fdo#107713] -> PASS +1

* igt@kms_flip@basic-flip-vs-dpms:
- shard-kbl: DMESG-WARN [fdo#103313] / [fdo#105345] -> PASS

* igt@kms_flip@flip-vs-dpms-off-vs-modeset:
- shard-apl: DMESG-WARN [fdo#103558] / [fdo#105602] -> PASS +44

* igt@kms_flip@flip-vs-expired-vblank-interruptible:
- shard-skl: FAIL [fdo#105363] -> PASS

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-spr-indfb-move:
- shard-apl: FAIL [fdo#103167] -> PASS

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-spr-indfb-onoff:
- shard-iclb: FAIL [fdo#103167] -> PASS +4

* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-c:
- shard-skl: FAIL [fdo#107362] -> PASS

* igt@kms_plane@plane-position-covered-pipe-b-planes:
- shard-iclb: FAIL [fdo#103166] -> PASS

* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: FAIL [fdo#107815] -> PASS

* igt@kms_plane_multiple@atomic-pipe-a-tiling-y:
- shard-glk: FAIL [fdo#103166] -> PASS +1

* igt@kms_plane_scaling@pipe-b-scaler-with-rotation:
- shard-iclb: DMESG-WARN [fdo#107724] -> PASS

* igt@perf_pmu@rc6-runtime-pm-long:
- shard-iclb: FAIL [fdo#105010] -> PASS
- shard-skl: FAIL [fdo#105010] -> PASS

* igt@pm_rpm@reg-read-ioctl:
- shard-iclb: INCOMPLETE [fdo#107713] / [fdo#108840] -> PASS

* igt@pm_rpm@system-suspend-execbuf:
- shard-apl: DMESG-WARN [fdo#108131] -> PASS

#### Warnings ####

* igt@i915_suspend@shrink:
- shard-skl: INCOMPLETE [fdo#106886] -> DMESG-WARN [fdo#107886] / [fdo#108784]

* igt@kms_cursor_crc@cursor-128x128-suspend:
- shard-glk: FAIL [fdo#103232] -> INCOMPLETE [fdo#103359] / [k.org#198133]

* igt@kms_plane_alpha_blend@pipe-b-constant-alpha-max:
- shard-apl: DMESG-FAIL [fdo#103558] / [fdo#105602] / [fdo#108145] -> FAIL [fdo#108145]

[fdo#102250]: https://bugs.freedesktop.org/show_bug.cgi?id=102250
[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103313]: https://bugs.freedesktop.org/show_bug.cgi?id=103313
[fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
[fdo#103558]: https://bugs.freedesktop.org/show_bug.cgi?id=103558
[fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
[fdo#104671]: https://bugs.freedesktop.org/show_bug.cgi?id=104671
[fdo#105010]: https://bugs.freedesktop.org/show_bug.cgi?id=105010
[fdo#105345]: https://bugs.freedesktop.org/show_bug.cgi?id=105345
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#106641]: https://bugs.freedesktop.org/show_bug.cgi?id=106641
[fdo#106885]: https://bugs.freedesktop.org/show_bug.cgi?id=106885
[fdo#106886]: https://bugs.freedesktop.org/show_bug.cgi?id=106886
[fdo#107122]: https://bugs.freedesktop.org/show_bug.cgi?id=107122
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#107773]: https://bugs.freedesktop.org/show_bug.cgi?id=107773
[fdo#107815]: https://bugs.freedesktop.org/show_bug.cgi?id=107815
[fdo#107882]: https://bugs.freedesktop.org/show_bug.cgi?id=107882
[fdo#107886]: https://bugs.freedesktop.org/show_bug.cgi?id=107886
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108131]: https://bugs.freedesktop.org/show_bug.cgi?id=108131
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108147]: https://bugs.freedesktop.org/show_bug.cgi?id=108147
[fdo#108470]: https://bugs.freedesktop.org/show_bug.cgi?id=108470
[fdo#108784]: https://bugs.freedesktop.org/show_bug.cgi?id=108784
[fdo#108840]: https://bugs.freedesktop.org/show_bug.cgi?id=108840
[fdo#109225]: https://bugs.freedesktop.org/show_bug.cgi?id=109225
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
[k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133

Participating hosts (7 -> 7)
------------------------------

No changes in participating hosts

Build changes
-------------

* Linux: CI_DRM_5364 -> Patchwork_11198

CI_DRM_5364: 53364c9f70e33458fe848372778f8d0eba994f91 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4756: 75081c6bfb9998bd7cbf35a7ac0578c683fe55a8 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_11198: e6454c963d6c544b9395ffe92a8ac443f8e6080f @ 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_11198/
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

Re: ✗ Fi.CI.IGT: failure for series starting with [1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set

Quoting Patchwork (2019-01-07 10:44:01)

Quoted 11 lines

### IGT changes ###

#### Possible regressions ####

* igt@gem_userptr_blits@readonly-unsync:
- shard-apl: PASS -> TIMEOUT

* igt@kms_draw_crc@draw-method-rgb565-mmap-wc-untiled:

    - shard-apl:          PASS -> FAIL
    - shard-glk:          PASS -> FAIL
    - shard-kbl:          PASS -> FAIL

igt_fb doesn't compute a page aligned size, and igt_draw ends up making a mmap request not rounding up to the page boundary. I wonder if that hasn't been causing a few flip-flips...
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

author maintainer
#9 lore raw
In reply to Joonas Lahtinen

Quoting Joonas Lahtinen (2019-01-07 10:56:55)

Quoted 6 lines

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.

These are now merged to drm-tip, and will head to 5.1 and then to stable kernels.

Thanks for the report and reviews!

Regards, Joonas

Quoted 45 lines
Fixes 1816f9236303 ("drm/i915: Support creation of unbound wc user mappings for objects")
Cc <[email protected]> # v4.0+
Cc Akash Goel <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Adam Zabrocki <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_gem.c +10 -1
index 062c8395557c..f1d594a53978 100644
@@ -1680,6 +1680,15 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
        return 0;
 }
 
+static inline bool
+match_gem_vma(struct vm_area_struct *vma, struct file *filp,
+             unsigned long addr, unsigned long size)
+{
+       return vma && vma->vm_file == filp &&
+              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.
@@ -1738,7 +1747,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
                        return -EINTR;
                }
                vma = find_vma(mm, addr);
-               if (vma)
+               if (match_gem_vma(vma, obj->base.filp, addr, args->size))
                        vma->vm_page_prot =
                                pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
                else
Signature · 1 line
2.17.2
#10 lore raw

Thanks for the patch for both issues!

Best regards,
Adam

-----Original Message-----
From: Joonas Lahtinen <[email protected]>
Sent: Thursday, February 7, 2019 5:39 AM
To: Intel graphics driver community testing & development <[email protected]>
Cc: [email protected]; Akash Goel <[email protected]>; Chris Wilson <[email protected]>; Tvrtko Ursulin <[email protected]>; Adam Zabrocki <[email protected]>
Subject: Re: [PATCH 1/2] drm/i915: Prevent a race during I915_GEM_MMAP ioctl with WC set

Quoting Joonas Lahtinen (2019-01-07 10:56:55)

Quoted 6 lines

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.

These are now merged to drm-tip, and will head to 5.1 and then to stable kernels.

Thanks for the report and reviews!

Regards, Joonas

Quoted 46 lines
Fixes 1816f9236303 ("drm/i915: Support creation of unbound wc user

mappings for objects")

---
 drivers/gpu/drm/i915/i915_gem.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/i915/i915_gem.c index 062c8395557c..f1d594a53978 100644

drivers/gpu/drm/i915/i915_gem.c +9 -2
@@ -1680,6 +1680,15 @@ i915_gem_sw_finish_ioctl(struct drm_device *dev, void *data,
        return 0;
 }
 
+static inline bool
+match_gem_vma(struct vm_area_struct *vma, struct file *filp,
+             unsigned long addr, unsigned long size) {
+       return vma && vma->vm_file == filp &&
+              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.
@@ -1738,7 +1747,7 @@ i915_gem_mmap_ioctl(struct drm_device *dev, void *data,
                        return -EINTR;
                }
                vma = find_vma(mm, addr);
-               if (vma)
+               if (match_gem_vma(vma, obj->base.filp, addr, 
+ args->size))
                        vma->vm_page_prot =
                                pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
                else
--

2.17.2