Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp682410rwb; Thu, 6 Oct 2022 03:04:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7/bmes8hbrK1rkdDtG2BLlMXNL0C5uPUUL4I3Qq5AogdpnRcDCbiVmbOiJQ5gpsL1ixCgC X-Received: by 2002:a05:6402:360d:b0:459:5f40:5b0a with SMTP id el13-20020a056402360d00b004595f405b0amr3702916edb.168.1665050697182; Thu, 06 Oct 2022 03:04:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665050697; cv=none; d=google.com; s=arc-20160816; b=JPg3+jVkgoii1pUQ1iJGXC28TbEdg+WazJj2LBYK9aGmZuf/AnhasMDjBet8B9xUP9 wgPZjTslTZA4bmD09zhY4KhoSoOlM/EfBZW1NAKXmr+aIURmXfhfLYuR1NBYAm791pYM maTYyH6ogR65TCYWgjXNJe8cwft8SfvMXV18Nkt4aYf+IEvlqoHl4aWNeI25JfkmMyjd t8SR+p35uwfD4ExlX/iWNwPypuvpexGG+RvbuDvJEyeAFtZeQxQBmDs/aersatWQIAFd 0mynKaRQ+BgZod+o2aJB49rVY6BdfJLHaFL4+/6QlpCtpvpRzc8GgUIuwGpVcWG2br0j tzhw== 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=fvDltZDrfHmItUKH39amE72R8LJrSqW4gKWzz+879SI=; b=OBCtncIBJsg2HGJIhfTPj1Vboz+s5tS/DeSTLM2uz9fwfi4puqR/IEwjsGFGVg1hV8 lqutD19GBFW7FIxkrz0CzNnjGmjoxJKTn/ilLySzO0axWEQrc4/Zo5IL4Zun5t+vbDCg l3SuFuPC29bCvXJYlpCAxuLsduSpx3Q7EGi2t8D393FwSpSnnkfPl7f8s1lI2ksEJHAd tiKcGIjhiRaHEFxxzpZoOYgGYlvyGKCWC9IJJ+Dhd3xQYvKxP/kkV9U3l2tmOrFZbasS N71TpQOCj/NZsqHC4M6F7u6Ostd9NhcwpgaUHr2QNiOrxfHV7lYt35TIYeX8kYB842kj stQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=L0NHfLuv; 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 i6-20020a1709064fc600b0078b91486b57si8489771ejw.575.2022.10.06.03.04.07; Thu, 06 Oct 2022 03:04:57 -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=L0NHfLuv; 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 S231177AbiJFJ4M (ORCPT + 99 others); Thu, 6 Oct 2022 05:56:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231175AbiJFJ4K (ORCPT ); Thu, 6 Oct 2022 05:56:10 -0400 Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 671D382761; Thu, 6 Oct 2022 02:56: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=1665050165; x=1696586165; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=ped3EFOSYgP0u/JOGENQgHEAPb1CTPyVsTF/z2bnBqI=; b=L0NHfLuvLkCl1pVQ6S5hUSZA98zGNWlQCSOiIuhwBrK/I7g0NOsaIvHf wHxu3MyGQ0KReGyRupAdmhUW6T47Q2UYdY7U3pXZqwY3EDKqXBLWOdE3/ Sk2Rit8pPO3srbjqjEIQQMaoYqQRwAdx33ex6ZN3ulI3IT9RY5BFnrLMR 4jxknb0RgGG8DKiNbZfGgeRkWxy92enpwzP10qtckQYbCAnCYRHPtO5lO N5l/eruZfqBdixkxeA+Wgxop052SGJBPsJscwo+yGuV0FcZ6kbAIWyAYN kVcdD5ljijjzby0WZNcznbu9o7CN9AKE2t9x+ku5tuXneJQ/tLXYGwj2I g==; X-IronPort-AV: E=McAfee;i="6500,9779,10491"; a="301000600" X-IronPort-AV: E=Sophos;i="5.95,163,1661842800"; d="scan'208";a="301000600" Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2022 02:56:04 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10491"; a="869785880" X-IronPort-AV: E=Sophos;i="5.95,163,1661842800"; d="scan'208";a="869785880" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmsmga006.fm.intel.com with ESMTP; 06 Oct 2022 02:56:00 -0700 Date: Thu, 6 Oct 2022 17:47:04 +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, 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 Subject: Re: [PATCH v3 3/4] fpga: dfl: add basic support for DFHv1 Message-ID: References: <20221004143718.1076710-1-matthew.gerlach@linux.intel.com> <20221004143718.1076710-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=-7.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,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 2022-10-04 at 18:11:06 +0300, Andy Shevchenko wrote: > On Tue, Oct 04, 2022 at 07:37:17AM -0700, matthew.gerlach@linux.intel.com wrote: > > From: Matthew Gerlach > > > > Add generic support for MSIX interrupts for DFL devices. > ... > > > +int dfhv1_find_param(void __iomem *base, resource_size_t max, int param) > > +{ > > + int off = DFHv1_PARAM_HDR; > > + u64 v, next; > > + > > + while (off < max) { > > + v = readq(base + off); > > + if (param == FIELD_GET(DFHv1_PARAM_HDR_ID, v)) > > > + return (DFHv1_PARAM_DATA + off); > > Too many parentheses. > > > + > > + next = FIELD_GET(DFHv1_PARAM_HDR_NEXT_OFFSET, v); > > + if (!next) > > + break; > > + > > + off += next; > > + } > > + > > + return -ENOENT; > > +} > > The entire function seems a bit dangerous to me. You can ask for any max which > covers (up to) 64-bit address space and then do MMIO by basically arbitrary > address. How do you protect against wrong MMIO window here? (This is FPGA, so > anything can be read from HW, i.o.w. it's _untrusted_ source of the data.) > > Also, have you tested this with IOMMU enabled? How do they work together (if > there is any collision at all between two?) Yeah, again I don't think this API is good to be used across modules, even if the parameters got checked. It requires too much details for other domain developers. How about: dfl_find_param(struct dfl_device *ddev, int param_id) Thanks, Yilun