All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vhost vdpa: setup vq irq only when set status includes VIRTIO_CONFIG_S_DRIVER_OK
@ 2021-02-15 14:04 Gautam Dawar
  0 siblings, 0 replies; only message in thread
From: Gautam Dawar @ 2021-02-15 14:04 UTC (permalink / raw)
  To: virtualization, jasowang, mst, gdawar, hanand, martinh


[-- Attachment #1.1: Type: text/plain, Size: 1447 bytes --]

When qemu with vhost-vdpa netdevice is run for the first time, it works
well.
But after the VM is powered off, the next qemu run causes kernel panic due
to a
NULL pointer dereference in irq_bypass_register_producer().

When the VM is powered off, vhost_dev_stop() is invoked which in turn calls
vhost_vdpa_reset_device() causing the irq_bypass producers to be
unregistered.

On the next run, when qemu opens the vhost device, the vhost_vdpa_open()
file
operation calls vhost_dev_init(). Here, call_ctx->producer memory is cleared
in vhost_vring_call_reset().

Further, when the virtqueues are initialized by vhost_virtqueue_init(),
vhost_vdpa_setup_vq_irq() again registers the irq_bypass producer for each
virtqueue. As the node member of struct irq_bypass_producer is also
initialized
to zero, traversal on the producers list causes crash due to NULL pointer
dereference.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=211711
Signed-off-by: Gautam Dawar <gdawar@xilinx.com>

diff --git a/drivers/vhost/vdpa.c b/drivers/vhost/vdpa.c
index 62a9bb0efc55..fdad94e2fbf9 100644
--- a/drivers/vhost/vdpa.c
+++ b/drivers/vhost/vdpa.c
@@ -409,7 +409,6 @@ static long vhost_vdpa_vring_ioctl(struct vhost_vdpa
*v, unsigned int cmd,
                        cb.private = NULL;
                }
                ops->set_vq_cb(vdpa, idx, &cb);
-               vhost_vdpa_setup_vq_irq(v, idx);
                break;

        case VHOST_SET_VRING_NUM:

[-- Attachment #1.2: Type: text/html, Size: 1762 bytes --]

[-- Attachment #2: Type: text/plain, Size: 183 bytes --]

_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-02-15 14:04 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-15 14:04 [PATCH] vhost vdpa: setup vq irq only when set status includes VIRTIO_CONFIG_S_DRIVER_OK Gautam Dawar

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.