drm/i915/gem: Explicitly return error value from eb_relocate helpers
Subsystems (2)
PATCH v2 1/1 drm/i915/gem: Explicitly return error value from eb_relocate helpers
Static analysis issue:
The current implementations of the eb_relocate_vma and eb_relocate_vma_slow functions cast the return value of eb_relocate_entry to a signed long in order to determine if an error has occurred. This is because the return value of eb_relocate_entry is a u64 offset value on a success and a negative error value on a failure.
It is improper to perform a cast like this, so just have eb_relocate_entry (and, by extension, its helper function relocate_entry) return the error value, storig the offset separately in a passed u64 pointer.
Interestingly, this value is only used for non-error-checking purposes in the eb_relocate_vma case. We can simplify the eb_relocate_vma_slow case by allowing the passed u64 pointer to be NULL because of this.
v2:
- Modify commit message (Karas)
- Reorder error and offset cases in eb_relocate_vma, as offset and error are now uncorrelated (jcavitt)
- Fix uninitialized read issue (jcavitt)
--- .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c +23 -23
@@ -1373,11 +1373,12 @@ static void clflush_write32(u32 *addr, u32 value, unsigned int flushes) } } -static u64 +static int relocate_entry (struct i915_vma *vma,const struct drm_i915_gem_relocation_entry *reloc,struct i915_execbuffer *eb, -const struct i915_vma *target) +const struct i915_vma *target, +u64 *pin_offset) {u64 target_addr =relocation_target (reloc, target);u64 offset = reloc->offset;
@@ -1402,13 +1403,16 @@ relocate_entry(struct i915_vma *vma, goto repeat; } -return target->node.start |UPDATE ; +if (pin_offset) + *pin_offset = target->node.start |UPDATE ; +return 0 ; } -static u64 +static int eb_relocate_entry (struct i915_execbuffer *eb,struct eb_vma *ev, -const struct drm_i915_gem_relocation_entry *reloc) +const struct drm_i915_gem_relocation_entry *reloc, +u64 *offset) {struct drm_i915_private *i915 = eb->i915;struct eb_vma *target;
@@ -1505,7 +1509,7 @@ eb_relocate_entry(struct i915_execbuffer *eb, ev->flags &= ~EXEC_OBJECT_ASYNC ;/* and update the user's relocation entry */ -return relocate_entry (ev->vma, reloc, eb, target->vma); +return relocate_entry (ev->vma, reloc, eb, target->vma, offset); }static int eb_relocate_vma (struct i915_execbuffer *eb,struct eb_vma *ev)
@@ -1516,6 +1520,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev)struct drm_i915_gem_relocation_entry __user *urelocs =u64_to_user_ptr (entry->relocs_ptr);unsigned long remain = entry->relocation_count; +int err =0 ;if (unlikely (remain >N_RELOC (INT_MAX )))return -EINVAL ;
@@ -1546,21 +1551,20 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev) copied =__copy_from_user_inatomic (r, urelocs, count *sizeof (r[0 ]));pagefault_enable ();if (unlikely (copied)) { - remain = -EFAULT ; + err = -EFAULT ; goto out; } remain -= count; do { - u64 offset = eb_relocate_entry(eb, ev, r); + u64 offset = 0; + + err = eb_relocate_entry(eb, ev, r, &offset); + if (err) + goto out; if (likely(offset == 0)) continue; - - if ((s64)offset < 0) { - remain = (int)offset; - goto out; - } /* * Note that reporting an error now * leaves everything in an inconsistent
@@ -1589,7 +1593,7 @@ static int eb_relocate_vma(struct i915_execbuffer *eb, struct eb_vma *ev) }while (remain); out:reloc_cache_reset (&eb->reloc_cache, eb); -return remain; +return err; } static int
@@ -1599,18 +1603,14 @@ eb_relocate_vma_slow(struct i915_execbuffer *eb, struct eb_vma *ev)struct drm_i915_gem_relocation_entry *relocs =u64_to_ptr (typeof (*relocs), entry->relocs_ptr);unsigned int i; -int err; +int err =0 ;for (i =0 ; i < entry->relocation_count; i++) { -u64 offset =eb_relocate_entry (eb, ev, &relocs[i]); - -if ((s64 )offset <0 ) { - err = (int )offset; - goto err; - } + err =eb_relocate_entry (eb, ev, &relocs[i],NULL ); +if (err) +break ; } - err =0 ; -err: +reloc_cache_reset (&eb->reloc_cache, eb);return err; }
Signature · 1 line
2.43.0
Patchwork
CI✗ i915.CI.BAT: failure for drm/i915/gem: Explicitly return error value from eb_relocate helpers (rev3)
== Series Details ==
== Series Details ==
Series: drm/i915/gem: Explicitly return error value from eb_relocate helpers (rev3)
URL : https://patchwork.freedesktop.org/series/161167/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_18022 -> Patchwork_161167v3
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_161167v3 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes
introduced in Patchwork_161167v3, please notify your bug team ([email protected]) to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/index.html
Participating hosts (43 -> 41)
------------------------------
Missing (2): bat-dg2-13 fi-snb-2520m
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_161167v3:
### IGT changes ###
#### Possible regressions ####
* igt@kms_pipe_crc_basic@hang-read-crc@pipe-b-dp-3:
- bat-arls-5: [PASS][1] -> [DMESG-WARN][2] +4 other tests dmesg-warn
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-arls-5/igt@kms_pipe_crc_basic@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-arls-5/igt@kms_pipe_crc_basic@[email protected]
Known issues
------------
Here are the changes found in Patchwork_161167v3 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_selftest@live@evict:
- bat-arls-5: [PASS][3] -> [DMESG-FAIL][4] ([i915#15738])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-arls-5/igt@i915_selftest@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-arls-5/igt@i915_selftest@[email protected]
* igt@i915_selftest@live@gem_contexts:
- bat-arls-5: [PASS][5] -> [INCOMPLETE][6] ([i915#15738]) +1 other test incomplete
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-arls-5/igt@i915_selftest@live@gem_contexts.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-arls-5/igt@i915_selftest@live@gem_contexts.html
* igt@i915_selftest@live@sanitycheck:
- bat-arls-5: [PASS][7] -> [DMESG-WARN][8] ([i915#15738]) +35 other tests dmesg-warn
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-arls-5/igt@i915_selftest@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-arls-5/igt@i915_selftest@[email protected]
#### Possible fixes ####
* igt@fbdev@eof:
- bat-jsl-5: [SKIP][9] ([i915#15755]) -> [PASS][10] +3 other tests pass
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-jsl-5/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-jsl-5/igt@[email protected]
* igt@fbdev@info:
- bat-jsl-5: [SKIP][11] ([i915#1849]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-jsl-5/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-jsl-5/igt@[email protected]
* igt@i915_selftest@live@workarounds:
- bat-arls-6: [DMESG-FAIL][13] ([i915#12061]) -> [PASS][14] +1 other test pass
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-arls-6/igt@i915_selftest@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-arls-6/igt@i915_selftest@[email protected]
* igt@kms_flip@basic-flip-vs-wf_vblank:
- bat-jsl-5: [SKIP][15] ([i915#15754]) -> [PASS][16] +3 other tests pass
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-jsl-5/igt@kms_flip@basic-flip-vs-wf_vblank.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-jsl-5/igt@kms_flip@basic-flip-vs-wf_vblank.html
* igt@kms_frontbuffer_tracking@basic:
- bat-jsl-5: [SKIP][17] ([i915#15756]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-jsl-5/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-jsl-5/igt@[email protected]
* igt@kms_pipe_crc_basic@nonblocking-crc:
- bat-jsl-5: [SKIP][19] ([i915#11190]) -> [PASS][20] +13 other tests pass
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-jsl-5/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-jsl-5/igt@[email protected]
* igt@prime_vgem@basic-fence-flip:
- bat-jsl-5: [SKIP][21] -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-jsl-5/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-jsl-5/igt@[email protected]
#### Warnings ####
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- bat-jsl-5: [SKIP][23] ([i915#11190]) -> [SKIP][24] ([i915#4103]) +1 other test skip
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-jsl-5/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-jsl-5/igt@[email protected]
* igt@kms_dsc@dsc-basic:
- bat-jsl-5: [SKIP][25] ([i915#11190]) -> [SKIP][26] ([i915#3555] / [i915#9886])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18022/bat-jsl-5/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/bat-jsl-5/igt@[email protected]
[i915#11190]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11190
[i915#12061]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12061
[i915#15738]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/15738
[i915#15754]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/15754
[i915#15755]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/15755
[i915#15756]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/15756
[i915#1849]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/1849
[i915#3555]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/3555
[i915#4103]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4103
[i915#9886]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9886
Build changes
-------------
* Linux: CI_DRM_18022 -> Patchwork_161167v3
CI-20190529: 20190529
CI_DRM_18022: 45a3045fc0dc46a893cb8bbe304afafd4120c904 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_8765: 8765
Patchwork_161167v3: 45a3045fc0dc46a893cb8bbe304afafd4120c904 @ git://anongit.freedesktop.org/gfx-ci/linux
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_161167v3/index.html