Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1578849rwi; Mon, 31 Oct 2022 19:19:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4mbfyIawJ/tGdy66BhsiqZmxYHIbgtdQeQkhVAh59Rpj0pUpry38jtJjmirSTSDqkb5/Yf X-Received: by 2002:a17:902:a611:b0:186:9ba2:148b with SMTP id u17-20020a170902a61100b001869ba2148bmr17233012plq.164.1667269149405; Mon, 31 Oct 2022 19:19:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667269149; cv=none; d=google.com; s=arc-20160816; b=kIMuO89DoAcAC28z2rC5BcjX1hHKzjuxmYobYXbcLllClulpDVmPC2Y88u9hEdSjKn SrHXxs9qJBKwF1hnCIk2z4zqkmOW8StBPfZBw0iYoZuHukl10GoZJVceVU5QdTEaiSYj SdZHGhKevmnnl2qMjuPnJKRZ9RAyqcaG/o7DOQtFySQCD6s/rSMcuLWM5OE3oZQq2Abo 7xzkWF7GOq6oLbV2GqI3/215ucYxnFKOe4nsQqRmAsIywGsr/uH672Ebzt3XNUwZ2c3R ly8Z1vqeJes9Q76KqFP0x4eZmQDt5ydWMYjKyoAfFsxQVOhE4IgeHLlNVWWfkNb7SMHu LkCA== 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=BHJUiv4AMgTgel1l6ofyyE64y09HTQMkExPE7bHenYI=; b=MKi1EBnbq2V8245JYb5QMgSRS3RNrD1ee0kEd5ETEkMbIWW1+djFXiq0ACgSiRaB5k TS0MksGVD6jZt25DffhB/2wZFi5cgZsUPO+qbJXPcNUAI5YnAqGWMiuA8NNf+INwrB5O +1xXv2cy+Pf3ofi39wwoCtmU9sDSfwLFYxusRxsTBwoNsbBqnux+S5zhzfm9zCnOG21x JWYd1OftE5nt2qNM+iWXanQPYjVYxbwf3+5/TNWQdvqK6iMWiWwsKH34bMu44acPdjF4 GfDwt2kt4u057FdXVGQlOHGsXWCk2O/Bgc9xn1rL0HGd5rZCmgS9blEvCnupFTmjP+Bc TMoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=ED9tKGUb; 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 n13-20020a170902d2cd00b0017e0ca906c8si12030927plc.568.2022.10.31.19.18.56; Mon, 31 Oct 2022 19:19:09 -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=ED9tKGUb; 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 S229711AbiKACEy (ORCPT + 98 others); Mon, 31 Oct 2022 22:04:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229561AbiKACEx (ORCPT ); Mon, 31 Oct 2022 22:04:53 -0400 Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80DB562C2; Mon, 31 Oct 2022 19:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667268291; x=1698804291; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=aCt6XUlU98NDB9OobTpbG9jY9vCxrYTtoNS5Y6y/56c=; b=ED9tKGUbJdyAu1C3soCbfUJG2tyR6w8Eau5UH2HjYtUU1/BTLKM6uboy SmF+cfrLY9+bWamJeNYPIrkebDU3M1P5QEwGBq1u9cymfYfWNNowhcQ55 wZPIfotcjHK3OmbVnPiAh7tWa55M6WRGhvu6mF1JmMKVTt1HPTDNUKzIY dlZkKj0bjkXPAlFSw1/eeqQ0VZhgLbJ5MgJbx5S1zyPw+dEDLZhPbycmq w+ZxLCL8I8RZ8WmjtV1gXCElc8q87Nxa9bM69X9R4bn0W3JOIIM3kjbiu hdVhtfYMw0qhIf5ywLVyPT3Ik44hTqlERTC3eiybf/UREFH4WJaFhE/dY A==; X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="310751480" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="310751480" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 19:04:27 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="776349365" X-IronPort-AV: E=Sophos;i="5.95,229,1661842800"; d="scan'208";a="776349365" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmsmga001.fm.intel.com with ESMTP; 31 Oct 2022 19:04:23 -0700 Date: Tue, 1 Nov 2022 09:55:13 +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.4 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_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 2022-10-31 at 17:34:20 +0200, Andy Shevchenko wrote: > On Mon, Oct 31, 2022 at 09:16:19AM +0800, Xu Yilun wrote: > > 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? > > Have you looked at macros in the overflow.h? Would the use of it solve your > concern? Yes, struct_size() or array_size() specifies the element size & count, which solve the concern at the root. > > -- > With Best Regards, > Andy Shevchenko > >