Commit 0e1882a4 authored by Jean-Philippe Brucker's avatar Jean-Philippe Brucker Committed by Will Deacon
Browse files

virtio/pci: Register a single eventfd for vhost

Vhost supports a single eventfd as the kick mechanism. Registering a
second one will override the first. To ensure vhost works with our
virtio-pci, only register the kick eventfd that is used by the guest.

Fixes: a508ea95

 ("virtio/pci: Use port I/O for configuration registers by default")
Signed-off-by: default avatarJean-Philippe Brucker <jean-philippe.brucker@arm.com>
Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
parent ed83730f
...@@ -25,8 +25,8 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde ...@@ -25,8 +25,8 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde
{ {
struct ioevent ioevent; struct ioevent ioevent;
struct virtio_pci *vpci = vdev->virtio; struct virtio_pci *vpci = vdev->virtio;
int i, r, flags = 0; int r, flags = 0;
int fds[2]; int fd;
vpci->ioeventfds[vq] = (struct virtio_pci_ioevent_param) { vpci->ioeventfds[vq] = (struct virtio_pci_ioevent_param) {
.vdev = vdev, .vdev = vdev,
...@@ -50,7 +50,7 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde ...@@ -50,7 +50,7 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde
/* ioport */ /* ioport */
ioevent.io_addr = vpci->port_addr + VIRTIO_PCI_QUEUE_NOTIFY; ioevent.io_addr = vpci->port_addr + VIRTIO_PCI_QUEUE_NOTIFY;
ioevent.io_len = sizeof(u16); ioevent.io_len = sizeof(u16);
ioevent.fd = fds[0] = eventfd(0, 0); ioevent.fd = fd = eventfd(0, 0);
r = ioeventfd__add_event(&ioevent, flags | IOEVENTFD_FLAG_PIO); r = ioeventfd__add_event(&ioevent, flags | IOEVENTFD_FLAG_PIO);
if (r) if (r)
return r; return r;
...@@ -58,15 +58,13 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde ...@@ -58,15 +58,13 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde
/* mmio */ /* mmio */
ioevent.io_addr = vpci->mmio_addr + VIRTIO_PCI_QUEUE_NOTIFY; ioevent.io_addr = vpci->mmio_addr + VIRTIO_PCI_QUEUE_NOTIFY;
ioevent.io_len = sizeof(u16); ioevent.io_len = sizeof(u16);
ioevent.fd = fds[1] = eventfd(0, 0); ioevent.fd = eventfd(0, 0);
r = ioeventfd__add_event(&ioevent, flags); r = ioeventfd__add_event(&ioevent, flags);
if (r) if (r)
goto free_ioport_evt; goto free_ioport_evt;
if (vdev->ops->notify_vq_eventfd) if (vdev->ops->notify_vq_eventfd)
for (i = 0; i < 2; ++i) vdev->ops->notify_vq_eventfd(kvm, vpci->dev, vq, fd);
vdev->ops->notify_vq_eventfd(kvm, vpci->dev, vq,
fds[i]);
return 0; return 0;
free_ioport_evt: free_ioport_evt:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment