aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Philippe Brucker <jean-philippe.brucker@arm.com>2022-07-01 15:24:27 +0100
committerWill Deacon <will@kernel.org>2022-07-01 16:09:00 +0100
commitde166e5f7edc93de3189c6848c40b39a4ac11a93 (patch)
tree5314f2d9936a541214c65be63eb434f5c27b07d2
parent73fd13686e2276f9ea3b2e47bdb92c2d73752daa (diff)
downloadkvmtool-de166e5f7edc93de3189c6848c40b39a4ac11a93.tar.gz
virtio/net: Set vhost backend after queue address
We currently call VHOST_SET_BACKEND from notify_vq_gsi(), which can't work with modern virtio because vhost checks that the virtqueue is accessible when handling VHOST_SET_BACKEND, and the modern driver initializes the MSIs before setting up the virtqueue. Move VHOST_SET_BACKEND to init_vq(). Signed-off-by: Jean-Philippe Brucker <jean-philippe.brucker@arm.com> Link: https://lore.kernel.org/r/20220701142434.75170-6-jean-philippe.brucker@arm.com Signed-off-by: Will Deacon <will@kernel.org>
-rw-r--r--virtio/net.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/virtio/net.c b/virtio/net.c
index f8c40d40..dcf9210d 100644
--- a/virtio/net.c
+++ b/virtio/net.c
@@ -601,6 +601,7 @@ static bool is_ctrl_vq(struct net_dev *ndev, u32 vq)
static int init_vq(struct kvm *kvm, void *dev, u32 vq)
{
struct vhost_vring_state state = { .index = vq };
+ struct vhost_vring_file file = { .index = vq };
struct net_dev_queue *net_queue;
struct vhost_vring_addr addr;
struct net_dev *ndev = dev;
@@ -656,6 +657,11 @@ static int init_vq(struct kvm *kvm, void *dev, u32 vq)
if (r < 0)
die_perror("VHOST_SET_VRING_ADDR failed");
+ file.fd = ndev->tap_fd;
+ r = ioctl(ndev->vhost_fd, VHOST_NET_SET_BACKEND, &file);
+ if (r < 0)
+ die_perror("VHOST_NET_SET_BACKEND failed");
+
return 0;
}
@@ -713,11 +719,6 @@ static void notify_vq_gsi(struct kvm *kvm, void *dev, u32 vq, u32 gsi)
r = ioctl(ndev->vhost_fd, VHOST_SET_VRING_CALL, &file);
if (r < 0)
die_perror("VHOST_SET_VRING_CALL failed");
- file.fd = ndev->tap_fd;
- r = ioctl(ndev->vhost_fd, VHOST_NET_SET_BACKEND, &file);
- if (r != 0)
- die("VHOST_NET_SET_BACKEND failed %d", errno);
-
}
static void notify_vq_eventfd(struct kvm *kvm, void *dev, u32 vq, u32 efd)