]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mshv: clear eventfd counter on irqfd shutdown
authorCarlos López <clopez@suse.de>
Thu, 22 Jan 2026 11:41:31 +0000 (12:41 +0100)
committerSasha Levin <sashal@kernel.org>
Wed, 4 Mar 2026 12:20:46 +0000 (07:20 -0500)
[ Upstream commit 2b4246153e2184e3a3b4edc8cc35337d7a2455a6 ]

While unhooking from the irqfd waitqueue, clear the internal eventfd
counter by using eventfd_ctx_remove_wait_queue() instead of
remove_wait_queue(), preventing potential spurious interrupts. This
removes the need to store a pointer into the workqueue, as the eventfd
already keeps track of it.

This mimicks what other similar subsystems do on their equivalent paths
with their irqfds (KVM, Xen, ACRN support, etc).

Signed-off-by: Carlos López <clopez@suse.de>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/hv/mshv_eventfd.c
drivers/hv/mshv_eventfd.h

index 6d176ed8ae516364701136a7f47466df4fd049ff..188923fce40b4628885219eacfc8f1e06de7248c 100644 (file)
@@ -248,12 +248,13 @@ static void mshv_irqfd_shutdown(struct work_struct *work)
 {
        struct mshv_irqfd *irqfd =
                        container_of(work, struct mshv_irqfd, irqfd_shutdown);
+       u64 cnt;
 
        /*
         * Synchronize with the wait-queue and unhook ourselves to prevent
         * further events.
         */
-       remove_wait_queue(irqfd->irqfd_wqh, &irqfd->irqfd_wait);
+       eventfd_ctx_remove_wait_queue(irqfd->irqfd_eventfd_ctx, &irqfd->irqfd_wait, &cnt);
 
        if (irqfd->irqfd_resampler) {
                mshv_irqfd_resampler_shutdown(irqfd);
@@ -372,8 +373,6 @@ static void mshv_irqfd_queue_proc(struct file *file, wait_queue_head_t *wqh,
        struct mshv_irqfd *irqfd =
                        container_of(polltbl, struct mshv_irqfd, irqfd_polltbl);
 
-       irqfd->irqfd_wqh = wqh;
-
        /*
         * TODO: Ensure there isn't already an exclusive, priority waiter, e.g.
         * that the irqfd isn't already bound to another partition.  Only the
index 332e7670a3442e5a2dde1c57d6e25d108f9db11a..464c6b81ab3364ceb704bc3b24687b63a4577e91 100644 (file)
@@ -32,7 +32,6 @@ struct mshv_irqfd {
        struct mshv_lapic_irq                irqfd_lapic_irq;
        struct hlist_node                    irqfd_hnode;
        poll_table                           irqfd_polltbl;
-       wait_queue_head_t                   *irqfd_wqh;
        wait_queue_entry_t                   irqfd_wait;
        struct work_struct                   irqfd_shutdown;
        struct mshv_irqfd_resampler         *irqfd_resampler;