public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Yan Zhao <yan.y.zhao@intel.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
	cohuck@redhat.com, zhenyuw@linux.intel.com, zhi.a.wang@intel.com,
	kevin.tian@intel.com, shaopeng.he@intel.com, yi.l.liu@intel.com
Subject: Re: [RFC PATCH v3 6/9] vfio/pci: export vfio_pci_setup_barmap
Date: Thu, 20 Feb 2020 14:00:13 -0700	[thread overview]
Message-ID: <20200220140013.66a6b52c@w520.home> (raw)
In-Reply-To: <20200211101419.21067-1-yan.y.zhao@intel.com>

On Tue, 11 Feb 2020 05:14:19 -0500
Yan Zhao <yan.y.zhao@intel.com> wrote:

> This allows vendor driver to read/write to bars directly which is useful
> in security checking condition.
> 
> Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
> ---
>  drivers/vfio/pci/vfio_pci_rdwr.c | 26 +++++++++++++-------------
>  include/linux/vfio.h             |  2 ++
>  2 files changed, 15 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_rdwr.c b/drivers/vfio/pci/vfio_pci_rdwr.c
> index a0ef1de4f74a..3ba85fb2af5b 100644
> --- a/drivers/vfio/pci/vfio_pci_rdwr.c
> +++ b/drivers/vfio/pci/vfio_pci_rdwr.c
> @@ -129,7 +129,7 @@ static ssize_t do_io_rw(void __iomem *io, char __user *buf,
>  	return done;
>  }
>  
> -static int vfio_pci_setup_barmap(struct vfio_pci_device *vdev, int bar)
> +void __iomem *vfio_pci_setup_barmap(struct vfio_pci_device *vdev, int bar)
>  {
>  	struct pci_dev *pdev = vdev->pdev;
>  	struct vfio_pci_device_private *priv = VDEV_TO_PRIV(vdev);
> @@ -137,22 +137,23 @@ static int vfio_pci_setup_barmap(struct vfio_pci_device *vdev, int bar)
>  	void __iomem *io;
>  
>  	if (priv->barmap[bar])
> -		return 0;
> +		return priv->barmap[bar];
>  
>  	ret = pci_request_selected_regions(pdev, 1 << bar, "vfio");
>  	if (ret)
> -		return ret;
> +		return NULL;
>  
>  	io = pci_iomap(pdev, bar, 0);
>  	if (!io) {
>  		pci_release_selected_regions(pdev, 1 << bar);
> -		return -ENOMEM;
> +		return NULL;
>  	}
>  
>  	priv->barmap[bar] = io;
>  
> -	return 0;
> +	return io;
>  }
> +EXPORT_SYMBOL_GPL(vfio_pci_setup_barmap);

This should instead become a vfio_pci_get_barmap() function that tests
for an optionally calls vfio_pci_setup_barmap before returning the
pointer.  I'm now willing to lose the better error returns in the
original.  Thanks,

Alex


  reply	other threads:[~2020-02-20 21:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11  9:57 [RFC PATCH v3 0/9] Introduce vendor ops in vfio-pci Yan Zhao
2020-02-11 10:10 ` [RFC PATCH v3 1/9] vfio/pci: export vfio_pci_device public and add vfio_pci_device_private Yan Zhao
2020-02-20 21:00   ` Alex Williamson
2020-02-21  6:19     ` Yan Zhao
2020-02-11 10:11 ` [RFC PATCH v3 2/9] vfio/pci: export functions in vfio_pci_ops Yan Zhao
2020-02-11 10:11 ` [RFC PATCH v3 3/9] vfio/pci: register/unregister vfio_pci_vendor_driver_ops Yan Zhao
2020-02-11 10:12 ` [RFC PATCH v3 4/9] vfio/pci: macros to generate module_init and module_exit for vendor modules Yan Zhao
2020-02-11 10:13 ` [RFC PATCH v3 5/9] vfio/pci: let vfio_pci know how many vendor regions are registered Yan Zhao
2020-02-11 10:14 ` [RFC PATCH v3 6/9] vfio/pci: export vfio_pci_setup_barmap Yan Zhao
2020-02-20 21:00   ` Alex Williamson [this message]
2020-02-21  6:20     ` Yan Zhao
2020-02-11 10:14 ` [RFC PATCH v3 7/9] samples/vfio-pci: add a sample vendor module of vfio-pci for IGD devices Yan Zhao
2020-02-11 10:15 ` [RFC PATCH v3 8/9] vfio: header for vfio live migration region Yan Zhao
2020-02-11 10:15 ` [RFC PATCH v3 9/9] i40e/vf_migration: vfio-pci vendor driver for VF live migration Yan Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200220140013.66a6b52c@w520.home \
    --to=alex.williamson@redhat.com \
    --cc=cohuck@redhat.com \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=shaopeng.he@intel.com \
    --cc=yan.y.zhao@intel.com \
    --cc=yi.l.liu@intel.com \
    --cc=zhenyuw@linux.intel.com \
    --cc=zhi.a.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox