Skip to contentSkip to conversation

drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning

PATCH Superseded Ashutosh Dixit 4 participants 7 messages May 10, 2023 – May 12, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning

Loading i915 on UBSAN enabled kernels (CONFIG_UBSAN/CONFIG_UBSAN_BOOL) causes the following warning:

  UBSAN: invalid-load in drivers/gpu/drm/i915/gt/uc/intel_uc.c:558:2
  load of value 255 is not a valid value for type '_Bool'
  Call Trace:
   dump_stack_lvl+0x57/0x7d
   ubsan_epilogue+0x5/0x40
   __ubsan_handle_load_invalid_value.cold+0x43/0x48
   __uc_init_hw+0x76a/0x903 [i915]
   ...
   i915_driver_probe+0xfb1/0x1eb0 [i915]
   i915_pci_probe+0xbe/0x2d0 [i915]

The warning happens because during probe i915_hwmon is still not available which results in the output boolean variable *old remaining uninitialized. Silence the warning by initializing the variable to an arbitrary value.

---
 drivers/gpu/drm/i915/i915_hwmon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_hwmon.c +4 -1
index a3bdd9f68a458..685663861bc0b 100644
@@ -502,8 +502,11 @@ void i915_hwmon_power_max_disable(struct drm_i915_private *i915, bool *old)
 	struct i915_hwmon *hwmon = i915->hwmon;
 	u32 r;
 
-	if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit))
+	if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit)) {
+		/* Fix uninitialized bool variable warning */
+		*old = false;
 		return;
+	}
 
 	mutex_lock(&hwmon->hwmon_lock);
 
Signature · 1 line
2.38.0
#1 lore raw

[Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning

== Series Details ==

== Series Details ==

Series: drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning
URL : https://patchwork.freedesktop.org/series/117591/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_13131 -> Patchwork_117591v1
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/index.html

Participating hosts (40 -> 40)
------------------------------

Additional (1): bat-mtlp-6
Missing (1): fi-snb-2520m

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

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

### IGT changes ###

#### Issues hit ####

* igt@kms_pipe_crc_basic@nonblocking-crc@pipe-d-dp-1:
- bat-dg2-8: [PASS][1] -> [FAIL][2] ([i915#7932])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/bat-dg2-8/igt@kms_pipe_crc_basic@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/bat-dg2-8/igt@kms_pipe_crc_basic@[email protected]

#### Possible fixes ####

* igt@dmabuf@all-tests@dma_fence:
- fi-kbl-7567u: [DMESG-FAIL][3] -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/fi-kbl-7567u/igt@dmabuf@all-tests@dma_fence.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/fi-kbl-7567u/igt@dmabuf@all-tests@dma_fence.html

* igt@dmabuf@all-tests@sanitycheck:
- fi-kbl-7567u: [ABORT][5] -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/fi-kbl-7567u/igt@dmabuf@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/fi-kbl-7567u/igt@dmabuf@[email protected]

* igt@i915_hangman@error-state-basic:
- fi-kbl-soraka: [INCOMPLETE][7] -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/fi-kbl-soraka/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/fi-kbl-soraka/igt@[email protected]

* igt@i915_selftest@live@requests:
- {bat-mtlp-8}: [ABORT][9] ([i915#4983] / [i915#7920] / [i915#7953]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/bat-mtlp-8/igt@i915_selftest@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/bat-mtlp-8/igt@i915_selftest@[email protected]

#### Warnings ####

* igt@i915_selftest@live@reset:
- bat-rpls-1: [ABORT][11] ([i915#4983] / [i915#7461] / [i915#7953] / [i915#7981] / [i915#8347] / [i915#8384]) -> [ABORT][12] ([i915#4983] / [i915#7461] / [i915#7953] / [i915#8347] / [i915#8384])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/bat-rpls-1/igt@i915_selftest@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/bat-rpls-1/igt@i915_selftest@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#3546]: https://gitlab.freedesktop.org/drm/intel/issues/3546
[i915#3595]: https://gitlab.freedesktop.org/drm/intel/issues/3595
[i915#3637]: https://gitlab.freedesktop.org/drm/intel/issues/3637
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4342]: https://gitlab.freedesktop.org/drm/intel/issues/4342
[i915#4579]: https://gitlab.freedesktop.org/drm/intel/issues/4579
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
[i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274
[i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#6645]: https://gitlab.freedesktop.org/drm/intel/issues/6645
[i915#7456]: https://gitlab.freedesktop.org/drm/intel/issues/7456
[i915#7461]: https://gitlab.freedesktop.org/drm/intel/issues/7461
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#7920]: https://gitlab.freedesktop.org/drm/intel/issues/7920
[i915#7932]: https://gitlab.freedesktop.org/drm/intel/issues/7932
[i915#7953]: https://gitlab.freedesktop.org/drm/intel/issues/7953
[i915#7981]: https://gitlab.freedesktop.org/drm/intel/issues/7981
[i915#8347]: https://gitlab.freedesktop.org/drm/intel/issues/8347
[i915#8368]: https://gitlab.freedesktop.org/drm/intel/issues/8368
[i915#8384]: https://gitlab.freedesktop.org/drm/intel/issues/8384

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

* Linux: CI_DRM_13131 -> Patchwork_117591v1

CI-20190529: 20190529
CI_DRM_13131: 92b7f1c42fc99ff1bad5e18d6b1aaa585f134d47 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7285: d1cbf2bad9c2664ab8bd3bd0946510a52800912f @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_117591v1: 92b7f1c42fc99ff1bad5e18d6b1aaa585f134d47 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

6ff4700f83c0 drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/index.html

#2 lore raw

[Intel-gfx] ✗ Fi.CI.IGT: failure for drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning

In reply to Ashutosh Dixit
== Series Details ==

== Series Details ==

Series: drm/i915/hwmon: Silence UBSAN uninitialized bool variable warning
URL : https://patchwork.freedesktop.org/series/117591/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_13131_full -> Patchwork_117591v1_full
====================================================

Summary
-------

**FAILURE**

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

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

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

No changes in participating hosts

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

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

### IGT changes ###

#### Possible regressions ####

* igt@kms_flip@flip-vs-suspend@c-dp1:
- shard-apl: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-apl3/igt@kms_flip@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-apl6/igt@kms_flip@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_barrier_race@remote-request@rcs0:
- shard-apl: [PASS][3] -> [ABORT][4] ([i915#7461] / [i915#8211] / [i915#8234])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-apl1/igt@gem_barrier_race@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-apl1/igt@gem_barrier_race@[email protected]

* igt@gem_exec_fair@basic-pace-solo@rcs0:
- shard-glk: [PASS][5] -> [FAIL][6] ([i915#2842])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-glk1/igt@gem_exec_fair@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-glk8/igt@gem_exec_fair@[email protected]

* igt@gen9_exec_parse@allowed-single:
- shard-glk: [PASS][7] -> [ABORT][8] ([i915#5566])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-glk5/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-glk1/igt@[email protected]

* igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions:
- shard-glk: [PASS][9] -> [FAIL][10] ([i915#2346])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-glk6/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-glk6/igt@[email protected]

* igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size:
- shard-apl: [PASS][11] -> [FAIL][12] ([i915#2346])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-apl7/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-apl6/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html

* igt@kms_hdr@bpc-switch-dpms@pipe-a-dp-1:
- shard-apl: [PASS][13] -> [FAIL][14] ([i915#1188])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-apl7/igt@kms_hdr@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-apl2/igt@kms_hdr@[email protected]

* igt@perf@stress-open-close@0-rcs0:
- shard-apl: [PASS][15] -> [ABORT][16] ([i915#5213])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-apl1/igt@perf@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-apl4/igt@perf@[email protected]

#### Possible fixes ####

* igt@gem_exec_fair@basic-none-solo@rcs0:
- shard-apl: [FAIL][17] ([i915#2842]) -> [PASS][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-apl6/igt@gem_exec_fair@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-apl7/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-none@vecs0:
- {shard-rkl}: [FAIL][19] ([i915#2842]) -> [PASS][20] +2 similar issues
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-rkl-3/igt@gem_exec_fair@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-rkl-7/igt@gem_exec_fair@[email protected]

* igt@gem_exec_fair@basic-pace-share@rcs0:
- shard-glk: [FAIL][21] ([i915#2842]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-glk4/igt@gem_exec_fair@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-glk3/igt@gem_exec_fair@[email protected]

* igt@gem_exec_suspend@basic-s4-devices@smem:
- {shard-tglu}: [ABORT][23] ([i915#7953] / [i915#7975] / [i915#8213]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-tglu-10/igt@gem_exec_suspend@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-tglu-9/igt@gem_exec_suspend@[email protected]

* igt@i915_pm_lpsp@kms-lpsp@kms-lpsp-hdmi-a:
- {shard-rkl}: [SKIP][25] ([i915#1937]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-rkl-3/igt@i915_pm_lpsp@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-rkl-7/igt@i915_pm_lpsp@[email protected]

* igt@i915_pm_rc6_residency@rc6-idle@vecs0:
- {shard-dg1}: [FAIL][27] ([i915#3591]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-dg1-12/igt@i915_pm_rc6_residency@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-dg1-12/igt@i915_pm_rc6_residency@[email protected]

* igt@i915_pm_rpm@dpms-mode-unset-lpsp:
- {shard-rkl}: [SKIP][29] ([i915#1397]) -> [PASS][30] +2 similar issues
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-rkl-6/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-rkl-7/igt@[email protected]

* igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-hflip-async-flip:
- {shard-rkl}: [FAIL][31] ([i915#3743]) -> [PASS][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-rkl-7/igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-hflip-async-flip.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-rkl-1/igt@kms_big_fb@x-tiled-max-hw-stride-64bpp-rotate-180-hflip-async-flip.html

* igt@kms_flip@2x-flip-vs-expired-vblank-interruptible@ab-hdmi-a1-hdmi-a2:
- shard-glk: [FAIL][33] ([i915#79]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-glk8/igt@kms_flip@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-glk9/igt@kms_flip@[email protected]

* igt@perf_pmu@idle@rcs0:
- {shard-dg1}: [FAIL][35] ([i915#4349]) -> [PASS][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-dg1-17/igt@perf_pmu@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-dg1-16/igt@perf_pmu@[email protected]
- {shard-rkl}: [FAIL][37] ([i915#4349]) -> [PASS][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_13131/shard-rkl-6/igt@perf_pmu@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_117591v1/shard-rkl-3/igt@perf_pmu@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#109280]: https://bugs.freedesktop.org/show_bug.cgi?id=109280
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#111614]: https://bugs.freedesktop.org/show_bug.cgi?id=111614
[fdo#111615]: https://bugs.freedesktop.org/show_bug.cgi?id=111615
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1188]: https://gitlab.freedesktop.org/drm/intel/issues/1188
[i915#1397]: https://gitlab.freedesktop.org/drm/intel/issues/1397
[i915#1937]: https://gitlab.freedesktop.org/drm/intel/issues/1937
[i915#2346]: https://gitlab.freedesktop.org/drm/intel/issues/2346
[i915#2681]: https://gitlab.freedesktop.org/drm/intel/issues/2681
[i915#2842]: https://gitlab.freedesktop.org/drm/intel/issues/2842
[i915#315]: https://gitlab.freedesktop.org/drm/intel/issues/315
[i915#3591]: https://gitlab.freedesktop.org/drm/intel/issues/3591
[i915#3689]: https://gitlab.freedesktop.org/drm/intel/issues/3689
[i915#3743]: https://gitlab.freedesktop.org/drm/intel/issues/3743
[i915#3778]: https://gitlab.freedesktop.org/drm/intel/issues/3778
[i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
[i915#4349]: https://gitlab.freedesktop.org/drm/intel/issues/4349
[i915#4579]: https://gitlab.freedesktop.org/drm/intel/issues/4579
[i915#5176]: https://gitlab.freedesktop.org/drm/intel/issues/5176
[i915#5213]: https://gitlab.freedesktop.org/drm/intel/issues/5213
[i915#5235]: https://gitlab.freedesktop.org/drm/intel/issues/5235
[i915#5286]: https://gitlab.freedesktop.org/drm/intel/issues/5286
[i915#5354]: https://gitlab.freedesktop.org/drm/intel/issues/5354
[i915#5439]: https://gitlab.freedesktop.org/drm/intel/issues/5439
[i915#5493]: https://gitlab.freedesktop.org/drm/intel/issues/5493
[i915#5566]: https://gitlab.freedesktop.org/drm/intel/issues/5566
[i915#6245]: https://gitlab.freedesktop.org/drm/intel/issues/6245
[i915#7461]: https://gitlab.freedesktop.org/drm/intel/issues/7461
[i915#7742]: https://gitlab.freedesktop.org/drm/intel/issues/7742
[i915#7828]: https://gitlab.freedesktop.org/drm/intel/issues/7828
[i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
[i915#7953]: https://gitlab.freedesktop.org/drm/intel/issues/7953
[i915#7975]: https://gitlab.freedesktop.org/drm/intel/issues/7975
[i915#8011]: https://gitlab.freedesktop.org/drm/intel/issues/8011
[i915#8211]: https://gitlab.freedesktop.org/drm/intel/issues/8211
[i915#8213]: https://gitlab.freedesktop.org/drm/intel/issues/8213
[i915#8234]: https://gitlab.freedesktop.org/drm/intel/issues/8234
[i915#8420]: https://gitlab.freedesktop.org/drm/intel/issues/8420

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

* Linux: CI_DRM_13131 -> Patchwork_117591v1

CI-20190529: 20190529
CI_DRM_13131: 92b7f1c42fc99ff1bad5e18d6b1aaa585f134d47 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7285: d1cbf2bad9c2664ab8bd3bd0946510a52800912f @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_117591v1: 92b7f1c42fc99ff1bad5e18d6b1aaa585f134d47 @ 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_117591v1/index.html

#3 lore raw
In reply to Ashutosh Dixit
Quoted 15 lines · Ashutosh Dixit

Loading i915 on UBSAN enabled kernels (CONFIG_UBSAN/CONFIG_UBSAN_BOOL) causes the following warning:

  UBSAN: invalid-load in drivers/gpu/drm/i915/gt/uc/intel_uc.c:558:2
  load of value 255 is not a valid value for type '_Bool'
  Call Trace:
   dump_stack_lvl+0x57/0x7d
   ubsan_epilogue+0x5/0x40
   __ubsan_handle_load_invalid_value.cold+0x43/0x48
   __uc_init_hw+0x76a/0x903 [i915]
   ...
   i915_driver_probe+0xfb1/0x1eb0 [i915]
   i915_pci_probe+0xbe/0x2d0 [i915]
Quoted 3 lines

The warning happens because during probe i915_hwmon is still not available which results in the output boolean variable *old remaining uninitialized.

Note that the variable was uninitialized in this case but it was never used uninitialized (the variable was not needed when it was uninitialized). So there was no bug in the code. UBSAN warning is just complaining about the uninitialized variable being passed into a function (where it is not used).

Also the variable can be initialized in the caller (__uc_init_hw) too and it will fix this issue. However in __uc_init_hw the assumption is that the variable will be initialized in the callee (i915_hwmon_power_max_disable), so that is how I have done it in this patch.

I thought these clarifications will help with the review.

Thanks.
--
Ashutosh

Quoted 27 lines

Silence the warning by initializing the variable to an arbitrary value.

---
 drivers/gpu/drm/i915/i915_hwmon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_hwmon.c +4 -2
index a3bdd9f68a458..685663861bc0b 100644
@@ -502,8 +502,11 @@ void i915_hwmon_power_max_disable(struct drm_i915_private *i915, bool *old)
 	struct i915_hwmon *hwmon = i915->hwmon;
 	u32 r;
 
-	if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit))
+	if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit)) {
+		/* Fix uninitialized bool variable warning */
+		*old = false;
 		return;
+	}
 
 	mutex_lock(&hwmon->hwmon_lock);
 
--

2.38.0

Reviewed-by
#4 lore raw

Hi Ashutosh,

Quoted 25 lines · Ashutosh
Quoted 15 lines · Ashutosh Dixit

Loading i915 on UBSAN enabled kernels (CONFIG_UBSAN/CONFIG_UBSAN_BOOL) causes the following warning:

  UBSAN: invalid-load in drivers/gpu/drm/i915/gt/uc/intel_uc.c:558:2
  load of value 255 is not a valid value for type '_Bool'
  Call Trace:
   dump_stack_lvl+0x57/0x7d
   ubsan_epilogue+0x5/0x40
   __ubsan_handle_load_invalid_value.cold+0x43/0x48
   __uc_init_hw+0x76a/0x903 [i915]
   ...
   i915_driver_probe+0xfb1/0x1eb0 [i915]
   i915_pci_probe+0xbe/0x2d0 [i915]
Quoted 3 lines

The warning happens because during probe i915_hwmon is still not available which results in the output boolean variable *old remaining uninitialized.

Note that the variable was uninitialized in this case but it was never used uninitialized (the variable was not needed when it was uninitialized). So there was no bug in the code. UBSAN warning is just complaining about the uninitialized variable being passed into a function (where it is not used).

Quoted 6 lines

Also the variable can be initialized in the caller (__uc_init_hw) too and it will fix this issue. However in __uc_init_hw the assumption is that the variable will be initialized in the callee (i915_hwmon_power_max_disable), so that is how I have done it in this patch.

I thought these clarifications will help with the review.

I think we should not just consider what's now but also what can come later. The use of pl1en is not 100% future proof and therefore your patch, even though now is not fixing anything, might avoid wrong uses in the future.

I'm just wondering, though, why not initializing the variable at it's declaration. As you wish.

Andi

Quoted 31 lines

Thanks.
--
Ashutosh

Quoted 27 lines

Silence the warning by initializing the variable to an arbitrary value.

---
 drivers/gpu/drm/i915/i915_hwmon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_hwmon.c +4 -2
index a3bdd9f68a458..685663861bc0b 100644
@@ -502,8 +502,11 @@ void i915_hwmon_power_max_disable(struct drm_i915_private *i915, bool *old)
 	struct i915_hwmon *hwmon = i915->hwmon;
 	u32 r;
 
-	if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit))
+	if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit)) {
+		/* Fix uninitialized bool variable warning */
+		*old = false;
 		return;
+	}
 
 	mutex_lock(&hwmon->hwmon_lock);
 
--

2.38.0

#5 lore raw
Quoted 1 line · Andi Shyti

Hi Andi,

Quoted 34 lines · Ashutosh
Quoted 25 lines · Ashutosh Dixit
Quoted 15 lines

Loading i915 on UBSAN enabled kernels (CONFIG_UBSAN/CONFIG_UBSAN_BOOL) causes the following warning:

  UBSAN: invalid-load in drivers/gpu/drm/i915/gt/uc/intel_uc.c:558:2
  load of value 255 is not a valid value for type '_Bool'
  Call Trace:
   dump_stack_lvl+0x57/0x7d
   ubsan_epilogue+0x5/0x40
   __ubsan_handle_load_invalid_value.cold+0x43/0x48
   __uc_init_hw+0x76a/0x903 [i915]
   ...
   i915_driver_probe+0xfb1/0x1eb0 [i915]
   i915_pci_probe+0xbe/0x2d0 [i915]
Quoted 3 lines

The warning happens because during probe i915_hwmon is still not available which results in the output boolean variable *old remaining uninitialized.

Note that the variable was uninitialized in this case but it was never used uninitialized (the variable was not needed when it was uninitialized). So there was no bug in the code. UBSAN warning is just complaining about the uninitialized variable being passed into a function (where it is not used).

Quoted 6 lines

Also the variable can be initialized in the caller (__uc_init_hw) too and it will fix this issue. However in __uc_init_hw the assumption is that the variable will be initialized in the callee (i915_hwmon_power_max_disable), so that is how I have done it in this patch.

I thought these clarifications will help with the review.

Quoted 7 lines

I think we should not just consider what's now but also what can come later. The use of pl1en is not 100% future proof and therefore your patch, even though now is not fixing anything, might avoid wrong uses in the future.

I'm just wondering, though, why not initializing the variable at it's declaration. As you wish.

OK, in v2 I went ahead and did just that (initializing the variable at the declaration). I was splitting hair too much :/

Quoted 1 line

Thanks.
--
Ashutosh

Quoted 28 lines
Quoted 28 lines
Quoted 28 lines

Silence the warning by initializing the variable to an arbitrary value.

---
 drivers/gpu/drm/i915/i915_hwmon.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_hwmon.c +4 -2
index a3bdd9f68a458..685663861bc0b 100644
@@ -502,8 +502,11 @@ void i915_hwmon_power_max_disable(struct drm_i915_private *i915, bool *old)
 	struct i915_hwmon *hwmon = i915->hwmon;
 	u32 r;
 
-	if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit))
+	if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit)) {
+		/* Fix uninitialized bool variable warning */
+		*old = false;
 		return;
+	}
 
 	mutex_lock(&hwmon->hwmon_lock);
 
--

2.38.0

Reviewed-by on v1 1/1
#6 lore raw
In reply to Ashutosh Dixit
Quoted 14 lines · Ashutosh Dixit

Loading i915 on UBSAN enabled kernels (CONFIG_UBSAN/CONFIG_UBSAN_BOOL) causes the following warning:

   UBSAN: invalid-load in drivers/gpu/drm/i915/gt/uc/intel_uc.c:558:2
   load of value 255 is not a valid value for type '_Bool'
   Call Trace:
    dump_stack_lvl+0x57/0x7d
    ubsan_epilogue+0x5/0x40
    __ubsan_handle_load_invalid_value.cold+0x43/0x48
    __uc_init_hw+0x76a/0x903 [i915]
    ...
    i915_driver_probe+0xfb1/0x1eb0 [i915]
    i915_pci_probe+0xbe/0x2d0 [i915]
Quoted 6 lines

The warning happens because during probe i915_hwmon is still not available which results in the output boolean variable *old remaining uninitialized. Silence the warning by initializing the variable to an arbitrary value.

Regards
Andrzej

Quoted 21 lines
---
  drivers/gpu/drm/i915/i915_hwmon.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_hwmon.c +4 -1
index a3bdd9f68a458..685663861bc0b 100644
@@ -502,8 +502,11 @@ void i915_hwmon_power_max_disable(struct drm_i915_private *i915, bool *old)
  	struct i915_hwmon *hwmon = i915->hwmon;
  	u32 r;
 
-	if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit))
+	if (!hwmon || !i915_mmio_reg_valid(hwmon->rg.pkg_rapl_limit)) {
+		/* Fix uninitialized bool variable warning */
+		*old = false;
  		return;
+	}
 
  	mutex_lock(&hwmon->hwmon_lock);