[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200220140013.66a6b52c@w520.home>
Date: Thu, 20 Feb 2020 14:00:13 -0700
From: Alex Williamson <alex.williamson@...hat.com>
To: Yan Zhao <yan.y.zhao@...el.com>
Cc: kvm@...r.kernel.org, linux-kernel@...r.kernel.org,
cohuck@...hat.com, zhenyuw@...ux.intel.com, zhi.a.wang@...el.com,
kevin.tian@...el.com, shaopeng.he@...el.com, yi.l.liu@...el.com
Subject: Re: [RFC PATCH v3 6/9] vfio/pci: export vfio_pci_setup_barmap
On Tue, 11 Feb 2020 05:14:19 -0500
Yan Zhao <yan.y.zhao@...el.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@...el.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
Powered by blists - more mailing lists