* [PATCH] drm/i915/dp: fix shifting by a negative number of bits
@ 2018-09-12 14:31 Gustavo A. R. Silva
2018-09-12 15:24 ` ✓ Fi.CI.BAT: success for " Patchwork
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Gustavo A. R. Silva @ 2018-09-12 14:31 UTC (permalink / raw)
To: Paulo Zanoni, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
David Airlie
Cc: intel-gfx, dri-devel, linux-kernel, Gustavo A. R. Silva
Function intel_port_to_tc() returns PORT_TC_NONE on error, which is
a negative value -1. In case PORT_TC_NONE is returned, there is an
undefined behavior when shifting by a negative number of bits in
both DP_PHY_MODE_STATUS_NOT_SAFE and P_PHY_MODE_STATUS_COMPLETED
macros.
Fix this by adding sanity checks on intel_port_to_tc return value, before
using macros DP_PHY_MODE_STATUS_NOT_SAFE and P_PHY_MODE_STATUS_COMPLETED.
Addresses-Coverity-ID: 1473324 ("Bad bit shift operation")
Addresses-Coverity-ID: 1473325 ("Bad bit shift operation")
Fixes: 39d1e234e1e1 ("drm/i915/icl: implement the tc/legacy HPD {dis,}connect flows")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/gpu/drm/i915/intel_dp.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 436c22d..e34b7b1 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -4811,6 +4811,11 @@ static bool icl_tc_phy_connect(struct drm_i915_private *dev_priv,
dig_port->tc_type != TC_PORT_TYPEC)
return true;
+ if (tc_port < 0) {
+ DRM_DEBUG_KMS("Bad TC port %d\n", tc_port);
+ return false;
+ }
+
val = I915_READ(PORT_TX_DFLEXDPPMS);
if (!(val & DP_PHY_MODE_STATUS_COMPLETED(tc_port))) {
DRM_DEBUG_KMS("DP PHY for TC port %d not ready\n", tc_port);
@@ -4857,6 +4862,10 @@ static void icl_tc_phy_disconnect(struct drm_i915_private *dev_priv,
dig_port->tc_type != TC_PORT_TYPEC)
return;
+ if (tc_port < 0) {
+ DRM_DEBUG_KMS("Bad TC port %d\n", tc_port);
+ return;
+ }
/*
* This function may be called many times in a row without an HPD event
* in between, so try to avoid the write when we can.
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* ✓ Fi.CI.BAT: success for drm/i915/dp: fix shifting by a negative number of bits
2018-09-12 14:31 [PATCH] drm/i915/dp: fix shifting by a negative number of bits Gustavo A. R. Silva
@ 2018-09-12 15:24 ` Patchwork
2018-09-12 21:04 ` ✓ Fi.CI.IGT: " Patchwork
2018-09-12 22:02 ` Paulo Zanoni
2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2018-09-12 15:24 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: intel-gfx
== Series Details ==
Series: drm/i915/dp: fix shifting by a negative number of bits
URL : https://patchwork.freedesktop.org/series/49565/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4812 -> Patchwork_10156 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/49565/revisions/1/mbox/
== Known issues ==
Here are the changes found in Patchwork_10156 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@drv_selftest@live_guc:
fi-skl-guc: NOTRUN -> DMESG-WARN (fdo#107258)
igt@kms_pipe_crc_basic@read-crc-pipe-b:
fi-byt-clapper: PASS -> FAIL (fdo#107362) +1
igt@kms_psr@primary_page_flip:
fi-kbl-7560u: PASS -> FAIL (fdo#107336)
==== Possible fixes ====
igt@kms_frontbuffer_tracking@basic:
fi-byt-clapper: FAIL (fdo#103167) -> PASS
fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#107258 https://bugs.freedesktop.org/show_bug.cgi?id=107258
fdo#107336 https://bugs.freedesktop.org/show_bug.cgi?id=107336
fdo#107362 https://bugs.freedesktop.org/show_bug.cgi?id=107362
== Participating hosts (49 -> 44) ==
Additional (2): fi-byt-j1900 fi-skl-guc
Missing (7): fi-ilk-m540 fi-bxt-dsi fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-icl-u
== Build changes ==
* Linux: CI_DRM_4812 -> Patchwork_10156
CI_DRM_4812: 7bed140e1a21dc0e04f2fd87d2726f47b845e82f @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4640: 9a8da36e708f9ed15b20689dfe305e41f9a19008 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10156: bfad517ac799fbbfa711620c387d61e645ed8e67 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
bfad517ac799 drm/i915/dp: fix shifting by a negative number of bits
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_10156/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
* ✓ Fi.CI.IGT: success for drm/i915/dp: fix shifting by a negative number of bits
2018-09-12 14:31 [PATCH] drm/i915/dp: fix shifting by a negative number of bits Gustavo A. R. Silva
2018-09-12 15:24 ` ✓ Fi.CI.BAT: success for " Patchwork
@ 2018-09-12 21:04 ` Patchwork
2018-09-12 22:02 ` Paulo Zanoni
2 siblings, 0 replies; 5+ messages in thread
From: Patchwork @ 2018-09-12 21:04 UTC (permalink / raw)
To: Gustavo A. R. Silva; +Cc: intel-gfx
== Series Details ==
Series: drm/i915/dp: fix shifting by a negative number of bits
URL : https://patchwork.freedesktop.org/series/49565/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4812_full -> Patchwork_10156_full =
== Summary - SUCCESS ==
No regressions found.
== Known issues ==
Here are the changes found in Patchwork_10156_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@gem_userptr_blits@dmabuf-sync:
shard-snb: PASS -> INCOMPLETE (fdo#105411)
igt@kms_setmode@basic:
shard-apl: PASS -> FAIL (fdo#99912)
igt@perf@rc6-disable:
shard-kbl: PASS -> FAIL (fdo#103179)
==== Possible fixes ====
igt@kms_cursor_legacy@2x-long-cursor-vs-flip-atomic:
shard-hsw: FAIL (fdo#105767) -> PASS
igt@kms_cursor_legacy@cursor-vs-flip-toggle:
shard-hsw: FAIL (fdo#103355) -> PASS
igt@kms_flip@flip-vs-expired-vblank:
shard-glk: FAIL (fdo#105363) -> PASS
igt@kms_setmode@basic:
shard-kbl: FAIL (fdo#99912) -> PASS
fdo#103179 https://bugs.freedesktop.org/show_bug.cgi?id=103179
fdo#103355 https://bugs.freedesktop.org/show_bug.cgi?id=103355
fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
fdo#105411 https://bugs.freedesktop.org/show_bug.cgi?id=105411
fdo#105767 https://bugs.freedesktop.org/show_bug.cgi?id=105767
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
== Participating hosts (5 -> 5) ==
No changes in participating hosts
== Build changes ==
* Linux: CI_DRM_4812 -> Patchwork_10156
CI_DRM_4812: 7bed140e1a21dc0e04f2fd87d2726f47b845e82f @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4640: 9a8da36e708f9ed15b20689dfe305e41f9a19008 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_10156: bfad517ac799fbbfa711620c387d61e645ed8e67 @ 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_10156/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915/dp: fix shifting by a negative number of bits
2018-09-12 14:31 [PATCH] drm/i915/dp: fix shifting by a negative number of bits Gustavo A. R. Silva
@ 2018-09-12 22:02 ` Paulo Zanoni
2018-09-12 21:04 ` ✓ Fi.CI.IGT: " Patchwork
2018-09-12 22:02 ` Paulo Zanoni
2 siblings, 0 replies; 5+ messages in thread
From: Paulo Zanoni @ 2018-09-12 22:02 UTC (permalink / raw)
To: Gustavo A. R. Silva, Jani Nikula, Joonas Lahtinen, David Airlie
Cc: intel-gfx, linux-kernel, dri-devel, Vivi, Rodrigo
Em Qua, 2018-09-12 às 09:31 -0500, Gustavo A. R. Silva escreveu:
> Function intel_port_to_tc() returns PORT_TC_NONE on error, which is
> a negative value -1. In case PORT_TC_NONE is returned, there is an
> undefined behavior when shifting by a negative number of bits in
> both DP_PHY_MODE_STATUS_NOT_SAFE and P_PHY_MODE_STATUS_COMPLETED
> macros.
>
> Fix this by adding sanity checks on intel_port_to_tc return value,
> before
> using macros DP_PHY_MODE_STATUS_NOT_SAFE and
> P_PHY_MODE_STATUS_COMPLETED.
This was just discussed yesterday in a patch by Rodrigo:
https://patchwork.freedesktop.org/patch/246903/
I would personally prefer his version because it avoids passing -1 to
register macros that Coverity doesn't seem to care about, it's a single
check and it prints WARN() instead of DRM_DEBUG_KMS().
Although I do prefer your commit message explanation :).
Perhaps I should reconsider my vote to not merge it. Or we could
actually go and test what happens when intel_port_to_tc() is broken,
fixing all the issues instead of just the ones reported by Coverity.
Anyway, Rodrigo's patch with an improved commit message could receive
my R-B tag now.
>
> Addresses-Coverity-ID: 1473324 ("Bad bit shift operation")
> Addresses-Coverity-ID: 1473325 ("Bad bit shift operation")
> Fixes: 39d1e234e1e1 ("drm/i915/icl: implement the tc/legacy HPD
> {dis,}connect flows")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/gpu/drm/i915/intel_dp.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c
> b/drivers/gpu/drm/i915/intel_dp.c
> index 436c22d..e34b7b1 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -4811,6 +4811,11 @@ static bool icl_tc_phy_connect(struct
> drm_i915_private *dev_priv,
> dig_port->tc_type != TC_PORT_TYPEC)
> return true;
>
> + if (tc_port < 0) {
> + DRM_DEBUG_KMS("Bad TC port %d\n", tc_port);
> + return false;
> + }
> +
> val = I915_READ(PORT_TX_DFLEXDPPMS);
> if (!(val & DP_PHY_MODE_STATUS_COMPLETED(tc_port))) {
> DRM_DEBUG_KMS("DP PHY for TC port %d not ready\n",
> tc_port);
> @@ -4857,6 +4862,10 @@ static void icl_tc_phy_disconnect(struct
> drm_i915_private *dev_priv,
> dig_port->tc_type != TC_PORT_TYPEC)
> return;
>
> + if (tc_port < 0) {
> + DRM_DEBUG_KMS("Bad TC port %d\n", tc_port);
> + return;
> + }
> /*
> * This function may be called many times in a row without
> an HPD event
> * in between, so try to avoid the write when we can.
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/i915/dp: fix shifting by a negative number of bits
@ 2018-09-12 22:02 ` Paulo Zanoni
0 siblings, 0 replies; 5+ messages in thread
From: Paulo Zanoni @ 2018-09-12 22:02 UTC (permalink / raw)
To: Gustavo A. R. Silva, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
David Airlie
Cc: intel-gfx, dri-devel, linux-kernel, Vivi, Rodrigo
Em Qua, 2018-09-12 às 09:31 -0500, Gustavo A. R. Silva escreveu:
> Function intel_port_to_tc() returns PORT_TC_NONE on error, which is
> a negative value -1. In case PORT_TC_NONE is returned, there is an
> undefined behavior when shifting by a negative number of bits in
> both DP_PHY_MODE_STATUS_NOT_SAFE and P_PHY_MODE_STATUS_COMPLETED
> macros.
>
> Fix this by adding sanity checks on intel_port_to_tc return value,
> before
> using macros DP_PHY_MODE_STATUS_NOT_SAFE and
> P_PHY_MODE_STATUS_COMPLETED.
This was just discussed yesterday in a patch by Rodrigo:
https://patchwork.freedesktop.org/patch/246903/
I would personally prefer his version because it avoids passing -1 to
register macros that Coverity doesn't seem to care about, it's a single
check and it prints WARN() instead of DRM_DEBUG_KMS().
Although I do prefer your commit message explanation :).
Perhaps I should reconsider my vote to not merge it. Or we could
actually go and test what happens when intel_port_to_tc() is broken,
fixing all the issues instead of just the ones reported by Coverity.
Anyway, Rodrigo's patch with an improved commit message could receive
my R-B tag now.
>
> Addresses-Coverity-ID: 1473324 ("Bad bit shift operation")
> Addresses-Coverity-ID: 1473325 ("Bad bit shift operation")
> Fixes: 39d1e234e1e1 ("drm/i915/icl: implement the tc/legacy HPD
> {dis,}connect flows")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/gpu/drm/i915/intel_dp.c | 9 +++++++++
> 1 file changed, 9 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/intel_dp.c
> b/drivers/gpu/drm/i915/intel_dp.c
> index 436c22d..e34b7b1 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -4811,6 +4811,11 @@ static bool icl_tc_phy_connect(struct
> drm_i915_private *dev_priv,
> dig_port->tc_type != TC_PORT_TYPEC)
> return true;
>
> + if (tc_port < 0) {
> + DRM_DEBUG_KMS("Bad TC port %d\n", tc_port);
> + return false;
> + }
> +
> val = I915_READ(PORT_TX_DFLEXDPPMS);
> if (!(val & DP_PHY_MODE_STATUS_COMPLETED(tc_port))) {
> DRM_DEBUG_KMS("DP PHY for TC port %d not ready\n",
> tc_port);
> @@ -4857,6 +4862,10 @@ static void icl_tc_phy_disconnect(struct
> drm_i915_private *dev_priv,
> dig_port->tc_type != TC_PORT_TYPEC)
> return;
>
> + if (tc_port < 0) {
> + DRM_DEBUG_KMS("Bad TC port %d\n", tc_port);
> + return;
> + }
> /*
> * This function may be called many times in a row without
> an HPD event
> * in between, so try to avoid the write when we can.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-09-12 22:02 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-12 14:31 [PATCH] drm/i915/dp: fix shifting by a negative number of bits Gustavo A. R. Silva
2018-09-12 15:24 ` ✓ Fi.CI.BAT: success for " Patchwork
2018-09-12 21:04 ` ✓ Fi.CI.IGT: " Patchwork
2018-09-12 22:02 ` [PATCH] " Paulo Zanoni
2018-09-12 22:02 ` Paulo Zanoni
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.