]> Git Repo - linux.git/commitdiff
Merge tag 'vfio-v6.0-rc1' of https://github.com/awilliam/linux-vfio
authorLinus Torvalds <[email protected]>
Sat, 6 Aug 2022 15:59:35 +0000 (08:59 -0700)
committerLinus Torvalds <[email protected]>
Sat, 6 Aug 2022 15:59:35 +0000 (08:59 -0700)
Pull VFIO updates from Alex Williamson:

 - Cleanup use of extern in function prototypes (Alex Williamson)

 - Simplify bus_type usage and convert to device IOMMU interfaces (Robin
   Murphy)

 - Check missed return value and fix comment typos (Bo Liu)

 - Split migration ops from device ops and fix races in mlx5 migration
   support (Yishai Hadas)

 - Fix missed return value check in noiommu support (Liam Ni)

 - Hardening to clear buffer pointer to avoid use-after-free (Schspa
   Shi)

 - Remove requirement that only the same mm can unmap a previously
   mapped range (Li Zhe)

 - Adjust semaphore release vs device open counter (Yi Liu)

 - Remove unused arg from SPAPR support code (Deming Wang)

 - Rework vfio-ccw driver to better fit new mdev framework (Eric Farman,
   Michael Kawano)

 - Replace DMA unmap notifier with callbacks (Jason Gunthorpe)

 - Clarify SPAPR support comment relative to iommu_ops (Alexey
   Kardashevskiy)

 - Revise page pinning API towards compatibility with future iommufd
   support (Nicolin Chen)

 - Resolve issues in vfio-ccw, including use of DMA unmap callback (Eric
   Farman)

* tag 'vfio-v6.0-rc1' of https://github.com/awilliam/linux-vfio: (40 commits)
  vfio/pci: fix the wrong word
  vfio/ccw: Check return code from subchannel quiesce
  vfio/ccw: Remove FSM Close from remove handlers
  vfio/ccw: Add length to DMA_UNMAP checks
  vfio: Replace phys_pfn with pages for vfio_pin_pages()
  vfio/ccw: Add kmap_local_page() for memcpy
  vfio: Rename user_iova of vfio_dma_rw()
  vfio/ccw: Change pa_pfn list to pa_iova list
  vfio/ap: Change saved_pfn to saved_iova
  vfio: Pass in starting IOVA to vfio_pin/unpin_pages API
  vfio/ccw: Only pass in contiguous pages
  vfio/ap: Pass in physical address of ind to ap_aqic()
  drm/i915/gvt: Replace roundup with DIV_ROUND_UP
  vfio: Make vfio_unpin_pages() return void
  vfio/spapr_tce: Fix the comment
  vfio: Replace the iommu notifier with a device list
  vfio: Replace the DMA unmapping notifier with a callback
  vfio/ccw: Move FSM open/close to MDEV open/close
  vfio/ccw: Refactor vfio_ccw_mdev_reset
  vfio/ccw: Create a CLOSE FSM event
  ...

1  2 
Documentation/driver-api/vfio-mediated-device.rst
drivers/vfio/pci/vfio_pci_core.c
drivers/vfio/vfio.c
include/linux/vfio_pci_core.h

index 66bd00d7aecff4711f31259223a3e28871fee80b,ba5fefcdae1ab1f5e5ed7f7deb9ccc1d8bd4441b..f47dca6645aae6aa483a87ce03914ab0c340d049
@@@ -1,4 -1,3 +1,4 @@@
 +.. SPDX-License-Identifier: GPL-2.0-only
  .. include:: <isonum.txt>
  
  =====================
@@@ -9,6 -8,9 +9,6 @@@ VFIO Mediated device
  :Author: Neo Jia <[email protected]>
  :Author: Kirti Wankhede <[email protected]>
  
 -This program is free software; you can redistribute it and/or modify
 -it under the terms of the GNU General Public License version 2 as
 -published by the Free Software Foundation.
  
  
  Virtual Function I/O (VFIO) Mediated devices[1]
@@@ -112,11 -114,11 +112,11 @@@ to register and unregister itself with 
  
  * Register::
  
-     extern int  mdev_register_driver(struct mdev_driver *drv);
+     int mdev_register_driver(struct mdev_driver *drv);
  
  * Unregister::
  
