Skip to content

Commit 2b42461

Browse files
00xcliuw
authored andcommitted
mshv: clear eventfd counter on irqfd shutdown
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 <[email protected]> Signed-off-by: Wei Liu <[email protected]>
1 parent 5ed8cbc commit 2b42461

2 files changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/hv/mshv_eventfd.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,13 @@ static void mshv_irqfd_shutdown(struct work_struct *work)
247247
{
248248
struct mshv_irqfd *irqfd =
249249
container_of(work, struct mshv_irqfd, irqfd_shutdown);
250+
u64 cnt;
250251

251252
/*
252253
* Synchronize with the wait-queue and unhook ourselves to prevent
253254
* further events.
254255
*/
255-
remove_wait_queue(irqfd->irqfd_wqh, &irqfd->irqfd_wait);
256+
eventfd_ctx_remove_wait_queue(irqfd->irqfd_eventfd_ctx, &irqfd->irqfd_wait, &cnt);
256257

257258
if (irqfd->irqfd_resampler) {
258259
mshv_irqfd_resampler_shutdown(irqfd);
@@ -371,8 +372,6 @@ static void mshv_irqfd_queue_proc(struct file *file, wait_queue_head_t *wqh,
371372
struct mshv_irqfd *irqfd =
372373
container_of(polltbl, struct mshv_irqfd, irqfd_polltbl);
373374

374-
irqfd->irqfd_wqh = wqh;
375-
376375
/*
377376
* TODO: Ensure there isn't already an exclusive, priority waiter, e.g.
378377
* that the irqfd isn't already bound to another partition. Only the

drivers/hv/mshv_eventfd.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ struct mshv_irqfd {
3232
struct mshv_lapic_irq irqfd_lapic_irq;
3333
struct hlist_node irqfd_hnode;
3434
poll_table irqfd_polltbl;
35-
wait_queue_head_t *irqfd_wqh;
3635
wait_queue_entry_t irqfd_wait;
3736
struct work_struct irqfd_shutdown;
3837
struct mshv_irqfd_resampler *irqfd_resampler;

0 commit comments

Comments
 (0)