From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gonglei Subject: Re: [PATCH RFC 3/3] pci-testdev: add RO pages for ioeventfd Date: Sun, 30 Aug 2015 17:44:30 +0800 Message-ID: <55E2D07E.2010306@huawei.com> References: <1440926395-23540-1-git-send-email-mst@redhat.com> <1440926395-23540-4-git-send-email-mst@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Cc: pbonzini@redhat.com, Markus Armbruster , kvm@vger.kernel.org To: "Michael S. Tsirkin" , Return-path: In-Reply-To: <1440926395-23540-4-git-send-email-mst@redhat.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org Sender: qemu-devel-bounces+gceq-qemu-devel=gmane.org@nongnu.org List-Id: kvm.vger.kernel.org On 2015/8/30 17:20, Michael S. Tsirkin wrote: > 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); > + Do we need think about hotplugging pci-testdev ? If yes, then we should release some resources when hot-unplug a pci-testdev device: munmap(d->zero, ...) memory_region_del_subregion(&d->mbar, &d->mmio) ... Regards, -Gonglei > + 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; > From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53576) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVzAY-0003Br-3O for qemu-devel@nongnu.org; Sun, 30 Aug 2015 05:44:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZVzAU-000230-Sc for qemu-devel@nongnu.org; Sun, 30 Aug 2015 05:44:58 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:27427) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZVzAU-00021K-AD for qemu-devel@nongnu.org; Sun, 30 Aug 2015 05:44:54 -0400 Message-ID: <55E2D07E.2010306@huawei.com> Date: Sun, 30 Aug 2015 17:44:30 +0800 From: Gonglei MIME-Version: 1.0 References: <1440926395-23540-1-git-send-email-mst@redhat.com> <1440926395-23540-4-git-send-email-mst@redhat.com> In-Reply-To: <1440926395-23540-4-git-send-email-mst@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH RFC 3/3] pci-testdev: add RO pages for ioeventfd List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Cc: pbonzini@redhat.com, Markus Armbruster , kvm@vger.kernel.org On 2015/8/30 17:20, Michael S. Tsirkin wrote: > 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); > + Do we need think about hotplugging pci-testdev ? If yes, then we should release some resources when hot-unplug a pci-testdev device: munmap(d->zero, ...) memory_region_del_subregion(&d->mbar, &d->mmio) ... Regards, -Gonglei > + 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; >