Patch "vfio: Introduce interface to flush virqfd inject workqueue" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    vfio: Introduce interface to flush virqfd inject workqueue

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     vfio-introduce-interface-to-flush-virqfd-inject-workqueue.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.


>From stable+bounces-35125-greg=kroah.com@xxxxxxxxxxxxxxx Mon Apr  1 18:54:02 2024
From: Alex Williamson <alex.williamson@xxxxxxxxxx>
Date: Mon,  1 Apr 2024 10:52:57 -0600
Subject: vfio: Introduce interface to flush virqfd inject workqueue
To: stable@xxxxxxxxxxxxxxx
Cc: Alex Williamson <alex.williamson@xxxxxxxxxx>, sashal@xxxxxxxxxx, gregkh@xxxxxxxxxxxxxxxxxxx, eric.auger@xxxxxxxxxx, Kevin Tian <kevin.tian@xxxxxxxxx>, Reinette Chatre <reinette.chatre@xxxxxxxxx>
Message-ID: <20240401165302.3699643-4-alex.williamson@xxxxxxxxxx>

From: Alex Williamson <alex.williamson@xxxxxxxxxx>

[ Upstream commit b620ecbd17a03cacd06f014a5d3f3a11285ce053 ]

In order to synchronize changes that can affect the thread callback,
introduce an interface to force a flush of the inject workqueue.  The
irqfd pointer is only valid under spinlock, but the workqueue cannot
be flushed under spinlock.  Therefore the flush work for the irqfd is
queued under spinlock.  The vfio_irqfd_cleanup_wq workqueue is re-used
for queuing this work such that flushing the workqueue is also ordered
relative to shutdown.

Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
Reviewed-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Reviewed-by: Eric Auger <eric.auger@xxxxxxxxxx>
Link: https://lore.kernel.org/r/20240308230557.805580-4-alex.williamson@xxxxxxxxxx
Signed-off-by: Alex Williamson <alex.williamson@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/vfio/virqfd.c |   21 +++++++++++++++++++++
 include/linux/vfio.h  |    2 ++
 2 files changed, 23 insertions(+)

--- a/drivers/vfio/virqfd.c
+++ b/drivers/vfio/virqfd.c
@@ -101,6 +101,13 @@ static void virqfd_inject(struct work_st
 		virqfd->thread(virqfd->opaque, virqfd->data);
 }
 
+static void virqfd_flush_inject(struct work_struct *work)
+{
+	struct virqfd *virqfd = container_of(work, struct virqfd, flush_inject);
+
+	flush_work(&virqfd->inject);
+}
+
 int vfio_virqfd_enable(void *opaque,
 		       int (*handler)(void *, void *),
 		       void (*thread)(void *, void *),
@@ -124,6 +131,7 @@ int vfio_virqfd_enable(void *opaque,
 
 	INIT_WORK(&virqfd->shutdown, virqfd_shutdown);
 	INIT_WORK(&virqfd->inject, virqfd_inject);
+	INIT_WORK(&virqfd->flush_inject, virqfd_flush_inject);
 
 	irqfd = fdget(fd);
 	if (!irqfd.file) {
@@ -214,6 +222,19 @@ void vfio_virqfd_disable(struct virqfd *
 }
 EXPORT_SYMBOL_GPL(vfio_virqfd_disable);
 
+void vfio_virqfd_flush_thread(struct virqfd **pvirqfd)
+{
+	unsigned long flags;
+
+	spin_lock_irqsave(&virqfd_lock, flags);
+	if (*pvirqfd && (*pvirqfd)->thread)
+		queue_work(vfio_irqfd_cleanup_wq, &(*pvirqfd)->flush_inject);
+	spin_unlock_irqrestore(&virqfd_lock, flags);
+
+	flush_workqueue(vfio_irqfd_cleanup_wq);
+}
+EXPORT_SYMBOL_GPL(vfio_virqfd_flush_thread);
+
 module_init(vfio_virqfd_init);
 module_exit(vfio_virqfd_exit);
 
--- a/include/linux/vfio.h
+++ b/include/linux/vfio.h
@@ -221,6 +221,7 @@ struct virqfd {
 	wait_queue_entry_t		wait;
 	poll_table		pt;
 	struct work_struct	shutdown;
+	struct work_struct	flush_inject;
 	struct virqfd		**pvirqfd;
 };
 
@@ -229,5 +230,6 @@ extern int vfio_virqfd_enable(void *opaq
 			      void (*thread)(void *, void *),
 			      void *data, struct virqfd **pvirqfd, int fd);
 extern void vfio_virqfd_disable(struct virqfd **pvirqfd);
+void vfio_virqfd_flush_thread(struct virqfd **pvirqfd);
 
 #endif /* VFIO_H */


Patches currently in stable-queue which might be from kroah.com@xxxxxxxxxxxxxxx are

queue-5.10/x86-rfds-mitigate-register-file-data-sampling-rfds.patch
queue-5.10/vfio-pci-create-persistent-intx-handler.patch
queue-5.10/x86-entry_32-add-verw-just-before-userspace-transition.patch
queue-5.10/vfio-fsl-mc-block-calling-interrupt-handler-without-trigger.patch
queue-5.10/x86-bugs-add-asm-helpers-for-executing-verw.patch
queue-5.10/vfio-pci-disable-auto-enable-of-exclusive-intx-irq.patch
queue-5.10/vfio-pci-lock-external-intx-masking-ops.patch
queue-5.10/vfio-introduce-interface-to-flush-virqfd-inject-workqueue.patch
queue-5.10/kvm-x86-export-rfds_no-and-rfds_clear-to-guests.patch
queue-5.10/x86-asm-add-_asm_rip-macro-for-x86-64-rip-suffix.patch
queue-5.10/x86-entry_64-add-verw-just-before-userspace-transition.patch
queue-5.10/x86-mmio-disable-kvm-mitigation-when-x86_feature_clear_cpu_buf-is-set.patch
queue-5.10/x86-bugs-use-alternative-instead-of-mds_user_clear-static-key.patch
queue-5.10/documentation-hw-vuln-add-documentation-for-rfds.patch
queue-5.10/kvm-vmx-use-bt-jnc-i.e.-eflags.cf-to-select-vmresume-vs.-vmlaunch.patch
queue-5.10/mm-migrate-set-swap-entry-values-of-thp-tail-pages-properly.patch
queue-5.10/kvm-vmx-move-verw-closer-to-vmentry-for-mds-mitigation.patch
queue-5.10/vfio-platform-create-persistent-irq-handlers.patch




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux