Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp2498445rwj; Sun, 30 Oct 2022 19:05:07 -0700 (PDT) X-Google-Smtp-Source: AMsMyM58K4g8SG20moRj4KZKHBf6swK2hdKpo7BafOrkjq3ficts/hlFLc5sTyB4+gSDEvuWscX/ X-Received: by 2002:a17:902:da82:b0:186:ee5a:47c7 with SMTP id j2-20020a170902da8200b00186ee5a47c7mr12122237plx.82.1667181907409; Sun, 30 Oct 2022 19:05:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667181907; cv=none; d=google.com; s=arc-20160816; b=JNTdxykt0Gb0dErK1WVErE1/32gsr+/y+UhG5qBeEPfCdijWakW98+x5TbASc2V1rP MroMrnHr8Tz4d22IoqQ6STHM8x6OKf3ygxOHusYflLfBVFSDBfC4yDTyMGyj4gzmsMFH eiBT57IDVD4pphFqW1cJbuJZ5J3qyp/LfWevoxACuaZQZ6ZXak4Q3veE06j4IK1cXv8k ZUt5gyT2D2IgcgJzjlT0+yaxvT9bCoxPlHnc4xmMCjEGfwYviOzjFuKHmlQqfHAWZMTE jNHe21+Pb9BqH7tTvaUa+r+MS/z5Yd/P4KqTG/aN43tZkC0gELrj14axwBBMymrGItSb chOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DCarjv1GdZWVBcviRTiBDdQwtK8QPxbg+KcPKB9PN1s=; b=tbA9XLPacpXItz3CRbdcGKFqC9qQGhGpa0NhxwqXT2pF3ypSf06SLgo+yTiVrpm4o0 NMFgsDCk+CWLXOuyzJDbg1i5HpGDr2SqPXbacPtua+1JqreUuzopGPZiN88aNXJzOczh TiWhFZqjNbj8OiUpyNsNw0pjS6ShAEhnKqQ33byfeOtIv5FUOzPdANrLsmlLZEqbh3dT /copL/hRITIY7cu03gSz92rX71doZKaOXdDCCKIHHCyvCdLjE/43VXuf9tPkXEmUPYNq OMMlqaBKY5C6iUHK3T2tZuJmlMk7hbNu8+BR/XBVunip5AwchmyD1GyfNEpJrKnJUhTT 0tRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="i/vbMTZ7"; 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 y192-20020a638ac9000000b0046afe44ce9esi7463131pgd.131.2022.10.30.19.04.54; Sun, 30 Oct 2022 19:05:07 -0700 (PDT) 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="i/vbMTZ7"; 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 S229716AbiJaBZg (ORCPT + 99 others); Sun, 30 Oct 2022 21:25:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbiJaBZd (ORCPT ); Sun, 30 Oct 2022 21:25:33 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 23C1565FD; Sun, 30 Oct 2022 18:25:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667179533; x=1698715533; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=f640Ubf/vnDK3++Ta0iClrJQA/SD0Rx+i4b2hr4OLDs=; b=i/vbMTZ7b6Mg7OZ/8GroZAwk/BJzYtHe7/nF3z4ZlmreCKQT0TS9fxWK h9uGfaMzeHmSGa4Jl3/gP7K7Gh2//Cbro3bg7hsp7S2PtgCSXiInREriK zCD5iH5JVso8p67hnP+BrI3j1S6HMcx7dMGxQ9OHELTA1opcyCQf+DnXY EoZR8q2/lxI7Dhb6gKVzTDg5DUqIxPfwc3IDmI+Wb1s1xW0em0ND556qy qvXDRVv866rCq/jLYpQbj4Rr63N1zwQj49QivahRbvNRceA0NTwusIwyV v8dza5S39Y/z9qapkm/jsE5gGkN6BKTcqQFF/HAxZYdDrNmbRrA/XUfg6 A==; X-IronPort-AV: E=McAfee;i="6500,9779,10516"; a="288509865" X-IronPort-AV: E=Sophos;i="5.95,227,1661842800"; d="scan'208";a="288509865" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Oct 2022 18:25:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10516"; a="611326587" X-IronPort-AV: E=Sophos;i="5.95,227,1661842800"; d="scan'208";a="611326587" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by orsmga006.jf.intel.com with ESMTP; 30 Oct 2022 18:25:28 -0700 Date: Mon, 31 Oct 2022 09:16:19 +0800 From: Xu Yilun To: Andy Shevchenko Cc: matthew.gerlach@linux.intel.com, hao.wu@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, 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 Subject: Re: [PATCH v4 3/4] fpga: dfl: add basic support DFHv1 Message-ID: References: <20221020212610.697729-1-matthew.gerlach@linux.intel.com> <20221020212610.697729-4-matthew.gerlach@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,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 2022-10-31 at 00:06:28 +0200, Andy Shevchenko wrote: > On Sat, Oct 29, 2022 at 09:08:44PM +0800, Xu Yilun wrote: > > On 2022-10-20 at 14:26:09 -0700, matthew.gerlach@linux.intel.com wrote: > > > > struct dfl_feature_info { > > > u16 fid; > > > u8 revision; > > > + u8 dfh_version; > > > struct resource mmio_res; > > > void __iomem *ioaddr; > > > struct list_head node; > > > unsigned int irq_base; > > > unsigned int nr_irqs; > > > + unsigned int param_size; > > > + u64 params[]; > > > }; > > ... > > > > + finfo = kzalloc(sizeof(*finfo) + dfh_psize, GFP_KERNEL); > > > This probably may use something from overflow.h. > > > The u64 flexible array in the structure, but seems dfh_get_psize could > > not garantee 64bit aligned size. > > > > What's the mandatory alignment of param data? If 64bit aligned, bit 33-34 > > of PARAM_HDR should be reserved. If 32bit aligned, finfo:params should be > > u32[]. > > Isn't it guaranteed by the C standard / architecture ABI? I'm referring to the malloc size of the structure. It reserved dfh_psize bytes for this u64 array, but there is no garantee dfh_psize should be a multiple of 8. So there may be memory leak when accessing the last array element? > > -- > With Best Regards, > Andy Shevchenko > >