public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* ioeventfd usage in KVM
@ 2010-03-12  5:08 Cam Macdonell
  2010-03-12  7:43 ` Avi Kivity
  0 siblings, 1 reply; 4+ messages in thread
From: Cam Macdonell @ 2010-03-12  5:08 UTC (permalink / raw)
  To: KVM General

Hi,

I'm trying to use ioeventfd/irqfds for my shared memory patch.  I
followed the usage in the vhost-net patches to see how it's setup for
virtio-pci and tried to follow it as closely as I could. Despite the
call to kvm_vm_ioctl() returning 0, any writes to the assigned 4-byte
memory area do not seem to trigger a write to the corresponding fd.
At this point, I'm just trying to get the ioeventfd happening.

I notice that virtio-pci allocates it's BAR as
PCI_BASE_ADDRESS_SPACE_IO and then uses register_ioport_{read,write}
whereas I use cpu_register_io_memory and the
PCI_BASE_ADDRESS_SPACE_MEMORY type as shown below.

+static void ivshmem_mmio_map(PCIDevice *pci_dev, int region_num,
+                       pcibus_t addr, pcibus_t size, int type)
+{
+    PCI_IVShmemState *d = (PCI_IVShmemState *)pci_dev;
+    IVShmemState *s = &d->ivshmem_state;
+
+    s->otheraddr = addr  /* this address will be used for the ioeventfd*/
+    cpu_register_physical_memory(addr + 0, 0x100, s->ivshmem_mmio_io_addr);
+}


+    s->ivshmem_mmio_io_addr = cpu_register_io_memory(ivshmem_mmio_read,
+                                    ivshmem_mmio_write, s);
+    /* region for registers*/
+    pci_register_bar(&d->dev, 0, 0x100,
+                           PCI_BASE_ADDRESS_SPACE_MEMORY, ivshmem_mmio_map);

my basic attempt looks like this:

    struct kvm_ioeventfd ked;

    ked.addr = s->otheraddr + Doorbell;
    ked.len = 4;
    ked.flags = KVM_IOEVENTFD_FLAG_PIO;
    ked.fd = an_eventfd;
    ret = kvm_vm_ioctl(kvm_state, KVM_IOEVENTFD, &ked);

but when the guest writes to the offset of Doorbell, I cannot see any
action (via a select on the fd).  Is there something obviously wrong
that I'm doing?

When I get this working, I'd be happy to write up a page for the KVM site.

Thanks,
Cam

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-03-12 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-12  5:08 ioeventfd usage in KVM Cam Macdonell
2010-03-12  7:43 ` Avi Kivity
2010-03-12 15:50   ` Cam Macdonell
2010-03-12 16:43     ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox