From patchwork Sun Aug 30 09:20:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 7096951 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 690DFBEEC1 for ; Sun, 30 Aug 2015 09:20:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7E5220721 for ; Sun, 30 Aug 2015 09:20:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C68772071E for ; Sun, 30 Aug 2015 09:20:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753261AbbH3JUb (ORCPT ); Sun, 30 Aug 2015 05:20:31 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49803 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752989AbbH3JUa (ORCPT ); Sun, 30 Aug 2015 05:20:30 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (Postfix) with ESMTPS id D74FF8EA56; Sun, 30 Aug 2015 09:20:30 +0000 (UTC) Received: from redhat.com (ovpn-116-40.ams2.redhat.com [10.36.116.40]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id t7U9KRC8002877; Sun, 30 Aug 2015 05:20:28 -0400 Date: Sun, 30 Aug 2015 12:20:27 +0300 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, kvm@vger.kernel.org, Markus Armbruster , Gonglei Subject: [PATCH RFC 3/3] pci-testdev: add RO pages for ioeventfd Message-ID: <1440926395-23540-4-git-send-email-mst@redhat.com> References: <1440926395-23540-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1440926395-23540-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This seems hackish - would it be better to create this region automatically within kvm? Suggestions are welcome. Signed-off-by: Michael S. Tsirkin --- hw/misc/pci-testdev.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/misc/pci-testdev.c b/hw/misc/pci-testdev.c index 94141a3..55efc32 100644 --- a/hw/misc/pci-testdev.c +++ b/hw/misc/pci-testdev.c @@ -21,6 +21,7 @@ #include "hw/pci/pci.h" #include "qemu/event_notifier.h" #include "qemu/osdep.h" +#include typedef struct PCITestDevHdr { uint8_t test; @@ -82,11 +83,13 @@ typedef struct PCITestDevState { PCIDevice parent_obj; /*< public >*/ + MemoryRegion zeromr; MemoryRegion mmio; MemoryRegion mbar; MemoryRegion portio; IOTest *tests; int current; + void *zero; } PCITestDevState; #define TYPE_PCI_TEST_DEV "pci-testdev" @@ -242,6 +245,11 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp) uint8_t *pci_conf; char *name; int r, i; + d->zero = mmap(NULL, IOTEST_MEMSIZE * 2, PROT_READ, + MAP_SHARED | MAP_ANONYMOUS, -1, 0); + + memory_region_init_ram_ptr(&d->zeromr, OBJECT(d), "pci-testdev-zero", 0x1000, d->zero); + memory_region_set_readonly(&d->zeromr, true); pci_conf = pci_dev->config; @@ -286,6 +294,11 @@ static void pci_testdev_realize(PCIDevice *pci_dev, Error **errp) test->hasnotifier = false; continue; } + + if (test->hasnotifier && !test->size) { + memory_region_add_subregion_overlap(&d->mbar, le32_to_cpu(test->hdr->offset), + &d->zeromr, 2 /* prio */); + } r = event_notifier_init(&test->notifier, 0); assert(r >= 0); test->hasnotifier = true;