]> git.proxmox.com Git - mirror_qemu.git/commitdiff
vfio: allow to disable MMAP per device with -x-mmap=off option
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Mon, 2 Mar 2015 18:38:55 +0000 (11:38 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Mon, 2 Mar 2015 18:38:55 +0000 (11:38 -0700)
Disabling MMAP support uses the slower read/write accesses but allows to
trace all MMIO accesses, which is not good for performance, but very
useful for reverse engineering PCI drivers. This option allows to
disable MMAP per device without a compile-time change.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
hw/vfio/common.c
hw/vfio/pci.c
include/hw/vfio/vfio-common.h

index 4ff8cab0df6a268545655f350f96a85803129f6f..9db7d8da17ad89d2796feb1f9666369bbb66b975 100644 (file)
@@ -493,7 +493,7 @@ int vfio_mmap_region(Object *obj, VFIORegion *region,
     int ret = 0;
     VFIODevice *vbasedev = region->vbasedev;
 
-    if (VFIO_ALLOW_MMAP && size && region->flags &
+    if (vbasedev->allow_mmap && size && region->flags &
         VFIO_REGION_INFO_FLAG_MMAP) {
         int prot = 0;
 
index 84e9d995aaf0ac4ab11ae84e1c67223db1412a1e..3c71de30235b4ca169d861f94d7a18fdb53d1514 100644 (file)
@@ -3456,6 +3456,7 @@ static Property vfio_pci_dev_properties[] = {
     DEFINE_PROP_BIT("x-vga", VFIOPCIDevice, features,
                     VFIO_FEATURE_ENABLE_VGA_BIT, false),
     DEFINE_PROP_INT32("bootindex", VFIOPCIDevice, bootindex, -1),
+    DEFINE_PROP_BOOL("x-mmap", VFIOPCIDevice, vbasedev.allow_mmap, true),
     /*
      * TODO - support passed fds... is this necessary?
      * DEFINE_PROP_STRING("vfiofd", VFIOPCIDevice, vfiofd_name),
index 3d3892cdf485665feb13fb486bce3d9c4a2d192b..0d1fb805bbf8d16d3f8756e69151fb287873e2ee 100644 (file)
@@ -36,7 +36,6 @@
 #endif
 
 /* Extra debugging, trap acceleration paths for more logging */
-#define VFIO_ALLOW_MMAP 1
 #define VFIO_ALLOW_KVM_INTX 1
 #define VFIO_ALLOW_KVM_MSI 1
 #define VFIO_ALLOW_KVM_MSIX 1
@@ -102,6 +101,7 @@ typedef struct VFIODevice {
     int type;
     bool reset_works;
     bool needs_reset;
+    bool allow_mmap;
     VFIODeviceOps *ops;
     unsigned int num_irqs;
     unsigned int num_regions;