Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp4394258rwj; Tue, 20 Dec 2022 09:31:01 -0800 (PST) X-Google-Smtp-Source: AMrXdXtbLB27/2vv16mNKpJdRCrg4zPOXKmaUWGykI55ntjnBOKWzdq6PXO8tjkmJtlE0baM6jP3 X-Received: by 2002:a17:907:c20a:b0:838:9b81:1c98 with SMTP id ti10-20020a170907c20a00b008389b811c98mr1849338ejc.1.1671557461703; Tue, 20 Dec 2022 09:31:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671557461; cv=none; d=google.com; s=arc-20160816; b=m23mARj1VzHD+QuLXIBp8FhSxRIEUfenXA6IaqCwIzYz1mSzMlftCqXzSctN8vyerX mOcAs70hYE4BVR1bK3vgKbLp0FqIlE4dMn3KgR5biwGGh9FaFbJcDFda9EzFn486ScUk Ep8mGlmfheONrRclO+U/OJ8NqRpTyN5RfDbGRn1KZujkaF0p2/ShRqF1e5glJHfc1kma GCu5HD8sBbIQk0nJdHzC43+Az5ebgrTUKgsUhhUJnfmeX07DoIrW+fn7vQkI1iE2v1Oa Dkatnw3JqfEP5Oc4ye7S+Kj3pKWy6HDKmoNe4nRha6jikrQHOKHfabSY31ZF0Ocr3w0G 9VoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=qtirDGWS6DezL9uk+I9CC6XoZX68LABQwV+BVRp1cXM=; b=z9yibMt53jMLerP6LGLBJA1Bhvc75UmJKX1wpFrl7nxPlOZqisA3daE2gVgDpSNIXz Rs+AisGrYgA2RTih9iD2UXuG0Dg19YTJvKTER3E7zcNCRoorgGEm0Ns9MCjuK0Jze/iY g8zTY2f10c+JiGkOy2t9AERhgCiBmaM2w0PV2CB++PV7X3wW2sogwJ2h3sYj14NwCd2l lqxL2NDfyiia5+6O8geOCw6RVOSGOaGIEKblwFIEY+rBuDdqIU75YS+klLsgiTFZAz7k NP6+Ihk7rUdjvwjBIU+OPRksc9BNJoMeeTwjsmqwWROvxOdCY16kWPq8u2TvnGbaQ27f GrHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=eZjHZ8OQ; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y10-20020a056402134a00b0046ff38a9345si10868215edw.587.2022.12.20.09.30.44; Tue, 20 Dec 2022 09:31:01 -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=@intel.com header.s=Intel header.b=eZjHZ8OQ; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233462AbiLTRFh (ORCPT + 70 others); Tue, 20 Dec 2022 12:05:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50312 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbiLTRFf (ORCPT ); Tue, 20 Dec 2022 12:05:35 -0500 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 609D42C3; Tue, 20 Dec 2022 09:05:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1671555934; x=1703091934; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=3isG2zOAi0PziSEV0If0SpVV/rOxtU3UD81BMRi9gFw=; b=eZjHZ8OQo61q9G+VHuhi67Q3/6Pk+GeRn6bH3Sjp1pPSIQCMi+6g/3ln h8CwSBewkRyePrxgB/wVdpWwHX/aSCh7qgg7DAE+IKQ23W5sh5lLYBepo KTcx51aZ/fRKRD731oaP01y3gwu2u1x5mAGaIYahDBUjC1buFuvSD4olb 8eHSg0ULXe1qiexjBvAQRGcVGv4DdKuLfy4140UKpN5utqaC+l/iBglJJ 5j1X751KeE+v9P0IjMug3PubErVco/Eiy0FqEOJ/mRUZ45b1tio6K0hZH iooaWlEsYZA1n5A+mNDdHL0uh2ecFjyXVbvj7TvOqlB54uh4oH5DCnOAR A==; X-IronPort-AV: E=McAfee;i="6500,9779,10567"; a="307341447" X-IronPort-AV: E=Sophos;i="5.96,259,1665471600"; d="scan'208";a="307341447" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Dec 2022 09:03:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10567"; a="825338877" X-IronPort-AV: E=Sophos;i="5.96,259,1665471600"; d="scan'208";a="825338877" Received: from smile.fi.intel.com ([10.237.72.54]) by orsmga005.jf.intel.com with ESMTP; 20 Dec 2022 09:03:09 -0800 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1p7g1D-00D198-0j; Tue, 20 Dec 2022 19:03:07 +0200 Date: Tue, 20 Dec 2022 19:03:06 +0200 From: Andy Shevchenko To: matthew.gerlach@linux.intel.com Cc: hao.wu@intel.com, yilun.xu@intel.com, russell.h.weight@intel.com, basheer.ahmed.muddebihal@intel.com, trix@redhat.com, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, tianfei.zhang@intel.com, corbet@lwn.net, gregkh@linuxfoundation.org, linux-serial@vger.kernel.org, jirislaby@kernel.org, geert+renesas@glider.be, niklas.soderlund+renesas@ragnatech.se, macro@orcam.me.uk, johan@kernel.org, lukas@wunner.de, ilpo.jarvinen@linux.intel.com, marpagan@redhat.com, bagasdotme@gmail.com Subject: Re: [PATCH v7 3/4] fpga: dfl: add basic support for DFHv1 Message-ID: References: <20221220163652.499831-1-matthew.gerlach@linux.intel.com> <20221220163652.499831-4-matthew.gerlach@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221220163652.499831-4-matthew.gerlach@linux.intel.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE 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: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 20, 2022 at 08:36:51AM -0800, matthew.gerlach@linux.intel.com wrote: > From: Matthew Gerlach > > Version 1 of the Device Feature Header (DFH) definition adds > functionality to the DFL bus. > > A DFHv1 header may have one or more parameter blocks that > further describes the HW to SW. Add support to the DFL bus > to parse the MSI-X parameter. > > The location of a feature's register set is explicitly > described in DFHv1 and can be relative to the base of the DFHv1 > or an absolute address. Parse the location and pass the information > to DFL driver. ... > +/** > + * dfh_find_param() - find data for the given parameter id > + * @dfl_dev: dfl device > + * @param: id of dfl parameter > + * > + * Return: pointer to parameter header on success, NULL otherwise. header is a bit confusing here, does it mean we give and ID and we got something more than just a data as summary above suggests? In such case summary and this text should clarify what exactly we get and layout of the data. Since this is a pointer, who is responsible of checking out-of-boundary accesses? For instance, if the parameters are variadic by length the length should be returned as well. Otherwise it should be specified as a constant somewhere, right? > + */ > +u64 *dfh_find_param(struct dfl_device *dfl_dev, int param_id) > +{ > + return find_param(dfl_dev->params, dfl_dev->param_size, param_id); > +} > +EXPORT_SYMBOL_GPL(dfh_find_param); ... > + finfo = kzalloc(sizeof(*finfo) + dfh_psize, GFP_KERNEL); It sounds like a candidate for struct_size() from overflow.h. I.o.w. check that header and come up with the best what can suit your case. > if (!finfo) > return -ENOMEM; -- With Best Regards, Andy Shevchenko