-     extern void mdev_unregister_driver(struct mdev_driver *drv);
+     void mdev_unregister_driver(struct mdev_driver *drv);
  
  The mediated bus driver's probe function should create a vfio_device on top of
  the mdev_device and connect it to an appropriate implementation of
@@@ -125,8 -127,8 +125,8 @@@ vfio_device_ops
  When a driver wants to add the GUID creation sysfs to an existing device it has
  probe'd to then it should call::
  
-       extern int  mdev_register_device(struct device *dev,
-                                        struct mdev_driver *mdev_driver);
+     int mdev_register_device(struct device *dev,
+                              struct mdev_driver *mdev_driver);
  
  This will provide the 'mdev_supported_types/XX/create' files which can then be
  used to trigger the creation of a mdev_device. The created mdev_device will be
@@@ -134,7 -136,7 +134,7 @@@ attached to the specified driver
  
  When the driver needs to remove itself it calls::
  
-       extern void mdev_unregister_device(struct device *dev);
+     void mdev_unregister_device(struct device *dev);
  
  Which will unbind and destroy all the created mdevs and remove the sysfs files.
  
@@@ -260,10 -262,10 +260,10 @@@ Translation APIs for Mediated Device
  The following APIs are provided for translating user pfn to host pfn in a VFIO
  driver::
  
-       int vfio_pin_pages(struct vfio_device *device, unsigned long *user_pfn,
-                                 int npage, int prot, unsigned long *phys_pfn);
+       int vfio_pin_pages(struct vfio_device *device, dma_addr_t iova,
+                                 int npage, int prot, struct page **pages);
  
