* [PATCH net] net: mana: Cap MSI-X vectors to the device MSI-X table size
@ 2026-08-21 18:37 Long Li
2026-08-24 16:16 ` Simon Horman
2026-08-24 19:10 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Long Li @ 2026-08-21 18:37 UTC (permalink / raw)
To: Long Li, Konstantin Taranov, Jakub Kicinski, David S . Miller,
Paolo Abeni, Eric Dumazet, Andrew Lunn, Jason Gunthorpe,
Leon Romanovsky, Haiyang Zhang, K . Y . Srinivasan, Wei Liu,
Dexuan Cui, shradhagupta, Simon Horman, ernis, stephen
Cc: netdev, linux-rdma, linux-hyperv, linux-kernel
mana_gd_query_max_resources() sizes gc->num_msix_usable from resp.max_msix
and the CPU count, but never from the device MSI-X table. On a 1792 vCPU
M-series VM that yields 1793 while the table has 1024 entries, and
mana_gd_setup_remaining_irqs() then walks indices 1..1792, running off the
end of the region mapped by msix_map_region():
BUG: unable to handle page fault for address: ff8e347f8b99800c
RIP: 0010:msix_prepare_msi_desc+0x7a/0x90
RAX: 0000000000004000 RBX: ff4330cb164ea780 RCX: ff8e347f8b998000
Call Trace:
<TASK>
__msi_domain_alloc_irqs+0x13a/0x440
msi_domain_alloc_irq_at+0x149/0x1b0
mana_gd_setup+0x351/0x890
mana_gd_probe+0x274/0x390
</TASK>
RAX is index 1024 * PCI_MSIX_ENTRY_SIZE, one entry past the table.
msi_insert_desc() does range check the index, but only against the MSI
domain hwsize, which matches the table only for devices on an MSI parent
domain. With a global PCI/MSI domain hwsize is MSI_XA_DOMAIN_SIZE, so
nothing bounds the request.
Cap num_msix_usable with pci_msix_vec_count().
Fixes: 755391121038 ("net: mana: Allocate MSI-X vectors dynamically")
Signed-off-by: Long Li <longli@microsoft.com>
---
.../net/ethernet/microsoft/mana/gdma_main.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/drivers/net/ethernet/microsoft/mana/gdma_main.c b/drivers/net/ethernet/microsoft/mana/gdma_main.c
index ed9af314e4ede3ea0422694bd1f2f652f9c10478..f92b2d0bf926e1b715ff665d37f8173a2103e6fe 100644
--- a/drivers/net/ethernet/microsoft/mana/gdma_main.c
+++ b/drivers/net/ethernet/microsoft/mana/gdma_main.c
@@ -182,6 +182,7 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev)
struct gdma_query_max_resources_resp resp = {};
struct gdma_general_req req = {};
unsigned int max_num_queues;
+ unsigned int msix_vec_count;
u8 bm_hostmode;
u16 num_ports;
int err;
@@ -218,6 +219,24 @@ static int mana_gd_query_max_resources(struct pci_dev *pdev)
gc->num_msix_usable = min(resp.max_msix, num_online_cpus() + 1);
}
+ /* MSI-X vectors are allocated by index into the device MSI-X table, so
+ * never ask for more than the table holds. It can be smaller than both
+ * resp.max_msix and the CPU count.
+ */
+ err = pci_msix_vec_count(pdev);
+ if (err <= 0) {
+ dev_err(gc->dev, "Failed to query MSI-X table size: %d\n", err);
+ return err < 0 ? err : -ENOSPC;
+ }
+ msix_vec_count = err;
+
+ if (gc->num_msix_usable > msix_vec_count) {
+ dev_info(gc->dev,
+ "Limiting MSI-X vectors from %u to table size %u\n",
+ gc->num_msix_usable, msix_vec_count);
+ gc->num_msix_usable = msix_vec_count;
+ }
+
if (gc->num_msix_usable <= 1)
return -ENOSPC;
base-commit: 746fc0787f616da418ffc04a110296fe95d53491
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] net: mana: Cap MSI-X vectors to the device MSI-X table size
2026-08-21 18:37 [PATCH net] net: mana: Cap MSI-X vectors to the device MSI-X table size Long Li
@ 2026-08-24 16:16 ` Simon Horman
2026-08-24 19:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2026-08-24 16:16 UTC (permalink / raw)
To: Long Li
Cc: Konstantin Taranov, Jakub Kicinski, David S . Miller, Paolo Abeni,
Eric Dumazet, Andrew Lunn, Jason Gunthorpe, Leon Romanovsky,
Haiyang Zhang, K . Y . Srinivasan, Wei Liu, Dexuan Cui,
shradhagupta, ernis, stephen, netdev, linux-rdma, linux-hyperv,
linux-kernel
On Fri, Aug 21, 2026 at 11:37:36AM -0700, Long Li wrote:
> mana_gd_query_max_resources() sizes gc->num_msix_usable from resp.max_msix
> and the CPU count, but never from the device MSI-X table. On a 1792 vCPU
> M-series VM that yields 1793 while the table has 1024 entries, and
> mana_gd_setup_remaining_irqs() then walks indices 1..1792, running off the
> end of the region mapped by msix_map_region():
>
> BUG: unable to handle page fault for address: ff8e347f8b99800c
> RIP: 0010:msix_prepare_msi_desc+0x7a/0x90
> RAX: 0000000000004000 RBX: ff4330cb164ea780 RCX: ff8e347f8b998000
> Call Trace:
> <TASK>
> __msi_domain_alloc_irqs+0x13a/0x440
> msi_domain_alloc_irq_at+0x149/0x1b0
> mana_gd_setup+0x351/0x890
> mana_gd_probe+0x274/0x390
> </TASK>
>
> RAX is index 1024 * PCI_MSIX_ENTRY_SIZE, one entry past the table.
>
> msi_insert_desc() does range check the index, but only against the MSI
> domain hwsize, which matches the table only for devices on an MSI parent
> domain. With a global PCI/MSI domain hwsize is MSI_XA_DOMAIN_SIZE, so
> nothing bounds the request.
>
> Cap num_msix_usable with pci_msix_vec_count().
>
> Fixes: 755391121038 ("net: mana: Allocate MSI-X vectors dynamically")
> Signed-off-by: Long Li <longli@microsoft.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net: mana: Cap MSI-X vectors to the device MSI-X table size
2026-08-21 18:37 [PATCH net] net: mana: Cap MSI-X vectors to the device MSI-X table size Long Li
2026-08-24 16:16 ` Simon Horman
@ 2026-08-24 19:10 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-08-24 19:10 UTC (permalink / raw)
To: Long Li
Cc: kotaranov, kuba, davem, pabeni, edumazet, andrew+netdev, jgg,
leon, haiyangz, kys, wei.liu, decui, shradhagupta, horms, ernis,
stephen, netdev, linux-rdma, linux-hyperv, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 21 Aug 2026 11:37:36 -0700 you wrote:
> mana_gd_query_max_resources() sizes gc->num_msix_usable from resp.max_msix
> and the CPU count, but never from the device MSI-X table. On a 1792 vCPU
> M-series VM that yields 1793 while the table has 1024 entries, and
> mana_gd_setup_remaining_irqs() then walks indices 1..1792, running off the
> end of the region mapped by msix_map_region():
>
> BUG: unable to handle page fault for address: ff8e347f8b99800c
> RIP: 0010:msix_prepare_msi_desc+0x7a/0x90
> RAX: 0000000000004000 RBX: ff4330cb164ea780 RCX: ff8e347f8b998000
> Call Trace:
> <TASK>
> __msi_domain_alloc_irqs+0x13a/0x440
> msi_domain_alloc_irq_at+0x149/0x1b0
> mana_gd_setup+0x351/0x890
> mana_gd_probe+0x274/0x390
> </TASK>
>
> [...]
Here is the summary with links:
- [net] net: mana: Cap MSI-X vectors to the device MSI-X table size
https://git.kernel.org/netdev/net/c/2c7493f98014
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-24 19:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21 18:37 [PATCH net] net: mana: Cap MSI-X vectors to the device MSI-X table size Long Li
2026-08-24 16:16 ` Simon Horman
2026-08-24 19:10 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox