aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>2022-07-01 15:24:26 +0100
committerWill Deacon <will@kernel.org>2022-07-01 16:09:00 +0100
commit73fd13686e2276f9ea3b2e47bdb92c2d73752daa (patch)
tree8ebae270665ba62953ec43ed3ac2257918d64487
parent21c9bc7440878fd341c26a32a068e045ff188e5c (diff)
downloadkvmtool-73fd13686e2276f9ea3b2e47bdb92c2d73752daa.tar.gz
virtio/pci: Use the correct eventfd for vhost notification
Legacy virtio drivers write to the I/O port BAR, and the modern virtio device uses the MMIO BAR. Since vhost can only listen on one ioeventfd, select the one that the guest will use. Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> Link: https://lore.kernel.org/r/20220701142434.75170-5-jean-philippe.brucker@arm.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--virtio/pci.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/virtio/pci.c b/virtio/pci.c
index c02534a6..320865c1 100644
--- a/virtio/pci.c
+++ b/virtio/pci.c
@@ -83,7 +83,7 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde
u16 port_addr = virtio_pci__port_addr(vpci);
off_t offset = vpci->doorbell_offset;
int r, flags = 0;
- int fd;
+ int pio_fd, mmio_fd;
vpci->ioeventfds[vq] = (struct virtio_pci_ioevent_param) {
.vdev = vdev,
@@ -107,7 +107,7 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde
/* ioport */
ioevent.io_addr = port_addr + offset;
ioevent.io_len = sizeof(u16);
- ioevent.fd = fd = eventfd(0, 0);
+ ioevent.fd = pio_fd = eventfd(0, 0);
r = ioeventfd__add_event(&ioevent, flags | IOEVENTFD_FLAG_PIO);
if (r)
return r;
@@ -115,13 +115,14 @@ static int virtio_pci__init_ioeventfd(struct kvm *kvm, struct virtio_device *vde
/* mmio */
ioevent.io_addr = mmio_addr + offset;
ioevent.io_len = sizeof(u16);
- ioevent.fd = eventfd(0, 0);
+ ioevent.fd = mmio_fd = eventfd(0, 0);
r = ioeventfd__add_event(&ioevent, flags);
if (r)
goto free_ioport_evt;
if (vdev->ops->notify_vq_eventfd)
- vdev->ops->notify_vq_eventfd(kvm, vpci->dev, vq, fd);
+ vdev->ops->notify_vq_eventfd(kvm, vpci->dev, vq,
+ vdev->legacy ? pio_fd : mmio_fd);
return 0;
free_ioport_evt: