From: Farhan Ali <alifm@linux.ibm.com>
To: lirongqing <lirongqing@baidu.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Thomas Gleixner <tglx@kernel.org>,
Vivian Wang <wangruikang@iscas.ac.cn>,
Haoxiang Li <lihaoxiang@isrc.iscas.ac.cn>,
Yuanhe Shu <xiangzao@linux.alibaba.com>,
Hans Zhang <18255117159@163.com>, Vidya Sagar <vidyas@nvidia.com>,
Shawn Lin <shawn.lin@rock-chips.com>,
Juergen Gross <jgross@suse.com>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] PCI/MSI: Initialize MSI-X descriptors in the setup loop
Date: Mon, 9 Nov 2026 12:47:41 -0800 [thread overview]
Message-ID: <114f0d44-3b01-4523-a99c-5654a3a556ba@linux.ibm.com> (raw)
In-Reply-To: <20261109031411.2205-1-lirongqing@baidu.com>
Hi Li,
On 11/8/2026 7:14 PM, lirongqing wrote:
> 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>
I think at some point the can_mask attribute was set in the loop in
msix_setup_msi_descs(). But this was split with commit 612ad43330d9
("PCI/MSI: Split MSI-X descriptor setup"), so I think the Fixes tag
should be applied against that commit?
> ---
> 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));
I wonder if we can just set can_mask = 0 in the loop rather doing the
memset every iteration?
Thanks
Farhan
> desc.msi_index = entries ? entries[i].entry : i;
> desc.affinity = masks ? curmsk : NULL;
> desc.pci.msi_attrib.is_virtual = desc.msi_index >= vec_count;
prev parent reply other threads:[~2026-11-09 20:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 3:14 lirongqing
2026-11-09 13:57 ` [tip: irq/msi] " tip-bot2 for Li RongQing
2026-11-09 20:47 ` Farhan Ali [this message]
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=114f0d44-3b01-4523-a99c-5654a3a556ba@linux.ibm.com \
--to=alifm@linux.ibm.com \
--cc=18255117159@163.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=lirongqing@baidu.com \
--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®