From: lirongqing <lirongqing@baidu.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
Thomas Gleixner <tglx@kernel.org>,
Vivian Wang <wangruikang@iscas.ac.cn>,
Li RongQing <lirongqing@baidu.com>,
Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>,
Yuanhe Shu <xiangzao@linux.alibaba.com>,
Hans Zhang <18255117159@163.com>, Vidya Sagar <vidyas@nvidia.com>,
Farhan Ali <alifm@linux.ibm.com>,
Shawn Lin <shawn.lin@rock-chips.com>,
Juergen Gross <jgross@suse.com>, <linux-pci@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: [PATCH] PCI/MSI: Initialize MSI-X descriptors in the setup loop
Date: Mon, 9 Nov 2026 11:14:11 +0800 [thread overview]
Message-ID: <20261109031411.2205-1-lirongqing@baidu.com> (raw)
From: Li RongQing <lirongqing@baidu.com>
msix_setup_msi_descs() reuses a single stack descriptor for all
MSI-X entries.
Since msix_prepare_msi_desc() only sets can_mask for non-virtual
descriptors, a virtual descriptor can inherit can_mask == 1 from
the preceding real descriptor.
As msi_domain_insert_msi_desc() copies the descriptor, this stale
value can cause pci_msix_write_vector_ctrl() to access beyond the
mapped MSI-X table.
Clear the descriptor inside the loop to ensure each MSI-X entry
starts with can_mask == 0.
Fixes: 3ece3e8e5976 ("PCI/MSI: Handle the NOMASK flag correctly for all PCI/MSI backends")
Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
drivers/pci/msi/msi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index a346284..681dd2f 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -638,9 +638,8 @@ static int msix_setup_msi_descs(struct pci_dev *dev, struct msix_entry *entries,
struct irq_affinity_desc *curmsk;
struct msi_desc desc;
- memset(&desc, 0, sizeof(desc));
-
for (i = 0, curmsk = masks; i < nvec; i++, curmsk++) {
+ memset(&desc, 0, sizeof(desc));
desc.msi_index = entries ? entries[i].entry : i;
desc.affinity = masks ? curmsk : NULL;
desc.pci.msi_attrib.is_virtual = desc.msi_index >= vec_count;
--
2.9.4
next reply other threads:[~2026-11-09 3:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 3:14 lirongqing [this message]
2026-11-09 13:57 ` [tip: irq/msi] " tip-bot2 for Li RongQing
2026-11-09 20:47 ` [PATCH] " Farhan Ali
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=20261109031411.2205-1-lirongqing@baidu.com \
--to=lirongqing@baidu.com \
--cc=18255117159@163.com \
--cc=alifm@linux.ibm.com \
--cc=bhelgaas@google.com \
--cc=jgross@suse.com \
--cc=lihaoxiang@isrc.iscas.ac.cn \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=shawn.lin@rock-chips.com \
--cc=tglx@kernel.org \
--cc=vidyas@nvidia.com \
--cc=wangruikang@iscas.ac.cn \
--cc=xiangzao@linux.alibaba.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
all inboxes | Powered by JetHome®