From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33572) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQMFP-0003TQ-Qj for qemu-devel@nongnu.org; Tue, 24 Feb 2015 15:38:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQMFM-00054R-JO for qemu-devel@nongnu.org; Tue, 24 Feb 2015 15:38:27 -0500 Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]:57562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQMFM-00054J-CU for qemu-devel@nongnu.org; Tue, 24 Feb 2015 15:38:24 -0500 Received: by mail-wi0-f180.google.com with SMTP id h11so274191wiw.1 for ; Tue, 24 Feb 2015 12:38:22 -0800 (PST) From: Samuel Pitoiset Date: Tue, 24 Feb 2015 21:38:51 +0100 Message-Id: <1424810331-25657-1-git-send-email-samuel.pitoiset@gmail.com> Subject: [Qemu-devel] [PATCH] vfio: allow to disable MMAP per device with -x-mmap=off option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: alex.williamson@redhat.com, Samuel Pitoiset 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 --- hw/vfio/common.c | 2 +- hw/vfio/pci.c | 1 + include/hw/vfio/vfio-common.h | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/vfio/common.c b/hw/vfio/common.c index c5d1551..bb87974 100644 --- a/hw/vfio/common.c +++ b/hw/vfio/common.c @@ -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; diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c index 84e9d99..3c71de3 100644 --- a/hw/vfio/pci.c +++ b/hw/vfio/pci.c @@ -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), diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h index 5f3679b..be860ca 100644 --- a/include/hw/vfio/vfio-common.h +++ b/include/hw/vfio/vfio-common.h @@ -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; -- 2.3.0