From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E4116C433C1 for ; Wed, 24 Mar 2021 17:23:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B4FBE619C9 for ; Wed, 24 Mar 2021 17:23:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237122AbhCXRXK (ORCPT ); Wed, 24 Mar 2021 13:23:10 -0400 Received: from mga06.intel.com ([134.134.136.31]:16672 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237098AbhCXRW7 (ORCPT ); Wed, 24 Mar 2021 13:22:59 -0400 IronPort-SDR: cQtKDfGSRClLmG3tg20PD7vnKE61zdl5Iy47lu7s8sWzMA5CBf7KgaDKt61tL4HaJj+00Su1S3 pZ8MXBc748TA== X-IronPort-AV: E=McAfee;i="6000,8403,9933"; a="252110427" X-IronPort-AV: E=Sophos;i="5.81,275,1610438400"; d="scan'208";a="252110427" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Mar 2021 10:22:57 -0700 IronPort-SDR: q7x5MCG+vkoOU9Zt5AI1qoSHSHC0Zp99QAlPGLHuv2CUXVcGAPnke24VDa6jskQUUfvyu5ceVQ Ar5TomltcFSQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,275,1610438400"; d="scan'208";a="443059639" Received: from stinkbox.fi.intel.com (HELO stinkbox) ([10.237.72.171]) by FMSMGA003.fm.intel.com with SMTP; 24 Mar 2021 10:22:49 -0700 Received: by stinkbox (sSMTP sendmail emulation); Wed, 24 Mar 2021 19:22:48 +0200 Date: Wed, 24 Mar 2021 19:22:48 +0200 From: Ville =?iso-8859-1?Q?Syrj=E4l=E4?= To: Jani Nikula Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, Martin Sebor , Joonas Lahtinen , Rodrigo Vivi , David Airlie , Daniel Vetter , Arnd Bergmann , x86@kernel.org, Ning Sun , Kalle Valo , Simon Kelley , James Smart , "James E.J. Bottomley" , Anders Larsen , Tejun Heo , Serge Hallyn , Imre Deak , linux-arm-kernel@lists.infradead.org, tboot-devel@lists.sourceforge.net, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, ath11k@lists.infradead.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-scsi@vger.kernel.org, cgroups@vger.kernel.org, linux-security-module@vger.kernel.org, Chris Wilson , =?iso-8859-1?Q?Jos=E9?= Roberto de Souza , Matt Roper , Aditya Swarup Subject: Re: [PATCH 10/11] drm/i915: avoid stringop-overread warning on pri_latency Message-ID: References: <20210322160253.4032422-1-arnd@kernel.org> <20210322160253.4032422-11-arnd@kernel.org> <874kh04lin.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <874kh04lin.fsf@intel.com> X-Patchwork-Hint: comment Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org On Wed, Mar 24, 2021 at 05:30:24PM +0200, Jani Nikula wrote: > On Mon, 22 Mar 2021, Arnd Bergmann wrote: > > From: Arnd Bergmann > > > > gcc-11 warns about what appears to be an out-of-range array access: > > > > In function ‘snb_wm_latency_quirk’, > > inlined from ‘ilk_setup_wm_latency’ at drivers/gpu/drm/i915/intel_pm.c:3108:3: > > drivers/gpu/drm/i915/intel_pm.c:3057:9: error: ‘intel_print_wm_latency’ reading 16 bytes from a region of size 10 [-Werror=stringop-overread] > > 3057 | intel_print_wm_latency(dev_priv, "Primary", dev_priv->wm.pri_latency); > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > drivers/gpu/drm/i915/intel_pm.c: In function ‘ilk_setup_wm_latency’: > > drivers/gpu/drm/i915/intel_pm.c:3057:9: note: referencing argument 3 of type ‘const u16 *’ {aka ‘const short unsigned int *’} > > drivers/gpu/drm/i915/intel_pm.c:2994:13: note: in a call to function ‘intel_print_wm_latency’ > > 2994 | static void intel_print_wm_latency(struct drm_i915_private *dev_priv, > > | ^~~~~~~~~~~~~~~~~~~~~~ > > > > My guess is that this code is actually safe because the size of the > > array depends on the hardware generation, and the function checks for > > that, but at the same time I would not expect the compiler to work it > > out correctly, and the code seems a little fragile with regards to > > future changes. Simply increasing the size of the array should help. > > Agreed, I don't think there's an issue, but the code could use a bunch > of improvements. > > Like, we have intel_print_wm_latency() for debug logging and > wm_latency_show() for debugfs, and there's a bunch of duplication and > ugh. There is all this ancient stuff in review limbo... https://patchwork.freedesktop.org/series/50802/ -- Ville Syrjälä Intel