DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org, Harman Kalra <hkalra@marvell.com>,
	Cunming Liang <cunming.liang@intel.com>,
	David Marchand <david.marchand@redhat.com>
Subject: [PATCH v2 03/13] vfio: fix uninitialized eventfds when enabling MSI-X
Date: Fri, 27 Nov 2026 13:14:03 +0000	[thread overview]
Message-ID: <052d3d0ce063abc5f0e7df280656504e646474a0.1795785194.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <cover.1795785194.git.anatoly.burakov@intel.com> <cover.1795785194.git.anatoly.burakov@intel.com>

Currently, when we enable MSI-X interrupts, we request as many vectors as
the interrupt handle says it may have, but we only fill in eventfds for
the vectors that have them. When the interrupt handle is set up through
EAL the two always match, but a driver is free to set the maximum number
of interrupts itself, and if it is bigger than the number of eventfds in
use, the rest of the request is uninitialized.

Fix it by marking all remaining vectors as having no eventfd.

Fixes: b13bfab4cdbe ("eal: reserve VFIO vector zero for misc interrupt")
Cc: cunming.liang@intel.com
Cc: stable@dpdk.org

Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
---
 lib/eal/linux/eal_interrupts.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/eal/linux/eal_interrupts.c b/lib/eal/linux/eal_interrupts.c
index c63956cde5c..03a0fc6ff32 100644
--- a/lib/eal/linux/eal_interrupts.c
+++ b/lib/eal/linux/eal_interrupts.c
@@ -278,7 +278,7 @@ vfio_enable_msix(const struct rte_intr_handle *intr_handle) {
 	int len, ret;
 	char irq_set_buf[MSIX_IRQ_SET_BUF_LEN];
 	struct vfio_irq_set *irq_set;
-	int *fd_ptr, vfio_dev_fd, i;
+	int *fd_ptr, vfio_dev_fd, i, nb_rxtx_vectors;
 
 	len = sizeof(irq_set_buf);
 
@@ -289,6 +289,8 @@ vfio_enable_msix(const struct rte_intr_handle *intr_handle) {
 		(rte_intr_max_intr_get(intr_handle) >
 		 RTE_MAX_RXTX_INTR_VEC_ID + 1 ?	RTE_MAX_RXTX_INTR_VEC_ID + 1 :
 		 rte_intr_max_intr_get(intr_handle)) : 1;
+	/* skip the first vector */
+	nb_rxtx_vectors = (int)irq_set->count - RTE_INTR_VEC_RXTX_OFFSET;
 
 	irq_set->flags = VFIO_IRQ_SET_DATA_EVENTFD | VFIO_IRQ_SET_ACTION_TRIGGER;
 	irq_set->index = VFIO_PCI_MSIX_IRQ_INDEX;
@@ -300,6 +302,9 @@ vfio_enable_msix(const struct rte_intr_handle *intr_handle) {
 		fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] =
 			rte_intr_efds_index_get(intr_handle, i);
 	}
+	/* vectors that have no eventfd must not be left uninitialized */
+	for (; i < nb_rxtx_vectors; i++)
+		fd_ptr[RTE_INTR_VEC_RXTX_OFFSET + i] = -1;
 
 	vfio_dev_fd = rte_intr_dev_fd_get(intr_handle);
 	ret = ioctl(vfio_dev_fd, VFIO_DEVICE_SET_IRQS, irq_set);
-- 
2.52.0


  parent reply	other threads:[~2026-11-27 13:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 16:03 [PATCH v1 00/11] VFIO-related fixes Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 01/11] bus/cdx: fix error check when enabling bus master Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 02/11] bus/cdx: fix eventfd setup when enabling interrupts Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 03/11] bus/fslmc: fix unchecked device setup for MC portal Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 04/11] bus/fslmc: fix double close of MC portal device FD Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 05/11] bus/fslmc: fix unchecked DPIO portal mapping Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 06/11] bus/fslmc: fix DPIO portal mapping leak on close Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 07/11] bus/pci: fix shared BAR info reset on mapping failure Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 08/11] bus/pci: fix leaks on BAR " Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 09/11] bus/pci: fix BAR area list free in secondary process Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 10/11] vfio: fix uninitialized eventfds when enabling MSI-X Anatoly Burakov
2026-11-26 16:03 ` [PATCH v1 11/11] vdpa/sfc: fix doorbell address in notify area query Anatoly Burakov
2026-11-27 13:14 ` [PATCH v2 00/13] VFIO-related fixes Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 01/13] interrupts: fix partial event list resize Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 02/13] interrupts: validate event list counts Anatoly Burakov
2026-11-27 13:14   ` Anatoly Burakov [this message]
2026-11-27 13:14   ` [PATCH v2 04/13] bus/cdx: fix error check when enabling bus master Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 05/13] bus/cdx: fix eventfd setup when enabling interrupts Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 06/13] bus/fslmc: fix unchecked device setup for MC portal Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 07/13] bus/fslmc: fix double close of MC portal device FD Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 08/13] bus/fslmc: fix unchecked DPIO portal mapping Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 09/13] bus/fslmc: fix DPIO portal mapping leak on close Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 10/13] bus/pci: fix shared BAR info reset on mapping failure Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 11/13] bus/pci: fix leaks on BAR " Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 12/13] bus/pci: fix BAR area list free in secondary process Anatoly Burakov
2026-11-27 13:14   ` [PATCH v2 13/13] vdpa/sfc: fix doorbell address in notify area query Anatoly Burakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=052d3d0ce063abc5f0e7df280656504e646474a0.1795785194.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=cunming.liang@intel.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=hkalra@marvell.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox