From patchwork Mon Mar 2 19:03:44 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Williamson X-Patchwork-Id: 445407 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id AE5F614010F for ; Tue, 3 Mar 2015 06:05:39 +1100 (AEDT) Received: from localhost ([::1]:59005 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSVer-0006t7-Fr for incoming@patchwork.ozlabs.org; Mon, 02 Mar 2015 14:05:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSVd6-000422-Os for qemu-devel@nongnu.org; Mon, 02 Mar 2015 14:03:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSVd5-0003Hb-T7 for qemu-devel@nongnu.org; Mon, 02 Mar 2015 14:03:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32923) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSVd5-0003HR-Jk for qemu-devel@nongnu.org; Mon, 02 Mar 2015 14:03:47 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t22J3jNg026469 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 2 Mar 2015 14:03:45 -0500 Received: from gimli.home (ovpn-113-210.phx2.redhat.com [10.3.113.210]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t22J3i34014074; Mon, 2 Mar 2015 14:03:45 -0500 From: Alex Williamson To: qemu-devel@nongnu.org Date: Mon, 02 Mar 2015 12:03:44 -0700 Message-ID: <20150302190344.2706.47653.stgit@gimli.home> In-Reply-To: <20150302190237.2706.61507.stgit@gimli.home> References: <20150302190237.2706.61507.stgit@gimli.home> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: alex.williamson@redhat.com, Samuel Pitoiset Subject: [Qemu-devel] [PULL 3/4] vfio: allow to disable MMAP per device with -x-mmap=off option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: 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 Signed-off-by: Alex Williamson --- 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 4ff8cab..9db7d8d 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 3d3892c..0d1fb80 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;