Message ID | 20221226225246.1.I15dff7bb5a0e485c862eae61a69096caf12ef29f@changeid |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1240917wrt; Mon, 26 Dec 2022 21:54:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXsSeDCyOk/Rh9duDfpccFKeZFfItjLugv/I5EXpIF7usEZSTAgbDxmCX3X9pg2RTK45BCpP X-Received: by 2002:a17:903:32c3:b0:189:7819:e5c with SMTP id i3-20020a17090332c300b0018978190e5cmr31477620plr.6.1672120466912; Mon, 26 Dec 2022 21:54:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672120466; cv=none; d=google.com; s=arc-20160816; b=HD6IAJC4iH4waY9wJ7CzqVP9Wl1wk1EENnDnE1/5IJVZFmEd0+7JEY2FVObkTuDEpj u9HFPv1EhTmQqHn7+9/Xico+BCZ+C9ojtaSEIhmyTEVB5T0j7659jQh1QEPQf6CCvLZo KFYPYZGSNtzF+nFnpzVAxZChyzkDIFqg1eONmXxiQ3A22JUfZWkB+5hXu6iBqXfv6fhM zhOfKCA6RzG56y9ymuBYOJSF1nrGTgm+JV8SVsHUikk5abrcuSKo7fs3e4ta4uFBlHQN YXymj+6gQ/MBF+fW+kbayaB7c52kat9XTKOrNZi2kHztcwvwnx6mcj5Lcif7yxldakhj ZE3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=9wARd1L8KoeksEpzilviu4ulCrJM4nCfjKCQtrReh+8=; b=DOUbL5diHG9jkZ9hrMOphWlpPlGOWqbtmCG8PSpI9jrjpHhVEv6dGG/t9FsYvKYcPi nrzV5hu3vKHBKg+iQtWL7wN4vU57NKPYz8Mq9R6ugAWUvwjCGWrUTzzwbKo8tj3HPnOm SWdWyJdlWs/AkCIYqBo5iq4DlaPz9JRrj4+M/qWxrrCAGTv6UnEC0WRpVNIiOOx1iSye DhX4xnwVCT/wgkpGJmqSIhTIkohRiW7l0M4jeH0BxCuGax/obyvB9A2alvxBh+5h+pbP oz9DzXPAjjEQCikzxeLG/YWaZSV/NkCBuw5Mf9FOc940s6fR8Sl5vVznpBcKOze06qeM RIHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KtWR1NWX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o17-20020a170902d4d100b0018701f083b1si14650109plg.619.2022.12.26.21.54.10; Mon, 26 Dec 2022 21:54:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KtWR1NWX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229651AbiL0Fxi (ORCPT <rfc822;eddaouddi.ayoub@gmail.com> + 99 others); Tue, 27 Dec 2022 00:53:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229478AbiL0Fxf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 27 Dec 2022 00:53:35 -0500 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C20F21A3 for <linux-kernel@vger.kernel.org>; Mon, 26 Dec 2022 21:53:35 -0800 (PST) Received: by mail-io1-xd2e.google.com with SMTP id q190so6512362iod.10 for <linux-kernel@vger.kernel.org>; Mon, 26 Dec 2022 21:53:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=9wARd1L8KoeksEpzilviu4ulCrJM4nCfjKCQtrReh+8=; b=KtWR1NWXObtv0A+S1nWRpm41eZaY26/OpoTg1WUZ0w96TGoaGxTskVlBy9RmAUg26I R50W5tkC5ZcQFkjLlDpE3K+Eebi3Ek2LtjejuCN1dyyzmdDotjvb03OKSHhHed9q3n1F scwRYzxgCR93T0aHENr/aJvGK684YPRaGbyzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9wARd1L8KoeksEpzilviu4ulCrJM4nCfjKCQtrReh+8=; b=2NKxtNS/vIqpmyVVParmHy0uUOfWMb/VDu2RxDgtnmkPNKOY6U4NzNAsf73Tp4uHNf qCHMSKdOMalg4ZQroAo5N+vYk8j/0kI7aeLFbyqZ9h5muQKMM4Y/C63aQzmBAUuytFX3 YL7CC+c4Fg5V84z0q0g5wn4uJpRCAf2sxlQpXekByyExqQBwlOCp/Iz/8vItxGKF+QVz jpMzCNdf0mNzXAAAoxIi9f4AJlFHEhCmCBBGr4sBFtwcsbLC9FXo3tAIlisBesgmIUqY xe9Yd/XtKdeBuDoCim+8MTbzfSTsYJJP8A6rOrT4RrySSh4i8Pzw8gpjbg7AWiN4M1A8 rauA== X-Gm-Message-State: AFqh2kpxy2Q0kORn3FSrjNby3YhlVNq+VRZKbl9nrDMpXngsub/3/+Ce gJadORIk0ThGpNdb0WW7xJ+1bA== X-Received: by 2002:a6b:da19:0:b0:6e4:e62c:38e3 with SMTP id x25-20020a6bda19000000b006e4e62c38e3mr15013786iob.5.1672120414631; Mon, 26 Dec 2022 21:53:34 -0800 (PST) Received: from midworld.bld.corp.google.com ([2620:15c:183:200:2d44:773f:eb35:d838]) by smtp.gmail.com with ESMTPSA id z11-20020a05660217cb00b006df2b3f17c3sm4678335iox.30.2022.12.26.21.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Dec 2022 21:53:34 -0800 (PST) From: Drew Davenport <ddavenport@chromium.org> To: intel-gfx@lists.freedesktop.org Cc: Drew Davenport <ddavenport@chromium.org>, Daniel Vetter <daniel@ffwll.ch>, David Airlie <airlied@gmail.com>, Imre Deak <imre.deak@intel.com>, Jani Nikula <jani.nikula@linux.intel.com>, Joonas Lahtinen <joonas.lahtinen@linux.intel.com>, =?utf-8?q?Jos=C3=A9_Robe?= =?utf-8?q?rto_de_Souza?= <jose.souza@intel.com>, =?utf-8?q?Juha-Pekka_Heikk?= =?utf-8?q?il=C3=A4?= <juha-pekka.heikkila@intel.com>, Matt Roper <matthew.d.roper@intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>, Thomas Zimmermann <tzimmermann@suse.de>, Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>, =?utf-8?b?VmlsbGUgU3lyasOk?= =?utf-8?b?bMOk?= <ville.syrjala@linux.intel.com>, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH] drm/i915/display: Check source height is > 0 Date: Mon, 26 Dec 2022 22:53:24 -0700 Message-Id: <20221226225246.1.I15dff7bb5a0e485c862eae61a69096caf12ef29f@changeid> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753345390442526856?= X-GMAIL-MSGID: =?utf-8?q?1753345390442526856?= |
Series |
drm/i915/display: Check source height is > 0
|
|
Commit Message
Drew Davenport
Dec. 27, 2022, 5:53 a.m. UTC
The error message suggests that the height of the src rect must be at
least 1. Reject source with height of 0.
Signed-off-by: Drew Davenport <ddavenport@chromium.org>
---
I was investigating some divide-by-zero crash reports on ChromeOS which
pointed to the intel_adjusted_rate function. Further prodding showed
that I could reproduce this in a simple test program if I made src_h
some value less than 1 but greater than 0.
This seemed to be a sensible place to check that the source height is at
least 1. I tried to repro this issue on an amd device I had on hand, and
the configuration was rejected.
Would it make sense to add a check that source dimensions are at least 1
somewhere in core, like in drm_atomic_plane_check? Or is that a valid
use case on some devices, and thus any such check should be done on a
per-driver basis?
Thanks.
drivers/gpu/drm/i915/display/skl_universal_plane.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Is there a better place for this check higher up the intel specific atomic-check? (so the check won't be skl specific - i notice that intel_adjusted_rate is also called by ilk_foo as well and non-backend-specific functions). Else, perhaps intel_adjusted_rate should add a check + WARN? (if we are trying to propagate this slowly across HW). ...alan On Mon, 2022-12-26 at 22:53 -0700, Drew Davenport wrote: > The error message suggests that the height of the src rect must be at > least 1. Reject source with height of 0. > > Signed-off-by: Drew Davenport <ddavenport@chromium.org> > > --- > I was investigating some divide-by-zero crash reports on ChromeOS which > pointed to the intel_adjusted_rate function. Further prodding showed > that I could reproduce this in a simple test program if I made src_h > some value less than 1 but greater than 0. > > This seemed to be a sensible place to check that the source height is at > least 1. I tried to repro this issue on an amd device I had on hand, and > the configuration was rejected. > > Would it make sense to add a check that source dimensions are at least 1 > somewhere in core, like in drm_atomic_plane_check? Or is that a valid > use case on some devices, and thus any such check should be done on a > per-driver basis? > > Thanks. > > drivers/gpu/drm/i915/display/skl_universal_plane.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c > index 4b79c2d2d6177..9b172a1e90deb 100644 > --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c > +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c > @@ -1627,7 +1627,7 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state) > u32 offset; > int ret; > > - if (w > max_width || w < min_width || h > max_height) { > + if (w > max_width || w < min_width || h > max_height || h < 1) { > drm_dbg_kms(&dev_priv->drm, > "requested Y/RGB source size %dx%d outside limits (min: %dx1 max: %dx%d)\n", > w, h, min_width, max_width, max_height); > -- > 2.39.0.314.g84b9a713c41-goog >
Hi Drew, this is good find. I went looking where the problem is in and saw what you probably also saw earlier. I was wondering if diff below would be better fix? I assume this would end up with einval or erange in your case but code flow otherwise would stay as is while fixing all future callers for same issue: diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c index 10e1fc9d0698..a9948e8d3543 100644 --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c @@ -144,7 +144,7 @@ unsigned int intel_adjusted_rate(const struct drm_rect *src, const struct drm_rect *dst, unsigned int rate) { - unsigned int src_w, src_h, dst_w, dst_h; + unsigned int src_w, src_h, dst_w, dst_h, dst_wh; src_w = drm_rect_width(src) >> 16; src_h = drm_rect_height(src) >> 16; @@ -155,8 +155,10 @@ unsigned int intel_adjusted_rate(const struct drm_rect *src, dst_w = min(src_w, dst_w); dst_h = min(src_h, dst_h); - return DIV_ROUND_UP_ULL(mul_u32_u32(rate, src_w * src_h), - dst_w * dst_h); + /* in case src contained only fractional part */ + dst_wh = max(dst_w * dst_h, (unsigned) 1); + + return DIV_ROUND_UP_ULL(mul_u32_u32(rate, src_w * src_h), dst_wh); } unsigned int intel_plane_pixel_rate(const struct intel_crtc_state *crtc_state, What do you think? I'll in any case come up with some test for this in igt. /Juha-Pekka On 27.12.2022 7.53, Drew Davenport wrote: > The error message suggests that the height of the src rect must be at > least 1. Reject source with height of 0. > > Signed-off-by: Drew Davenport <ddavenport@chromium.org> > > --- > I was investigating some divide-by-zero crash reports on ChromeOS which > pointed to the intel_adjusted_rate function. Further prodding showed > that I could reproduce this in a simple test program if I made src_h > some value less than 1 but greater than 0. > > This seemed to be a sensible place to check that the source height is at > least 1. I tried to repro this issue on an amd device I had on hand, and > the configuration was rejected. > > Would it make sense to add a check that source dimensions are at least 1 > somewhere in core, like in drm_atomic_plane_check? Or is that a valid > use case on some devices, and thus any such check should be done on a > per-driver basis? > > Thanks. > > drivers/gpu/drm/i915/display/skl_universal_plane.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c > index 4b79c2d2d6177..9b172a1e90deb 100644 > --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c > +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c > @@ -1627,7 +1627,7 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state) > u32 offset; > int ret; > > - if (w > max_width || w < min_width || h > max_height) { > + if (w > max_width || w < min_width || h > max_height || h < 1) { > drm_dbg_kms(&dev_priv->drm, > "requested Y/RGB source size %dx%d outside limits (min: %dx1 max: %dx%d)\n", > w, h, min_width, max_width, max_height);
On Tue, Jan 03, 2023 at 12:42:43PM +0200, Juha-Pekka Heikkila wrote: > Hi Drew, Hi Juha-Pekka, sorry for the late response since I was on vacation. > > this is good find. I went looking where the problem is in and saw what you > probably also saw earlier. > > I was wondering if diff below would be better fix? I assume this would end > up with einval or erange in your case but code flow otherwise would stay as > is while fixing all future callers for same issue: Yes, the function you identify below is where I encountered divide-by-zero errors. If width/height less than 1 is a legitimate use case, then your proposed solution looks like it would be better. It should have no risk of regression in userspace either, which is nice. I tested your patch, and as expected I did not hit the divide-by-zero error, though the test commit was rejected due to a check further along inside skl_update_scaler. Perhaps there is some other configuration which would pass the test commit with a width/height less than 1, but I didn't dig much further. > > diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c > b/drivers/gpu/drm/i915/display/intel_atomic_plane.c > index 10e1fc9d0698..a9948e8d3543 100644 > --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c > +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c > @@ -144,7 +144,7 @@ unsigned int intel_adjusted_rate(const struct drm_rect > *src, > const struct drm_rect *dst, > unsigned int rate) > { > - unsigned int src_w, src_h, dst_w, dst_h; > + unsigned int src_w, src_h, dst_w, dst_h, dst_wh; > > src_w = drm_rect_width(src) >> 16; > src_h = drm_rect_height(src) >> 16; > @@ -155,8 +155,10 @@ unsigned int intel_adjusted_rate(const struct drm_rect > *src, > dst_w = min(src_w, dst_w); > dst_h = min(src_h, dst_h); > > - return DIV_ROUND_UP_ULL(mul_u32_u32(rate, src_w * src_h), > - dst_w * dst_h); > + /* in case src contained only fractional part */ > + dst_wh = max(dst_w * dst_h, (unsigned) 1); > + > + return DIV_ROUND_UP_ULL(mul_u32_u32(rate, src_w * src_h), dst_wh); > } > > unsigned int intel_plane_pixel_rate(const struct intel_crtc_state > *crtc_state, > > > What do you think? I'll in any case come up with some test for this in igt. I see that you've posted your fix to the list already. Adding a test to cover this in IGT also sounds great. Thanks! Breadcrumbs to Juha-Pekka's patch for anyone following this thread: https://patchwork.freedesktop.org/series/112396/ > > /Juha-Pekka > > On 27.12.2022 7.53, Drew Davenport wrote: > > The error message suggests that the height of the src rect must be at > > least 1. Reject source with height of 0. > > > > Signed-off-by: Drew Davenport <ddavenport@chromium.org> > > > > --- > > I was investigating some divide-by-zero crash reports on ChromeOS which > > pointed to the intel_adjusted_rate function. Further prodding showed > > that I could reproduce this in a simple test program if I made src_h > > some value less than 1 but greater than 0. > > > > This seemed to be a sensible place to check that the source height is at > > least 1. I tried to repro this issue on an amd device I had on hand, and > > the configuration was rejected. > > > > Would it make sense to add a check that source dimensions are at least 1 > > somewhere in core, like in drm_atomic_plane_check? Or is that a valid > > use case on some devices, and thus any such check should be done on a > > per-driver basis? > > > > Thanks. > > > > drivers/gpu/drm/i915/display/skl_universal_plane.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c > > index 4b79c2d2d6177..9b172a1e90deb 100644 > > --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c > > +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c > > @@ -1627,7 +1627,7 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state) > > u32 offset; > > int ret; > > - if (w > max_width || w < min_width || h > max_height) { > > + if (w > max_width || w < min_width || h > max_height || h < 1) { > > drm_dbg_kms(&dev_priv->drm, > > "requested Y/RGB source size %dx%d outside limits (min: %dx1 max: %dx%d)\n", > > w, h, min_width, max_width, max_height); >
On Tue, Dec 27, 2022 at 05:55:17PM +0000, Teres Alexis, Alan Previn wrote: > Is there a better place for this check higher up the intel specific atomic-check? (so the check won't be skl specific - i notice that intel_adjusted_rate is also called by > ilk_foo as well and non-backend-specific functions). Else, perhaps intel_adjusted_rate should add a check + WARN? (if we are trying to propagate this slowly across HW). Would intel_plane_atomic_check_with_state be a more appropriate place to check that the src width and height are at least 1? This is where skl_plane_check and other HW's foo_plane_check functions are called from. I don't think that the potential divide-by-zero will be hit in the case where intel_adjusted_rate is called from ilk_pipe_pixel_rate because the src rect will not have a fractional part to it in this case. I'm assuming that something earlier on would catch and reject a src with zero width/height. Drew > > > ...alan > > On Mon, 2022-12-26 at 22:53 -0700, Drew Davenport wrote: > > The error message suggests that the height of the src rect must be at > > least 1. Reject source with height of 0. > > > > Signed-off-by: Drew Davenport <ddavenport@chromium.org> > > > > --- > > I was investigating some divide-by-zero crash reports on ChromeOS which > > pointed to the intel_adjusted_rate function. Further prodding showed > > that I could reproduce this in a simple test program if I made src_h > > some value less than 1 but greater than 0. > > > > This seemed to be a sensible place to check that the source height is at > > least 1. I tried to repro this issue on an amd device I had on hand, and > > the configuration was rejected. > > > > Would it make sense to add a check that source dimensions are at least 1 > > somewhere in core, like in drm_atomic_plane_check? Or is that a valid > > use case on some devices, and thus any such check should be done on a > > per-driver basis? > > > > Thanks. > > > > drivers/gpu/drm/i915/display/skl_universal_plane.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c > > index 4b79c2d2d6177..9b172a1e90deb 100644 > > --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c > > +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c > > @@ -1627,7 +1627,7 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state) > > u32 offset; > > int ret; > > > > - if (w > max_width || w < min_width || h > max_height) { > > + if (w > max_width || w < min_width || h > max_height || h < 1) { > > drm_dbg_kms(&dev_priv->drm, > > "requested Y/RGB source size %dx%d outside limits (min: %dx1 max: %dx%d)\n", > > w, h, min_width, max_width, max_height); > > -- > > 2.39.0.314.g84b9a713c41-goog > > >
On Mon, Dec 26, 2022 at 10:53:24PM -0700, Drew Davenport wrote: > The error message suggests that the height of the src rect must be at > least 1. Reject source with height of 0. > > Signed-off-by: Drew Davenport <ddavenport@chromium.org> > > --- > I was investigating some divide-by-zero crash reports on ChromeOS which > pointed to the intel_adjusted_rate function. Further prodding showed > that I could reproduce this in a simple test program if I made src_h > some value less than 1 but greater than 0. > > This seemed to be a sensible place to check that the source height is at > least 1. I tried to repro this issue on an amd device I had on hand, and > the configuration was rejected. > > Would it make sense to add a check that source dimensions are at least 1 > somewhere in core, like in drm_atomic_plane_check? Or is that a valid > use case on some devices, and thus any such check should be done on a > per-driver basis? > > Thanks. > > drivers/gpu/drm/i915/display/skl_universal_plane.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c > index 4b79c2d2d6177..9b172a1e90deb 100644 > --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c > +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c > @@ -1627,7 +1627,7 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state) > u32 offset; > int ret; > > - if (w > max_width || w < min_width || h > max_height) { > + if (w > max_width || w < min_width || h > max_height || h < 1) { I liked this one best so pushed to drm-intel-next with cc:stable. Thanks. In the future we might want to move some of these checks to an earlier spot to make sure we don't hit any other weird issues in some other code, but for the moment I think this will do. > drm_dbg_kms(&dev_priv->drm, > "requested Y/RGB source size %dx%d outside limits (min: %dx1 max: %dx%d)\n", > w, h, min_width, max_width, max_height); > -- > 2.39.0.314.g84b9a713c41-goog
On 12.1.2023 20.28, Ville Syrjälä wrote: > On Mon, Dec 26, 2022 at 10:53:24PM -0700, Drew Davenport wrote: >> The error message suggests that the height of the src rect must be at >> least 1. Reject source with height of 0. >> >> Signed-off-by: Drew Davenport <ddavenport@chromium.org> >> >> --- >> I was investigating some divide-by-zero crash reports on ChromeOS which >> pointed to the intel_adjusted_rate function. Further prodding showed >> that I could reproduce this in a simple test program if I made src_h >> some value less than 1 but greater than 0. >> >> This seemed to be a sensible place to check that the source height is at >> least 1. I tried to repro this issue on an amd device I had on hand, and >> the configuration was rejected. >> >> Would it make sense to add a check that source dimensions are at least 1 >> somewhere in core, like in drm_atomic_plane_check? Or is that a valid >> use case on some devices, and thus any such check should be done on a >> per-driver basis? >> >> Thanks. >> >> drivers/gpu/drm/i915/display/skl_universal_plane.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c >> index 4b79c2d2d6177..9b172a1e90deb 100644 >> --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c >> +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c >> @@ -1627,7 +1627,7 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state) >> u32 offset; >> int ret; >> >> - if (w > max_width || w < min_width || h > max_height) { >> + if (w > max_width || w < min_width || h > max_height || h < 1) { > > I liked this one best so pushed to drm-intel-next with cc:stable. Thanks. > > In the future we might want to move some of these checks to an earlier > spot to make sure we don't hit any other weird issues in some other > code, but for the moment I think this will do. > Look ok to me. Tests which I had written to try different ways to cause this issue are now returning einval as expected. I'll polish my igt test for this issue and send it out bit later. /Juha-pekka >> drm_dbg_kms(&dev_priv->drm, >> "requested Y/RGB source size %dx%d outside limits (min: %dx1 max: %dx%d)\n", >> w, h, min_width, max_width, max_height); >> -- >> 2.39.0.314.g84b9a713c41-goog >
diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c b/drivers/gpu/drm/i915/display/skl_universal_plane.c index 4b79c2d2d6177..9b172a1e90deb 100644 --- a/drivers/gpu/drm/i915/display/skl_universal_plane.c +++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c @@ -1627,7 +1627,7 @@ static int skl_check_main_surface(struct intel_plane_state *plane_state) u32 offset; int ret; - if (w > max_width || w < min_width || h > max_height) { + if (w > max_width || w < min_width || h > max_height || h < 1) { drm_dbg_kms(&dev_priv->drm, "requested Y/RGB source size %dx%d outside limits (min: %dx1 max: %dx%d)\n", w, h, min_width, max_width, max_height);