-       int vfio_unpin_pages(struct vfio_device *device, unsigned long *user_pfn,
+       void vfio_unpin_pages(struct vfio_device *device, dma_addr_t iova,
                                    int npage);
  
  These functions call back into the back-end IOMMU module by using the pin_pages
index 0d8d4cdfb2f03d6fedea3f607ad1cf1f864440d6,2efa06b1fafaa6fbdb8cdac100adf38add6fa98b..c8d3b0450fb35b5a1f615545ca72d5264833fc0f
@@@ -10,7 -10,6 +10,7 @@@
  
  #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  
 +#include <linux/aperture.h>
  #include <linux/device.h>
  #include <linux/eventfd.h>
  #include <linux/file.h>
@@@ -317,14 -316,10 +317,14 @@@ int vfio_pci_core_enable(struct vfio_pc
                pci_write_config_word(pdev, PCI_COMMAND, cmd);
        }
  
 -      ret = vfio_config_init(vdev);
 +      ret = vfio_pci_zdev_open_device(vdev);
        if (ret)
                goto out_free_state;
  
 +      ret = vfio_config_init(vdev);
 +      if (ret)
 +              goto out_free_zdev;
 +
        msix_pos = pdev->msix_cap;
        if (msix_pos) {
                u16 flags;
  
        return 0;
  
 +out_free_zdev:
 +      vfio_pci_zdev_close_device(vdev);
  out_free_state:
        kfree(vdev->pci_saved_state);
        vdev->pci_saved_state = NULL;
@@@ -425,8 -418,6 +425,8 @@@ void vfio_pci_core_disable(struct vfio_
  
        vdev->needs_reset = true;
  
 +      vfio_pci_zdev_close_device(vdev);
 +
        /*
         * If we have saved state, restore it.  If we can reset the device,
         * even better.  Resetting with current state seems better than
@@@ -1802,10 -1793,6 +1802,10 @@@ static int vfio_pci_vga_init(struct vfi
        if (!vfio_pci_is_vga(pdev))
                return 0;
  
 +      ret = aperture_remove_conflicting_pci_devices(pdev, vdev->vdev.ops->name);
 +      if (ret)
 +              return ret;
 +
        ret = vga_client_register(pdev, vfio_pci_set_decode);
        if (ret)
                return ret;
@@@ -1868,6 -1855,13 +1868,13 @@@ int vfio_pci_core_register_device(struc
        if (pdev->hdr_type != PCI_HEADER_TYPE_NORMAL)
                return -EINVAL;
  
+       if (vdev->vdev.mig_ops) {
+               if (!(vdev->vdev.mig_ops->migration_get_state &&
+                     vdev->vdev.mig_ops->migration_set_state) ||
+                   !(vdev->vdev.migration_flags & VFIO_MIGRATION_STOP_COPY))
+                       return -EINVAL;
+       }
        /*
         * Prevent binding to PFs with VFs enabled, the VFs might be in use
         * by the host or other users.  We cannot capture the VFs if they
diff --combined drivers/vfio/vfio.c
index 521a3eabf0e1db66b9b4bc807fa1c0d3935d6380,8e23ca59ceed472750052d76a65f167635336ea6..7cb56c382c97a25c8634b44148ea77bbdf228fff
@@@ -231,6 -231,9 +231,9 @@@ int vfio_register_iommu_driver(const st
  {
        struct vfio_iommu_driver *driver, *tmp;
  
+       if (WARN_ON(!ops->register_device != !ops->unregister_device))
+               return -EINVAL;
        driver = kzalloc(sizeof(*driver), GFP_KERNEL);
        if (!driver)
                return -ENOMEM;
@@@ -504,7 -507,9 +507,9 @@@ static struct vfio_group *vfio_noiommu_
        if (IS_ERR(iommu_group))
                return ERR_CAST(iommu_group);
  
-       iommu_group_set_name(iommu_group, "vfio-noiommu");
+       ret = iommu_group_set_name(iommu_group, "vfio-noiommu");
+       if (ret)
+               goto out_put_group;
        ret = iommu_group_add_device(iommu_group, dev);
        if (ret)
                goto out_put_group;
@@@ -549,16 -554,6 +554,16 @@@ static struct vfio_group *vfio_group_fi
        if (!iommu_group)
                return ERR_PTR(-EINVAL);
  
-       if (!iommu_capable(dev->bus, IOMMU_CAP_CACHE_COHERENCY)) {
 +      /*
 +       * VFIO always sets IOMMU_CACHE because we offer no way for userspace to
 +       * restore cache coherency. It has to be checked here because it is only
 +       * valid for cases where we are using iommu groups.
 +       */
++      if (!device_iommu_capable(dev, IOMMU_CAP_CACHE_COHERENCY)) {
 +              iommu_group_put(iommu_group);
 +              return ERR_PTR(-EINVAL);
 +      }
 +
        group = vfio_group_get_from_iommu(iommu_group);
        if (!group)
                group = vfio_create_group(iommu_group, VFIO_IOMMU);
@@@ -611,6 -606,13 +616,6 @@@ static int __vfio_register_dev(struct v
  
  int vfio_register_group_dev(struct vfio_device *device)
  {
 -      /*
 -       * VFIO always sets IOMMU_CACHE because we offer no way for userspace to
 -       * restore cache coherency.
 -       */
 -      if (!device_iommu_capable(device->dev, IOMMU_CAP_CACHE_COHERENCY))
 -              return -EINVAL;
 -
        return __vfio_register_dev(device,
                vfio_group_find_or_alloc(device->dev));
  }
@@@ -1082,6 -1084,7 +1087,7 @@@ static void vfio_device_unassign_contai
  
  static struct file *vfio_device_open(struct vfio_device *device)
  {
+       struct vfio_iommu_driver *iommu_driver;
        struct file *filep;
        int ret;
  
                        if (ret)
                                goto err_undo_count;
                }
+               iommu_driver = device->group->container->iommu_driver;
+               if (iommu_driver && iommu_driver->ops->register_device)
+                       iommu_driver->ops->register_device(
+                               device->group->container->iommu_data, device);
                up_read(&device->group->group_rwsem);
        }
        mutex_unlock(&device->dev_set->lock);
         * Appears to be missing by lack of need rather than
         * explicitly prevented.  Now there's need.
         */
 -      filep->f_mode |= (FMODE_LSEEK | FMODE_PREAD | FMODE_PWRITE);
 +      filep->f_mode |= (FMODE_PREAD | FMODE_PWRITE);
  
        if (device->group->type == VFIO_NO_IOMMU)
                dev_warn(device->dev, "vfio-noiommu device opened by user "
  err_close_device:
        mutex_lock(&device->dev_set->lock);
        down_read(&device->group->group_rwsem);
-       if (device->open_count == 1 && device->ops->close_device)
+       if (device->open_count == 1 && device->ops->close_device) {
                device->ops->close_device(device);
+               iommu_driver = device->group->container->iommu_driver;
+               if (iommu_driver && iommu_driver->ops->unregister_device)
+                       iommu_driver->ops->unregister_device(
+                               device->group->container->iommu_data, device);
+       }
  err_undo_count:
+       up_read(&device->group->group_rwsem);
        device->open_count--;
        if (device->open_count == 0 && device->kvm)
                device->kvm = NULL;
-       up_read(&device->group->group_rwsem);
        mutex_unlock(&device->dev_set->lock);
        module_put(device->dev->driver->owner);
  err_unassign_container:
@@@ -1342,12 -1357,18 +1360,18 @@@ static const struct file_operations vfi
  static int vfio_device_fops_release(struct inode *inode, struct file *filep)
  {
        struct vfio_device *device = filep->private_data;
+       struct vfio_iommu_driver *iommu_driver;
  
        mutex_lock(&device->dev_set->lock);
        vfio_assert_device_open(device);
        down_read(&device->group->group_rwsem);
        if (device->open_count == 1 && device->ops->close_device)
                device->ops->close_device(device);
+       iommu_driver = device->group->container->iommu_driver;
+       if (iommu_driver && iommu_driver->ops->unregister_device)
+               iommu_driver->ops->unregister_device(
+                       device->group->container->iommu_data, device);
        up_read(&device->group->group_rwsem);
        device->open_count--;
        if (device->open_count == 0)
@@@ -1544,8 -1565,7 +1568,7 @@@ vfio_ioctl_device_feature_mig_device_st
        struct file *filp = NULL;
        int ret;
  
-       if (!device->ops->migration_set_state ||
-           !device->ops->migration_get_state)
+       if (!device->mig_ops)
                return -ENOTTY;
  
        ret = vfio_check_feature(flags, argsz,
        if (flags & VFIO_DEVICE_FEATURE_GET) {
                enum vfio_device_mig_state curr_state;
  
-               ret = device->ops->migration_get_state(device, &curr_state);
+               ret = device->mig_ops->migration_get_state(device,
+                                                          &curr_state);
                if (ret)
                        return ret;
                mig.device_state = curr_state;
        }
  
        /* Handle the VFIO_DEVICE_FEATURE_SET */
-       filp = device->ops->migration_set_state(device, mig.device_state);
+       filp = device->mig_ops->migration_set_state(device, mig.device_state);
        if (IS_ERR(filp) || !filp)
                goto out_copy;
  
@@@ -1592,8 -1613,7 +1616,7 @@@ static int vfio_ioctl_device_feature_mi
        };
        int ret;
  
-       if (!device->ops->migration_set_state ||
-           !device->ops->migration_get_state)
+       if (!device->mig_ops)
                return -ENOTTY;
  
        ret = vfio_check_feature(flags, argsz, VFIO_DEVICE_FEATURE_GET,
@@@ -1815,6 -1835,7 +1838,7 @@@ struct vfio_info_cap_header *vfio_info_
        buf = krealloc(caps->buf, caps->size + size, GFP_KERNEL);
        if (!buf) {
                kfree(caps->buf);
+               caps->buf = NULL;
                caps->size = 0;
                return ERR_PTR(-ENOMEM);
        }
@@@ -1913,26 -1934,25 +1937,25 @@@ int vfio_set_irqs_validate_and_prepare(
  EXPORT_SYMBOL(vfio_set_irqs_validate_and_prepare);
  
  /*
-  * Pin a set of guest PFNs and return their associated host PFNs for local
+  * Pin contiguous user pages and return their associated host pages for local
   * domain only.
   * @device [in]  : device
-  * @user_pfn [in]: array of user/guest PFNs to be pinned.
-  * @npage [in]   : count of elements in user_pfn array.  This count should not
-  *               be greater VFIO_PIN_PAGES_MAX_ENTRIES.
+  * @iova [in]    : starting IOVA of user pages to be pinned.
+  * @npage [in]   : count of pages to be pinned.  This count should not
+  *               be greater than VFIO_PIN_PAGES_MAX_ENTRIES.
   * @prot [in]    : protection flags
-  * @phys_pfn[out]: array of host PFNs
+  * @pages[out]   : array of host pages
   * Return error or number of pages pinned.
   */
- int vfio_pin_pages(struct vfio_device *device, unsigned long *user_pfn,
-                  int npage, int prot, unsigned long *phys_pfn)
+ int vfio_pin_pages(struct vfio_device *device, dma_addr_t iova,
+                  int npage, int prot, struct page **pages)
  {
        struct vfio_container *container;
        struct vfio_group *group = device->group;
        struct vfio_iommu_driver *driver;
        int ret;
  
-       if (!user_pfn || !phys_pfn || !npage ||
-           !vfio_assert_device_open(device))
+       if (!pages || !npage || !vfio_assert_device_open(device))
                return -EINVAL;
  
        if (npage > VFIO_PIN_PAGES_MAX_ENTRIES)
        driver = container->iommu_driver;
        if (likely(driver && driver->ops->pin_pages))
                ret = driver->ops->pin_pages(container->iommu_data,
-                                            group->iommu_group, user_pfn,
-                                            npage, prot, phys_pfn);
+                                            group->iommu_group, iova,
+                                            npage, prot, pages);
        else
                ret = -ENOTTY;
  
  EXPORT_SYMBOL(vfio_pin_pages);
  
  /*
-  * Unpin set of host PFNs for local domain only.
+  * Unpin contiguous host pages for local domain only.
   * @device [in]  : device
-  * @user_pfn [in]: array of user/guest PFNs to be unpinned. Number of user/guest
-  *               PFNs should not be greater than VFIO_PIN_PAGES_MAX_ENTRIES.
-  * @npage [in]   : count of elements in user_pfn array.  This count should not
+  * @iova [in]    : starting address of user pages to be unpinned.
+  * @npage [in]   : count of pages to be unpinned.  This count should not
   *                 be greater than VFIO_PIN_PAGES_MAX_ENTRIES.
-  * Return error or number of pages unpinned.
   */
- int vfio_unpin_pages(struct vfio_device *device, unsigned long *user_pfn,
-                    int npage)
+ void vfio_unpin_pages(struct vfio_device *device, dma_addr_t iova, int npage)
  {
        struct vfio_container *container;
        struct vfio_iommu_driver *driver;
-       int ret;
  
-       if (!user_pfn || !npage || !vfio_assert_device_open(device))
-               return -EINVAL;
+       if (WARN_ON(npage <= 0 || npage > VFIO_PIN_PAGES_MAX_ENTRIES))
+               return;
  
-       if (npage > VFIO_PIN_PAGES_MAX_ENTRIES)
-               return -E2BIG;
+       if (WARN_ON(!vfio_assert_device_open(device)))
+               return;
  
        /* group->container cannot change while a vfio device is open */
        container = device->group->container;
        driver = container->iommu_driver;
-       if (likely(driver && driver->ops->unpin_pages))
-               ret = driver->ops->unpin_pages(container->iommu_data, user_pfn,
-                                              npage);
-       else
-               ret = -ENOTTY;
  
-       return ret;
+       driver->ops->unpin_pages(container->iommu_data, iova, npage);
  }
  EXPORT_SYMBOL(vfio_unpin_pages);
  
   * not a real device DMA, it is not necessary to pin the user space memory.
   *
   * @device [in]               : VFIO device
-  * @user_iova [in]    : base IOVA of a user space buffer
+  * @iova [in]         : base IOVA of a user space buffer
   * @data [in]         : pointer to kernel buffer
   * @len [in]          : kernel buffer length
   * @write             : indicate read or write
   * Return error code on failure or 0 on success.
   */
- int vfio_dma_rw(struct vfio_device *device, dma_addr_t user_iova, void *data,
+ int vfio_dma_rw(struct vfio_device *device, dma_addr_t iova, void *data,
                size_t len, bool write)
  {
        struct vfio_container *container;
  
        if (likely(driver && driver->ops->dma_rw))
                ret = driver->ops->dma_rw(container->iommu_data,
-                                         user_iova, data, len, write);
+                                         iova, data, len, write);
        else
                ret = -ENOTTY;
        return ret;
  }
  EXPORT_SYMBOL(vfio_dma_rw);
  
- static int vfio_register_iommu_notifier(struct vfio_group *group,
-                                       unsigned long *events,
-                                       struct notifier_block *nb)
- {
-       struct vfio_container *container;
-       struct vfio_iommu_driver *driver;
-       int ret;
-       lockdep_assert_held_read(&group->group_rwsem);
-       container = group->container;
-       driver = container->iommu_driver;
-       if (likely(driver && driver->ops->register_notifier))
-               ret = driver->ops->register_notifier(container->iommu_data,
-                                                    events, nb);
-       else
-               ret = -ENOTTY;
-       return ret;
- }
- static int vfio_unregister_iommu_notifier(struct vfio_group *group,
-                                         struct notifier_block *nb)
- {
-       struct vfio_container *container;
-       struct vfio_iommu_driver *driver;
-       int ret;
-       lockdep_assert_held_read(&group->group_rwsem);
-       container = group->container;
-       driver = container->iommu_driver;
-       if (likely(driver && driver->ops->unregister_notifier))
-               ret = driver->ops->unregister_notifier(container->iommu_data,
-                                                      nb);
-       else
-               ret = -ENOTTY;
-       return ret;
- }
- int vfio_register_notifier(struct vfio_device *device,
-                          enum vfio_notify_type type, unsigned long *events,
-                          struct notifier_block *nb)
- {
-       struct vfio_group *group = device->group;
-       int ret;
-       if (!nb || !events || (*events == 0) ||
-           !vfio_assert_device_open(device))
-               return -EINVAL;
-       switch (type) {
-       case VFIO_IOMMU_NOTIFY:
-               ret = vfio_register_iommu_notifier(group, events, nb);
-               break;
-       default:
-               ret = -EINVAL;
-       }
-       return ret;
- }
- EXPORT_SYMBOL(vfio_register_notifier);
- int vfio_unregister_notifier(struct vfio_device *device,
-                            enum vfio_notify_type type,
-                            struct notifier_block *nb)
- {
-       struct vfio_group *group = device->group;
-       int ret;
-       if (!nb || !vfio_assert_device_open(device))
-               return -EINVAL;
-       switch (type) {
-       case VFIO_IOMMU_NOTIFY:
-               ret = vfio_unregister_iommu_notifier(group, nb);
-               break;
-       default:
-               ret = -EINVAL;
-       }
-       return ret;
- }
- EXPORT_SYMBOL(vfio_unregister_notifier);
  /*
   * Module/class support
   */
@@@ -2159,13 -2086,17 +2089,17 @@@ static int __init vfio_init(void
        if (ret)
                goto err_alloc_chrdev;
  
-       pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
  #ifdef CONFIG_VFIO_NOIOMMU
-       vfio_register_iommu_driver(&vfio_noiommu_ops);
+       ret = vfio_register_iommu_driver(&vfio_noiommu_ops);
  #endif
+       if (ret)
+               goto err_driver_register;
+       pr_info(DRIVER_DESC " version: " DRIVER_VERSION "\n");
        return 0;
  
+ err_driver_register:
+       unregister_chrdev_region(vfio.group_devt, MINORMASK + 1);
  err_alloc_chrdev:
        class_destroy(vfio.class);
        vfio.class = NULL;
index d5d9e17f01562b51dbe282aaac3ef014c2669d70,22de2bce63940bd86d453d44c5bbeaed3fdb3459..5579ece4347bdc5427905027615f570796c9d015
@@@ -147,23 -147,23 +147,23 @@@ struct vfio_pci_core_device 
  #define is_irq_none(vdev) (!(is_intx(vdev) || is_msi(vdev) || is_msix(vdev)))
  #define irq_is(vdev, type) (vdev->irq_type == type)
  
extern void vfio_pci_intx_mask(struct vfio_pci_core_device *vdev);
extern void vfio_pci_intx_unmask(struct vfio_pci_core_device *vdev);
+ void vfio_pci_intx_mask(struct vfio_pci_core_device *vdev);
+ void vfio_pci_intx_unmask(struct vfio_pci_core_device *vdev);
  
extern int vfio_pci_set_irqs_ioctl(struct vfio_pci_core_device *vdev,
-                                  uint32_t flags, unsigned index,
-                                  unsigned start, unsigned count, void *data);
+ int vfio_pci_set_irqs_ioctl(struct vfio_pci_core_device *vdev,
+                           uint32_t flags, unsigned index,
+                           unsigned start, unsigned count, void *data);
  
extern ssize_t vfio_pci_config_rw(struct vfio_pci_core_device *vdev,
-                                 char __user *buf, size_t count,
-                                 loff_t *ppos, bool iswrite);
+ ssize_t vfio_pci_config_rw(struct vfio_pci_core_device *vdev,
+                          char __user *buf, size_t count,
+                          loff_t *ppos, bool iswrite);
  
extern ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __user *buf,
-                              size_t count, loff_t *ppos, bool iswrite);
+ ssize_t vfio_pci_bar_rw(struct vfio_pci_core_device *vdev, char __user *buf,
+                       size_t count, loff_t *ppos, bool iswrite);
  
  #ifdef CONFIG_VFIO_PCI_VGA
extern ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, char __user *buf,
-                              size_t count, loff_t *ppos, bool iswrite);
+ ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev, char __user *buf,
+                       size_t count, loff_t *ppos, bool iswrite);
  #else
  static inline ssize_t vfio_pci_vga_rw(struct vfio_pci_core_device *vdev,
                                      char __user *buf, size_t count,
  }
  #endif
  
extern long vfio_pci_ioeventfd(struct vfio_pci_core_device *vdev, loff_t offset,
-                              uint64_t data, int count, int fd);
+ long vfio_pci_ioeventfd(struct vfio_pci_core_device *vdev, loff_t offset,
+                       uint64_t data, int count, int fd);
  
extern int vfio_pci_init_perm_bits(void);
extern void vfio_pci_uninit_perm_bits(void);
+ int vfio_pci_init_perm_bits(void);
+ void vfio_pci_uninit_perm_bits(void);
  
extern int vfio_config_init(struct vfio_pci_core_device *vdev);
extern void vfio_config_free(struct vfio_pci_core_device *vdev);
+ int vfio_config_init(struct vfio_pci_core_device *vdev);
+ void vfio_config_free(struct vfio_pci_core_device *vdev);
  
extern int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev,
-                                       unsigned int type, unsigned int subtype,
-                                       const struct vfio_pci_regops *ops,
-                                       size_t size, u32 flags, void *data);
+ int vfio_pci_register_dev_region(struct vfio_pci_core_device *vdev,
+                                unsigned int type, unsigned int subtype,
+                                const struct vfio_pci_regops *ops,
+                                size_t size, u32 flags, void *data);
  
extern int vfio_pci_set_power_state(struct vfio_pci_core_device *vdev,
-                                   pci_power_t state);
+ int vfio_pci_set_power_state(struct vfio_pci_core_device *vdev,
+                            pci_power_t state);
  
- extern bool __vfio_pci_memory_enabled(struct vfio_pci_core_device *vdev);
- extern void vfio_pci_zap_and_down_write_memory_lock(struct vfio_pci_core_device
-                                                   *vdev);
- extern u16 vfio_pci_memory_lock_and_enable(struct vfio_pci_core_device *vdev);
- extern void vfio_pci_memory_unlock_and_restore(struct vfio_pci_core_device *vdev,
-                                              u16 cmd);
+ bool __vfio_pci_memory_enabled(struct vfio_pci_core_device *vdev);
+ void vfio_pci_zap_and_down_write_memory_lock(struct vfio_pci_core_device *vdev);
+ u16 vfio_pci_memory_lock_and_enable(struct vfio_pci_core_device *vdev);
+ void vfio_pci_memory_unlock_and_restore(struct vfio_pci_core_device *vdev,
+                                       u16 cmd);
  
  #ifdef CONFIG_VFIO_PCI_IGD
extern int vfio_pci_igd_init(struct vfio_pci_core_device *vdev);
+ int vfio_pci_igd_init(struct vfio_pci_core_device *vdev);
  #else
  static inline int vfio_pci_igd_init(struct vfio_pci_core_device *vdev)
  {
  }
  #endif
  
 -#ifdef CONFIG_S390
 +#ifdef CONFIG_VFIO_PCI_ZDEV_KVM
- extern int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
-                                      struct vfio_info_cap *caps);
+ int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
+                               struct vfio_info_cap *caps);
 +int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev);
 +void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev);
  #else
  static inline int vfio_pci_info_zdev_add_caps(struct vfio_pci_core_device *vdev,
                                              struct vfio_info_cap *caps)
  {
        return -ENODEV;
  }
 +
 +static inline int vfio_pci_zdev_open_device(struct vfio_pci_core_device *vdev)
 +{
 +      return 0;
 +}
 +
 +static inline void vfio_pci_zdev_close_device(struct vfio_pci_core_device *vdev)
 +{}
  #endif
  
  /* Will be exported for vfio pci drivers usage */
This page took 0.188859 seconds and 4 git commands to generate.