Received: by 2002:a05:622a:1442:b0:3a5:28ea:c4b9 with SMTP id v2csp801645qtx; Mon, 31 Oct 2022 14:19:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5I/JOEwBX3Yrvg/3Waze/wVH/fz0uq0EekvsxvJOgx3NALWGgHvHtMtBV7oIAFJBT7Jy7/ X-Received: by 2002:a05:6a00:2446:b0:528:5f22:5b6f with SMTP id d6-20020a056a00244600b005285f225b6fmr16446141pfj.73.1667251142943; Mon, 31 Oct 2022 14:19:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667251142; cv=none; d=google.com; s=arc-20160816; b=nu5dD9P8WXmkByxbtfWld59pknN8QVUyNyOHSRpDr9I3GJDO9El1eZO5EE9rl+9UOd Cr1xtjwmxeAPVILX43uFXEeYEgoVTViNIYwtMrcTv4Ia9hsdf7203kWaj5X6eamPOtgg S6tPbpcd/5SiZ7g0wJqEfwU5WorXpXCEoucEsC4oLtLcY+OShdT3ENcgoVVjEnP9OMj1 WnCMBClPlujgaG4kLkFbMqfYI+IVMdWvi7mkQCkV/cmpU+1wVjkGSSjvOroyDSZXIU4Y JCNEANb8AVhTy4dDeLj7pw9o5YDL6A5qIj+/aI6WNxy2nHqFl8DuZT1+sFtM3hrT15Xm XTsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=JiFGmeb4OKDKWnXUVW93zI2WZnNiDZMtnTwDJdSg8/M=; b=hEDqIkREbJz6jjgyH1zvDYGD4Tq5UF8VmhqQP0iTSXJV1KhFl2OCjrO5LFi8PZmQWF zHCzqszKhhPR07llzqnvyHGGR5Dc/aInjQ1K2JVDBvccqIVhmOhuJ7KXbDex5JknAJV6 szXtgkmxcyRutDgYC2Jkk0wvGHji0E4lscAXtw1QFF3bMZM+zDOXf/Mdte46owqHTnWk 5YOKNQESBX+k+i5pk9ZJaF2tl0IOuOr/77I/hrLYfsi+6CL5fGThpBHfNZpOnb8OhuTU tboO/gA6vBGVNxoXZzqDS2etoEWVY4kSc0TGjM4nqstcEY2Y7FW3R1dUVvPRZd+n9x4i Bf+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Gbm1faOr; 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 q27-20020a63f95b000000b0044e12bf36e1si9835578pgk.557.2022.10.31.14.18.50; Mon, 31 Oct 2022 14:19:02 -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=Gbm1faOr; 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 S229589AbiJaUPL (ORCPT + 98 others); Mon, 31 Oct 2022 16:15:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbiJaUPG (ORCPT ); Mon, 31 Oct 2022 16:15:06 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 35DB06337; Mon, 31 Oct 2022 13:15:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1667247305; x=1698783305; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=IHbJOlvitpR4GGONJy+qLhQEFg8wxFTPAPEhDEJBvcI=; b=Gbm1faOrlUqsBnNglUrYPOgFhzUG7psoc5fnpkUvlz4SNAUQMMIZ/2sv ryPvpMudpHhL4ikWyr31ctVDZWoBbJPMf8ms+lwg6PF0zjL697FTLwN9u mbEUeqvubfbk8jRbPgbVv9Kl1QxtIablCdDPwVTP2H4HGVWOW7q7XUatt tlxi8poftOd1jFLjetgYzVn8jDXWvWZNKp+PqzwQE7QAx7t3neWc6Al56 CpHEnLWWDnDwl2Ehswu4kNybhWbK719WOwqJOlZrDqfcXWp28zPaHt41s qlV+ejQDYKAexxA15nPzfdkD20itVN1imCYCdhuz8yRTm43Fn5ePBgbB3 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="308989799" X-IronPort-AV: E=Sophos;i="5.95,228,1661842800"; d="scan'208";a="308989799" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 13:15:04 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10517"; a="758956171" X-IronPort-AV: E=Sophos;i="5.95,228,1661842800"; d="scan'208";a="758956171" Received: from rhweight-wrk1.ra.intel.com ([137.102.106.139]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Oct 2022 13:15:04 -0700 Date: Mon, 31 Oct 2022 13:15:06 -0700 (PDT) From: matthew.gerlach@linux.intel.com X-X-Sender: mgerlach@rhweight-WRK1 To: Andy Shevchenko cc: Xu Yilun , 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 In-Reply-To: Message-ID: References: <20221020212610.697729-1-matthew.gerlach@linux.intel.com> <20221020212610.697729-4-matthew.gerlach@linux.intel.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,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 Mon, 31 Oct 2022, 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? By clarifying the definition of the next field in the parameter header as the number of 8-byte words, dfh_get_psize is guaranteed to be a multiple of 8. This is fixed in the next revision of patches. Matthew Gerlach > > -- > With Best Regards, > Andy Shevchenko > > >