@@ -153,6 +153,16 @@ static int vfio_pci_setup_barmap(struct vfio_pci_device *vdev, int bar)
return 0;
}
+void __iomem *vfio_pci_get_barmap(void *device_data, int bar)
+{
+ int ret;
+ struct vfio_pci_device *vdev = device_data;
+
+ ret = vfio_pci_setup_barmap(vdev, bar);
+ return ret ? ERR_PTR(ret) : vdev->barmap[bar];
+}
+EXPORT_SYMBOL_GPL(vfio_pci_get_barmap);
+
ssize_t vfio_pci_bar_rw(struct vfio_pci_device *vdev, char __user *buf,
size_t count, loff_t *ppos, bool iswrite)
{
@@ -234,6 +234,7 @@ extern void *vfio_pci_vendor_data(void *device_data);
extern int vfio_pci_set_vendor_regions(void *device_data,
int num_vendor_regions);
extern int vfio_pci_set_vendor_irqs(void *device_data, int num_vendor_irqs);
+extern void __iomem *vfio_pci_get_barmap(void *device_data, int bar);
struct vfio_pci_vendor_driver_ops {
char *name;
This allows vendor driver to read/write to bars directly which is useful in security checking condition. Cc: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Yan Zhao <yan.y.zhao@intel.com> --- drivers/vfio/pci/vfio_pci_rdwr.c | 10 ++++++++++ include/linux/vfio.h | 1 + 2 files changed, 11 insertions(+)