Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  * Copyright (C) 2012 Red Hat, Inc.  All rights reserved.
0004  *     Author: Alex Williamson <alex.williamson@redhat.com>
0005  */
0006 
0007 enum vfio_group_type {
0008     /*
0009      * Physical device with IOMMU backing.
0010      */
0011     VFIO_IOMMU,
0012 
0013     /*
0014      * Virtual device without IOMMU backing. The VFIO core fakes up an
0015      * iommu_group as the iommu_group sysfs interface is part of the
0016      * userspace ABI.  The user of these devices must not be able to
0017      * directly trigger unmediated DMA.
0018      */
0019     VFIO_EMULATED_IOMMU,
0020 
0021     /*
0022      * Physical device without IOMMU backing. The VFIO core fakes up an
0023      * iommu_group as the iommu_group sysfs interface is part of the
0024      * userspace ABI.  Users can trigger unmediated DMA by the device,
0025      * usage is highly dangerous, requires an explicit opt-in and will
0026      * taint the kernel.
0027      */
0028     VFIO_NO_IOMMU,
0029 };
0030 
0031 /* events for the backend driver notify callback */
0032 enum vfio_iommu_notify_type {
0033     VFIO_IOMMU_CONTAINER_CLOSE = 0,
0034 };
0035 
0036 /**
0037  * struct vfio_iommu_driver_ops - VFIO IOMMU driver callbacks
0038  */
0039 struct vfio_iommu_driver_ops {
0040     char        *name;
0041     struct module   *owner;
0042     void        *(*open)(unsigned long arg);
0043     void        (*release)(void *iommu_data);
0044     long        (*ioctl)(void *iommu_data, unsigned int cmd,
0045                  unsigned long arg);
0046     int     (*attach_group)(void *iommu_data,
0047                     struct iommu_group *group,
0048                     enum vfio_group_type);
0049     void        (*detach_group)(void *iommu_data,
0050                     struct iommu_group *group);
0051     int     (*pin_pages)(void *iommu_data,
0052                      struct iommu_group *group,
0053                      dma_addr_t user_iova,
0054                      int npage, int prot,
0055                      struct page **pages);
0056     void        (*unpin_pages)(void *iommu_data,
0057                        dma_addr_t user_iova, int npage);
0058     void        (*register_device)(void *iommu_data,
0059                        struct vfio_device *vdev);
0060     void        (*unregister_device)(void *iommu_data,
0061                          struct vfio_device *vdev);
0062     int     (*dma_rw)(void *iommu_data, dma_addr_t user_iova,
0063                   void *data, size_t count, bool write);
0064     struct iommu_domain *(*group_iommu_domain)(void *iommu_data,
0065                            struct iommu_group *group);
0066     void        (*notify)(void *iommu_data,
0067                   enum vfio_iommu_notify_type event);
0068 };
0069 
0070 int vfio_register_iommu_driver(const struct vfio_iommu_driver_ops *ops);
0071 void vfio_unregister_iommu_driver(const struct vfio_iommu_driver_ops *ops);