All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Simon Ser <contact@emersion.fr>
Cc: David Airlie <airlied@linux.ie>,
	intel-gfx <intel-gfx@lists.freedesktop.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Pekka Paalanen <ppaalanen@gmail.com>
Subject: Re: [Intel-gfx] drm_modes: signed integer overflow
Date: Fri, 23 Oct 2020 18:27:19 +0300	[thread overview]
Message-ID: <20201023152719.GV6112@intel.com> (raw)
In-Reply-To: <BaLsmzqZNUi-nVbYiLstRgspKGlLahAI8vM2_NPfos2PxM0N9lycj-Zn5TdqNtEHB-jeWgmzw9EHJxq4H5552tVi4bAZXTLnP0y1QsTPFtY=@emersion.fr>

On Fri, Oct 23, 2020 at 03:14:20PM +0000, Simon Ser wrote:
> On Thursday, October 22, 2020 12:14 PM, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> 
> > On Wed, Oct 21, 2020 at 08:13:43PM -0700, Randy Dunlap wrote:
> >
> > > Hi,
> > > With linux-next 20201021, when booting up, I am seeing this:
> > > [ 0.560896] UBSAN: signed-integer-overflow in ../drivers/gpu/drm/drm_modes.c:765:20
> > > [ 0.560903] 2376000 * 1000 cannot be represented in type 'int'
> >
> > Dang. Didn't realize these new crazy >8k modes have dotclocks reaching
> > almost 6 GHz, which would overflow even u32. I guess we'll switch to
> > 64bit maths. Now I wonder how many other places can hit this overflow
> > in practice...
> 
> Can you provide an example of a full crazy >8k mode?

