Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp34419ybg; Thu, 11 Jun 2020 16:22:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVJqemy4UWIpZrow/EbfyMrMU12igKqTXUPmAN6ukn/KINMef9KCUTBlc73LDZvne/oMbB X-Received: by 2002:a17:906:63c9:: with SMTP id u9mr10958294ejk.487.1591917746114; Thu, 11 Jun 2020 16:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591917746; cv=none; d=google.com; s=arc-20160816; b=Md+Wn7GsCmgCwZk9FGOtsyPJljrnKGTc09lgti3QdGuB5kfWQzHGCOt19245uAFVvq reUj71xyGBYQPRcdESzN72LJw7/P6LnCXlr83n5P77Ezk7+iHcmnGWiiLNVBdfPeQHs+ 0Br0h4o4FjtlwNgZuR+bOrQZZq90zdrW33VMThtIN6K6ylp7kRKsryAVNfeid1V4364h wYeZViIc1NL4BKSZG7v47t9+CnnLGTcPPAK9CwnZxE3wwbcUfmfHGSiKnZplfBcSFaIu 0O1lNLimAd57c4Mc0i1BfnHhlftTzK5uYa5bJ/VWYMQQ+5xH5Bmylqzk1vx0fJdhHFrn V6SA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:ironport-sdr:ironport-sdr; bh=B1sFSd0DqCJ7xLh1cjcbVkPP6eiVHc99swPPTaQhB+o=; b=fJDrsvmVv9ET9L5Vk5a7w4lLFAv5PefxwSvhmXmzkbNmL8J5GyYhm+T4kPXDqKgeQB MJKllaYY4QLqBeseLbxbXMv3UeFdScn3ezPP9nJRrUU11xcPUfGJPjioiFGU1HfguWNK GXqO5wBbgtWSEgwmbmnBzUZpMwglD9mL2Dz8RHSxHKFHgzD3FlVYjCOzRpDTm9T/moDW IUv1BqeIn+0P6JIXKG1VGhMaV0ST0oWQmXhEhY58awkToiXVZoMUNHBW7i1geYkCoHe0 Z5oG6JJpDLn2xdoUfb1AoyEwAXAh0BD4qhFdt0F7eJ8f9lFqi9IB43nKUQUhVzLfnGd5 wpLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di12si2380272edb.27.2020.06.11.16.22.03; Thu, 11 Jun 2020 16:22:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726375AbgFKXTn (ORCPT + 99 others); Thu, 11 Jun 2020 19:19:43 -0400 Received: from mga01.intel.com ([192.55.52.88]:54817 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbgFKXTm (ORCPT ); Thu, 11 Jun 2020 19:19:42 -0400 IronPort-SDR: /e8IMUcCmRV4SpnuVMO8EikxbhJF5FkY5r06R+jt6jua1sktp+ZidvAfGOazS+KLnr20SHWeo2 /GvZ7Bz2diNA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 Jun 2020 16:19:41 -0700 IronPort-SDR: AGUrCH3jTbmFw0VS5HaFBFEvT/Llroj3vgjcZqsmwo1bPwjfkUlLgdwXTuw1GBgZ2T00/h/SS1 uoy89sWFFWPg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,501,1583222400"; d="scan'208";a="473995204" Received: from joy-optiplex-7040.sh.intel.com (HELO joy-OptiPlex-7040) ([10.239.13.16]) by fmsmga005.fm.intel.com with ESMTP; 11 Jun 2020 16:19:39 -0700 Date: Thu, 11 Jun 2020 19:09:40 -0400 From: Yan Zhao To: David Edmondson Cc: Cornelia Huck , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, alex.williamson@redhat.com, zhenyuw@linux.intel.com, zhi.a.wang@intel.com, kevin.tian@intel.com, shaopeng.he@intel.com, yi.l.liu@intel.com, xin.zeng@intel.com, hang.yuan@intel.com Subject: Re: [RFC PATCH v4 04/10] vfio/pci: let vfio_pci know number of vendor regions and vendor irqs Message-ID: <20200611230940.GD13961@joy-OptiPlex-7040> Reply-To: Yan Zhao References: <20200518024202.13996-1-yan.y.zhao@intel.com> <20200518024944.14263-1-yan.y.zhao@intel.com> <20200604172515.614e9864.cohuck@redhat.com> <20200605021542.GG12300@joy-OptiPlex-7040> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 11, 2020 at 01:31:05PM +0100, David Edmondson wrote: > On Thursday, 2020-06-04 at 22:15:42 -04, Yan Zhao wrote: > > > On Thu, Jun 04, 2020 at 05:25:15PM +0200, Cornelia Huck wrote: > >> On Sun, 17 May 2020 22:49:44 -0400 > >> Yan Zhao wrote: > >> > >> > This allows a simpler VFIO_DEVICE_GET_INFO ioctl in vendor driver > >> > > >> > Cc: Kevin Tian > >> > Signed-off-by: Yan Zhao > >> > --- > >> > drivers/vfio/pci/vfio_pci.c | 23 +++++++++++++++++++++-- > >> > drivers/vfio/pci/vfio_pci_private.h | 2 ++ > >> > include/linux/vfio.h | 3 +++ > >> > 3 files changed, 26 insertions(+), 2 deletions(-) > >> > > >> > diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c > >> > index 290b7ab55ecf..30137c1c5308 100644 > >> > --- a/drivers/vfio/pci/vfio_pci.c > >> > +++ b/drivers/vfio/pci/vfio_pci.c > >> > @@ -105,6 +105,24 @@ void *vfio_pci_vendor_data(void *device_data) > >> > } > >> > EXPORT_SYMBOL_GPL(vfio_pci_vendor_data); > >> > > >> > +int vfio_pci_set_vendor_regions(void *device_data, int num_vendor_regions) > >> > +{ > >> > + struct vfio_pci_device *vdev = device_data; > >> > + > >> > + vdev->num_vendor_regions = num_vendor_regions; > >> > >> Do we need any kind of sanity check here, in case this is called with a > >> bogus value? > >> > > you are right. it at least needs to be >=0. > > maybe type of "unsigned int" is more appropriate for num_vendor_regions. > > we don't need to check its max value as QEMU would check it. > > That seems like a bad precedent - the caller may not be QEMU. > but the caller has to query that through vfio_pci_ioctl() and at there info.num_regions = VFIO_PCI_NUM_REGIONS + vdev->num_regions + vdev->num_vendor_regions; info.num_regions is of type __u32. Thanks Yan