Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp1198451rda; Mon, 23 Oct 2023 05:50:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+Z+Eu5Z9wDGUtkbMyagwdk3S2CH+B6WipusqvqVx6H4d1wKLwPdU71m3qVa9yJJvfdp0Y X-Received: by 2002:a05:6e02:1d0a:b0:352:a73a:16f5 with SMTP id i10-20020a056e021d0a00b00352a73a16f5mr11062548ila.18.1698065404054; Mon, 23 Oct 2023 05:50:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698065404; cv=none; d=google.com; s=arc-20160816; b=yJ6jgTrZQW/wZfVtBt/rKQdFevKF9Q713hOsskeiEStemysVOCwU7HFpzLHVfhgTms IXdJyX0c8CRu2J8NAe8uZJKkgb5i5DVJlLfLuUU3FjifE5lzV0OMM9g+zivr4n5WqRvx VWi5h3aiSHDsMa4aI1alyMOTjryDEvzf9Tb569SUWKpbdJdTXPKZKj+rq+6T7pS6I41n o17hh6HJynGoZH+kIYawLQ9j+H9WpR49ELCg5UDpz2bLu7wqovdqm0f6voegSse7y4Qx oGkpk6j/1bV3e7UJ5kTTKU54PGbJ7kE2U3vtCtYR9r6WaaZm4zC6txplR+17CsmovPKV cLqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :organization:in-reply-to:subject:cc:to:from:dkim-signature; bh=m0X4x3HSdKJT43wps7xaV/8/h+RWvzClPvJ4ROqyRzA=; fh=YIFx3NVQp9sAQEci7vvm/UKTQ2w84Z49tC/3F2TV12U=; b=B9+rWKmKcEW/nZ4g5hWpZMZJXEjcF6OhyzXBL9/cSSBIc9/z027zUbuVHYCrtyyOpi fyNUOJTe7xao/H4kIuG8dR8xyNVXm6fk1561ggZvs+4BBOsR/R8ts5KQMLg133MysTWv M8ZCslnAJEtL71Ju4W8OpEOt7RXyzRAfyDosxxNXmG7lK3Nuvm8nanX/8VP/QFMcvPYc mwbp8/hKeDULVe82o/RZrugBFjpkY4DaeRwrsIP9KxvhEb5rygjTyrMmmQMyaXoCZad1 k5KhygydJUsHW1w+5YE7X2RrdS917ABIXL7ddnoZkcl8R2U8Xl7lIvvhdXm56uaOew/H BjVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CJJVLVyj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id d38-20020a631d66000000b00578c64433d5si6200021pgm.877.2023.10.23.05.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 05:50:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=CJJVLVyj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BCE94805F5CA; Mon, 23 Oct 2023 05:50:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbjJWMtw (ORCPT + 99 others); Mon, 23 Oct 2023 08:49:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbjJWMtv (ORCPT ); Mon, 23 Oct 2023 08:49:51 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.120]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B5141CC for ; Mon, 23 Oct 2023 05:49:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698065389; x=1729601389; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=/06vn1FESH5ehRnRfIJp0ycCvwF0E4N5zV1BYkmcMd4=; b=CJJVLVyjaTpj4HilA1vY97URbnmZ4YaCpmzNmvqBHGPtzwFbJ1DQGa9v jX9bBWiZmUhsM90fNB+SgcutaUeNU59GNtR/0OMDSCTPP1MlY/+8xxB8W 9/1O3tgjK7lnr+peywHmLoAn5Kcw+QyJekhc4qMKwNrusHcwlGCzdB3t7 D6rvcTlqI/TN2aRNtUs8GgVvA5ZWrfMIZuxpv0eEo761LlahrGNVfJyc+ N14GwjeXOzXsWsgiZcPRDhvwz/D+OT6r4SCMb5wIy7QSAGHBX0BJhJQMa byeCrrqFohpVz42TEy/x/xfPwj4bTKuesIkyZBjHa0OyVCU3dEfkqhqrR w==; X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="385715728" X-IronPort-AV: E=Sophos;i="6.03,244,1694761200"; d="scan'208";a="385715728" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2023 05:49:49 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10872"; a="761731237" X-IronPort-AV: E=Sophos;i="6.03,244,1694761200"; d="scan'208";a="761731237" Received: from evlad-mobl.ger.corp.intel.com (HELO localhost) ([10.252.47.180]) by fmsmga007-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Oct 2023 05:49:44 -0700 From: Jani Nikula To: Arnd Bergmann , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , Badal Nilawar , Ashutosh Dixit Cc: Arnd Bergmann , Matt Roper , Vinay Belgaumkar , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/i915/mtl: avoid stringop-overflow warning In-Reply-To: <20231016201012.1022812-1-arnd@kernel.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20231016201012.1022812-1-arnd@kernel.org> Date: Mon, 23 Oct 2023 15:49:41 +0300 Message-ID: <87edhlbj16.fsf@intel.com> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 23 Oct 2023 05:50:01 -0700 (PDT) On Mon, 16 Oct 2023, Arnd Bergmann wrote: > From: Arnd Bergmann > > The newly added memset() causes a warning for some reason I could not figure out: > > In file included from arch/x86/include/asm/string.h:3, > from drivers/gpu/drm/i915/gt/intel_rc6.c:6: > In function 'rc6_res_reg_init', > inlined from 'intel_rc6_init' at drivers/gpu/drm/i915/gt/intel_rc6.c:610:2: > arch/x86/include/asm/string_32.h:195:29: error: '__builtin_memset' writing 16 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=] > 195 | #define memset(s, c, count) __builtin_memset(s, c, count) > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > drivers/gpu/drm/i915/gt/intel_rc6.c:584:9: note: in expansion of macro 'memset' > 584 | memset(rc6->res_reg, INVALID_MMIO_REG.reg, sizeof(rc6->res_reg)); > | ^~~~~~ > In function 'intel_rc6_init': > > Change it to an normal initializer and an added memcpy() that does not have > this problem. > > Fixes: 4bb9ca7ee0745 ("drm/i915/mtl: C6 residency and C state type for MTL SAMedia") > Signed-off-by: Arnd Bergmann > --- > drivers/gpu/drm/i915/gt/intel_rc6.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/i915/gt/intel_rc6.c b/drivers/gpu/drm/i915/gt/intel_rc6.c > index 8b67abd720be8..7090e4be29cb6 100644 > --- a/drivers/gpu/drm/i915/gt/intel_rc6.c > +++ b/drivers/gpu/drm/i915/gt/intel_rc6.c > @@ -581,19 +581,23 @@ static void __intel_rc6_disable(struct intel_rc6 *rc6) > > static void rc6_res_reg_init(struct intel_rc6 *rc6) > { > - memset(rc6->res_reg, INVALID_MMIO_REG.reg, sizeof(rc6->res_reg)); That's just bollocks. memset() is byte granularity, while INVALID_MMIO_REG.reg is u32. If the value was anything other than 0, this would break. And you're not supposed to look at the guts of i915_reg_t to begin with, that's why it's a typedef. Basically any code that accesses the members of i915_reg_t outside of its implementation are doing it wrong. Reviewed-by: Jani Nikula > + i915_reg_t res_reg[INTEL_RC6_RES_MAX] = { > + [0 ... INTEL_RC6_RES_MAX - 1] = INVALID_MMIO_REG, > + }; > > switch (rc6_to_gt(rc6)->type) { > case GT_MEDIA: > - rc6->res_reg[INTEL_RC6_RES_RC6] = MTL_MEDIA_MC6; > + res_reg[INTEL_RC6_RES_RC6] = MTL_MEDIA_MC6; > break; > default: > - rc6->res_reg[INTEL_RC6_RES_RC6_LOCKED] = GEN6_GT_GFX_RC6_LOCKED; > - rc6->res_reg[INTEL_RC6_RES_RC6] = GEN6_GT_GFX_RC6; > - rc6->res_reg[INTEL_RC6_RES_RC6p] = GEN6_GT_GFX_RC6p; > - rc6->res_reg[INTEL_RC6_RES_RC6pp] = GEN6_GT_GFX_RC6pp; > + res_reg[INTEL_RC6_RES_RC6_LOCKED] = GEN6_GT_GFX_RC6_LOCKED; > + res_reg[INTEL_RC6_RES_RC6] = GEN6_GT_GFX_RC6; > + res_reg[INTEL_RC6_RES_RC6p] = GEN6_GT_GFX_RC6p; > + res_reg[INTEL_RC6_RES_RC6pp] = GEN6_GT_GFX_RC6pp; > break; > } > + > + memcpy(rc6->res_reg, res_reg, sizeof(res_reg)); > } > > void intel_rc6_init(struct intel_rc6 *rc6) -- Jani Nikula, Intel