These are two extreme cases:
        /* 216 - 10240x4320@100Hz 64:27 */
        { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 5940000, 10240, 12432,
                   12608, 13200, 0, 4320, 4336, 4356, 4500, 0,
                   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
          .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
        /* 217 - 10240x4320@120Hz 64:27 */
        { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 5940000, 10240, 10528,
                   10704, 11000, 0, 4320, 4336, 4356, 4500, 0,
                   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
          .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }

> I'm trying to get
> a fix for my user-space [1], and I'm wondering if int32_t is enough
> after dividing by mode->htotal.
> 
> CC Pekka, just FYI (I think Weston has similar code).
> 
> [1]: https://github.com/swaywm/wlroots/pull/2450

What's with those 1000000LL constants? Are you storing
clock in Hz units?

-- 
Ville Syrjälä
Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Simon Ser <contact@emersion.fr>
Cc: David Airlie <airlied@linux.ie>,
	intel-gfx <intel-gfx@lists.freedesktop.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	LKML <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>
Subject: Re: [Intel-gfx] drm_modes: signed integer overflow
Date: Fri, 23 Oct 2020 18:27:19 +0300	[thread overview]
Message-ID: <20201023152719.GV6112@intel.com> (raw)
In-Reply-To: <BaLsmzqZNUi-nVbYiLstRgspKGlLahAI8vM2_NPfos2PxM0N9lycj-Zn5TdqNtEHB-jeWgmzw9EHJxq4H5552tVi4bAZXTLnP0y1QsTPFtY=@emersion.fr>

On Fri, Oct 23, 2020 at 03:14:20PM +0000, Simon Ser wrote:
> On Thursday, October 22, 2020 12:14 PM, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> 
> > On Wed, Oct 21, 2020 at 08:13:43PM -0700, Randy Dunlap wrote:
> >
> > > Hi,
> > > With linux-next 20201021, when booting up, I am seeing this:
> > > [ 0.560896] UBSAN: signed-integer-overflow in ../drivers/gpu/drm/drm_modes.c:765:20
> > > [ 0.560903] 2376000 * 1000 cannot be represented in type 'int'
> >
> > Dang. Didn't realize these new crazy >8k modes have dotclocks reaching
> > almost 6 GHz, which would overflow even u32. I guess we'll switch to
> > 64bit maths. Now I wonder how many other places can hit this overflow
> > in practice...
> 
> Can you provide an example of a full crazy >8k mode?

These are two extreme cases:
        /* 216 - 10240x4320@100Hz 64:27 */
        { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 5940000, 10240, 12432,
                   12608, 13200, 0, 4320, 4336, 4356, 4500, 0,
                   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
          .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
        /* 217 - 10240x4320@120Hz 64:27 */
        { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 5940000, 10240, 10528,
                   10704, 11000, 0, 4320, 4336, 4356, 4500, 0,
                   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
          .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }

> I'm trying to get
> a fix for my user-space [1], and I'm wondering if int32_t is enough
> after dividing by mode->htotal.
> 
> CC Pekka, just FYI (I think Weston has similar code).
> 
> [1]: https://github.com/swaywm/wlroots/pull/2450

What's with those 1000000LL constants? Are you storing
clock in Hz units?

-- 
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

WARNING: multiple messages have this Message-ID (diff)
From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Simon Ser <contact@emersion.fr>
Cc: Randy Dunlap <rdunlap@infradead.org>,
	David Airlie <airlied@linux.ie>,
	intel-gfx <intel-gfx@lists.freedesktop.org>,
	LKML <linux-kernel@vger.kernel.org>,
	dri-devel <dri-devel@lists.freedesktop.org>,
	Pekka Paalanen <ppaalanen@gmail.com>
Subject: Re: [Intel-gfx] drm_modes: signed integer overflow
Date: Fri, 23 Oct 2020 18:27:19 +0300	[thread overview]
Message-ID: <20201023152719.GV6112@intel.com> (raw)
In-Reply-To: <BaLsmzqZNUi-nVbYiLstRgspKGlLahAI8vM2_NPfos2PxM0N9lycj-Zn5TdqNtEHB-jeWgmzw9EHJxq4H5552tVi4bAZXTLnP0y1QsTPFtY=@emersion.fr>

On Fri, Oct 23, 2020 at 03:14:20PM +0000, Simon Ser wrote:
> On Thursday, October 22, 2020 12:14 PM, Ville Syrjälä <ville.syrjala@linux.intel.com> wrote:
> 
> > On Wed, Oct 21, 2020 at 08:13:43PM -0700, Randy Dunlap wrote:
> >
> > > Hi,
> > > With linux-next 20201021, when booting up, I am seeing this:
> > > [ 0.560896] UBSAN: signed-integer-overflow in ../drivers/gpu/drm/drm_modes.c:765:20
> > > [ 0.560903] 2376000 * 1000 cannot be represented in type 'int'
> >
> > Dang. Didn't realize these new crazy >8k modes have dotclocks reaching
> > almost 6 GHz, which would overflow even u32. I guess we'll switch to
> > 64bit maths. Now I wonder how many other places can hit this overflow
> > in practice...
> 
> Can you provide an example of a full crazy >8k mode?

These are two extreme cases:
        /* 216 - 10240x4320@100Hz 64:27 */
        { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 5940000, 10240, 12432,
                   12608, 13200, 0, 4320, 4336, 4356, 4500, 0,
                   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
          .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, },
        /* 217 - 10240x4320@120Hz 64:27 */
        { DRM_MODE("10240x4320", DRM_MODE_TYPE_DRIVER, 5940000, 10240, 10528,
                   10704, 11000, 0, 4320, 4336, 4356, 4500, 0,
                   DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_PVSYNC),
          .picture_aspect_ratio = HDMI_PICTURE_ASPECT_64_27, }

> I'm trying to get
> a fix for my user-space [1], and I'm wondering if int32_t is enough
> after dividing by mode->htotal.
> 
> CC Pekka, just FYI (I think Weston has similar code).
> 
> [1]: https://github.com/swaywm/wlroots/pull/2450

What's with those 1000000LL constants? Are you storing
clock in Hz units?

-- 
Ville Syrjälä
Intel

  reply	other threads:[~2020-10-23 15:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-22  3:13 [Intel-gfx] drm_modes: signed integer overflow Randy Dunlap
2020-10-22  3:13 ` Randy Dunlap
2020-10-22  3:13 ` Randy Dunlap
2020-10-22 10:14 ` [Intel-gfx] " Ville Syrjälä
2020-10-22 10:14   ` Ville Syrjälä
2020-10-22 10:14   ` Ville Syrjälä
2020-10-23 15:14   ` Simon Ser
2020-10-23 15:14     ` Simon Ser
2020-10-23 15:14     ` Simon Ser
2020-10-23 15:27     ` Ville Syrjälä [this message]
2020-10-23 15:27       ` Ville Syrjälä
2020-10-23 15:27       ` Ville Syrjälä
2020-10-23 16:02       ` Simon Ser
2020-10-23 16:02         ` Simon Ser
2020-10-23 16:02         ` Simon Ser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201023152719.GV6112@intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=airlied@linux.ie \
    --cc=contact@emersion.fr \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ppaalanen@gmail.com \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.