Skip to contentSkip to conversation

lib/intel_reg: fix shift undefined behaviour

PATCH In review Simon Ser 3 participants 4 messages Mar 21, 2019 – Apr 16, 2019 Library code

lore
Share & tools
lore

Simon Ser

author
#0 lore raw

PATCH 1/1 lib/intel_reg: fix shift undefined behaviour

1<<31 (same as 2<<30) is undefined behaviour in C. When compiling with GCC and UBSan, it gives this error:

../tools/intel_reg_decode.c: In function ‘ivb_debug_port’:
../tools/intel_reg_decode.c:398:3: error: case label does not reduce to an integer constant
case PORT_DBG_DRRS_HW_STATE_HIGH:
^~~~

This happens because 1<<31 isn't representable as a signed int. Instead, use am unsigned int.

---
 lib/intel_reg.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/intel_reg.h +1 -1
index f85fb742..069440cb 100644
@@ -3383,7 +3383,7 @@ typedef enum {
 #define PORT_DBG                    0x42308
 #define  PORT_DBG_DRRS_HW_STATE_OFF     (0<<30)
 #define  PORT_DBG_DRRS_HW_STATE_LOW     (1<<30)
-#define  PORT_DBG_DRRS_HW_STATE_HIGH    (2<<30)
+#define  PORT_DBG_DRRS_HW_STATE_HIGH    (2U<<30)
 
 /* RC6 residence counters
  */
Signature · 16 lines
2.21.0

---------------------------------------------------------------------
Intel Finland Oy
Registered Address: PL 281, 00181 Helsinki 
Business Identity Code: 0357606 - 4 
Domiciled in Helsinki 

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev
#1 lore raw

[igt-dev] ✓ Fi.CI.BAT: success for lib/intel_reg: fix shift undefined behaviour

== Series Details ==

== Series Details ==

Series: lib/intel_reg: fix shift undefined behaviour
URL : https://patchwork.freedesktop.org/series/58345/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5787 -> IGTPW_2680
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_basic@gtt-bsd:
- fi-bwr-2160: NOTRUN -> SKIP [fdo#109271] +103

* igt@i915_selftest@live_uncore:
- fi-ivb-3770: PASS -> DMESG-FAIL [fdo#110210]

* igt@kms_busy@basic-flip-a:
- fi-bsw-n3050: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +1

* igt@kms_busy@basic-flip-c:
- fi-bwr-2160: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]

* igt@kms_chamelium@hdmi-crc-fast:
- fi-bsw-n3050: NOTRUN -> SKIP [fdo#109271] +62

* igt@kms_force_connector_basic@force-load-detect:
- fi-bxt-j4205: NOTRUN -> SKIP [fdo#109271] +47

* igt@kms_pipe_crc_basic@nonblocking-crc-pipe-a-frame-sequence:
- fi-byt-clapper: PASS -> FAIL [fdo#103191] / [fdo#107362]

* igt@kms_psr@primary_mmap_gtt:
- fi-blb-e6850: NOTRUN -> SKIP [fdo#109271] +27

#### Possible fixes ####

* igt@gem_exec_suspend@basic-s3:
- fi-whl-u: FAIL [fdo#103375] -> PASS

* igt@kms_busy@basic-flip-a:
- fi-gdg-551: FAIL [fdo#103182] -> PASS

* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
- fi-blb-e6850: INCOMPLETE [fdo#107718] -> PASS

[fdo#103182]: https://bugs.freedesktop.org/show_bug.cgi?id=103182
[fdo#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
[fdo#107362]: https://bugs.freedesktop.org/show_bug.cgi?id=107362
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#110210]: https://bugs.freedesktop.org/show_bug.cgi?id=110210

Participating hosts (42 -> 37)
------------------------------

Additional (3): fi-bxt-j4205 fi-bwr-2160 fi-bsw-n3050
Missing (8): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-icl-u3 fi-bdw-samus

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

* IGT: IGT_4896 -> IGTPW_2680

CI_DRM_5787: 8a27af0b94f56d403bc7806a64a50013a2dd9396 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2680: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2680/
IGT_4896: 0f9c061247fb7aba21c9459f19f437927a28f32c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2680/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

#2 lore raw

[igt-dev] ✓ Fi.CI.IGT: success for lib/intel_reg: fix shift undefined behaviour

In reply to Simon Ser
== Series Details ==

== Series Details ==

Series: lib/intel_reg: fix shift undefined behaviour
URL : https://patchwork.freedesktop.org/series/58345/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_5787_full -> IGTPW_2680_full
====================================================

Summary
-------

**SUCCESS**

No regressions found.

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

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_exec_basic@basic-bsd1:
- shard-glk: NOTRUN -> SKIP [fdo#109271] +18

* igt@gem_wait@wait-bsd2:
- shard-snb: NOTRUN -> SKIP [fdo#109271] +33

* igt@i915_suspend@fence-restore-untiled:
- shard-kbl: PASS -> INCOMPLETE [fdo#103665] +1
- shard-snb: PASS -> INCOMPLETE [fdo#105411]

* igt@kms_atomic_transition@plane-all-modeset-transition-fencing:
- shard-apl: PASS -> INCOMPLETE [fdo#103927]

* igt@kms_busy@basic-flip-d:
- shard-glk: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]

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

* igt@kms_busy@extended-modeset-hang-newfb-render-b:
- shard-kbl: NOTRUN -> DMESG-WARN [fdo#107956]

* igt@kms_busy@extended-modeset-hang-newfb-with-reset-render-b:
- shard-kbl: PASS -> DMESG-WARN [fdo#107956] +1
- shard-hsw: PASS -> DMESG-WARN [fdo#107956]

* igt@kms_busy@extended-pageflip-hang-oldfb-render-e:
- shard-kbl: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +2

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

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

* igt@kms_frontbuffer_tracking@psr-2p-primscrn-spr-indfb-draw-pwrite:
- shard-kbl: NOTRUN -> SKIP [fdo#109271] +39

* igt@kms_plane@plane-panning-bottom-right-pipe-a-planes:
- shard-snb: PASS -> SKIP [fdo#109271] +2

* igt@kms_plane_alpha_blend@pipe-a-alpha-opaque-fb:
- shard-kbl: NOTRUN -> FAIL [fdo#108145]

* igt@kms_plane_alpha_blend@pipe-c-constant-alpha-max:

    - shard-glk:          PASS -> FAIL [fdo#108145]
    - shard-kbl:          PASS -> FAIL [fdo#108145]
    - shard-apl:          PASS -> FAIL [fdo#108145]

* igt@kms_plane_alpha_blend@pipe-c-constant-alpha-mid:
- shard-snb: NOTRUN -> SKIP [fdo#109271] / [fdo#109278] +3

* igt@kms_rotation_crc@multiplane-rotation-cropping-top:
- shard-kbl: NOTRUN -> FAIL [fdo#109016]

* igt@kms_universal_plane@disable-primary-vs-flip-pipe-d:
- shard-apl: NOTRUN -> SKIP [fdo#109271] / [fdo#109278]

* igt@kms_vblank@pipe-c-ts-continuation-modeset-rpm:
- shard-kbl: PASS -> FAIL [fdo#104894]
- shard-apl: PASS -> FAIL [fdo#104894]

* igt@prime_nv_test@i915_import_pread_pwrite:
- shard-apl: NOTRUN -> SKIP [fdo#109271]

* igt@tools_test@tools_test:
- shard-hsw: PASS -> SKIP [fdo#109271]

#### Possible fixes ####

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

* {igt@kms_plane@pixel-format-pipe-c-planes-source-clamping}:
- shard-glk: SKIP [fdo#109271] -> PASS +1

* igt@kms_plane_scaling@pipe-b-scaler-with-pixel-format:
- shard-glk: SKIP [fdo#109271] / [fdo#109278] -> PASS

* igt@kms_rotation_crc@multiplane-rotation:
- shard-kbl: INCOMPLETE [fdo#103665] -> PASS

* igt@kms_rotation_crc@multiplane-rotation-cropping-bottom:
- shard-kbl: DMESG-FAIL [fdo#105763] -> PASS

* igt@kms_vblank@pipe-a-ts-continuation-modeset-rpm:
- shard-apl: FAIL [fdo#104894] -> PASS

* igt@perf_pmu@rc6-runtime-pm-long:
- shard-apl: FAIL [fdo#105010] -> PASS
- shard-kbl: FAIL [fdo#105010] -> 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#103191]: https://bugs.freedesktop.org/show_bug.cgi?id=103191
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#104894]: https://bugs.freedesktop.org/show_bug.cgi?id=104894
[fdo#105010]: https://bugs.freedesktop.org/show_bug.cgi?id=105010
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
[fdo#105763]: https://bugs.freedesktop.org/show_bug.cgi?id=105763
[fdo#107956]: https://bugs.freedesktop.org/show_bug.cgi?id=107956
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#109016]: https://bugs.freedesktop.org/show_bug.cgi?id=109016
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278

Participating hosts (10 -> 5)
------------------------------

Missing (5): shard-skl pig-hsw-4770r pig-glk-j5005 shard-iclb pig-skl-6260u

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

* IGT: IGT_4896 -> IGTPW_2680
* Piglit: piglit_4509 -> None

CI_DRM_5787: 8a27af0b94f56d403bc7806a64a50013a2dd9396 @ git://anongit.freedesktop.org/gfx-ci/linux
IGTPW_2680: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2680/
IGT_4896: 0f9c061247fb7aba21c9459f19f437927a28f32c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/IGTPW_2680/
_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev

Reviewed-by on v1 1/1
#3 lore raw
In reply to Simon Ser
Quoted 6 lines · Simon Ser

1<<31 (same as 2<<30) is undefined behaviour in C. When compiling with GCC and UBSan, it gives this error:

../tools/intel_reg_decode.c: In function ‘ivb_debug_port’:
../tools/intel_reg_decode.c:398:3: error: case label does not reduce to an integer constant
case PORT_DBG_DRRS_HW_STATE_HIGH:

Quoted 6 lines
   ^~~~

This happens because 1<<31 isn't representable as a signed int. Instead, use am unsigned int.

With s,am,an, in commit message,

_______________________________________________
igt-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/igt-dev