Skip to content

Commit bf11791

Browse files
KAGA-KOKOvijay-suman
authored andcommitted
PCI/MSI: Handle lack of irqdomain gracefully
Alexandre observed a warning emitted from pci_msi_setup_msi_irqs() on a RISCV platform which does not provide PCI/MSI support: WARNING: CPU: 1 PID: 1 at drivers/pci/msi/msi.h:121 pci_msi_setup_msi_irqs+0x2c/0x32 __pci_enable_msix_range+0x30c/0x596 pci_msi_setup_msi_irqs+0x2c/0x32 pci_alloc_irq_vectors_affinity+0xb8/0xe2 RISCV uses hierarchical interrupt domains and correctly does not implement the legacy fallback. The warning triggers from the legacy fallback stub. That warning is bogus as the PCI/MSI layer knows whether a PCI/MSI parent domain is associated with the device or not. There is a check for MSI-X, which has a legacy assumption. But that legacy fallback assumption is only valid when legacy support is enabled, but otherwise the check should simply return -ENOTSUPP. Loongarch tripped over the same problem and blindly enabled legacy support without implementing the legacy fallbacks. There are weak implementations which return an error, so the problem was papered over. Correct pci_msi_domain_supports() to evaluate the legacy mode and add the missing supported check into the MSI enable path to complete it. Fixes: d2a463b ("PCI/MSI: Reject multi-MSI early") Reported-by: Alexandre Ghiti <[email protected]> Signed-off-by: Thomas Gleixner <[email protected]> Tested-by: Alexandre Ghiti <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/all/87ed2a8ow5.ffs@tglx Orabug: 37452651 CVE: CVE-2024-56760 (cherry picked from commit a60b990) cherry-pick-repo=kernel/git/torvalds/linux.git unmodified-from-upstream: a60b990 Signed-off-by: Qing Huang <[email protected]> Reviewed-by: Harshit Mogalapalli <[email protected]> Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 4b9cffa commit bf11791

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

drivers/pci/msi/irqdomain.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,8 +330,11 @@ bool pci_msi_domain_supports(struct pci_dev *pdev, unsigned int feature_mask,
330330

331331
domain = dev_get_msi_domain(&pdev->dev);
332332

333-
if (!domain || !irq_domain_is_hierarchy(domain))
334-
return mode == ALLOW_LEGACY;
333+
if (!domain || !irq_domain_is_hierarchy(domain)) {
334+
if (IS_ENABLED(CONFIG_PCI_MSI_ARCH_FALLBACKS))
335+
return mode == ALLOW_LEGACY;
336+
return false;
337+
}
335338

336339
if (!irq_domain_is_msi_parent(domain)) {
337340
/*

drivers/pci/msi/msi.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,10 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec,
424424
if (WARN_ON_ONCE(dev->msi_enabled))
425425
return -EINVAL;
426426

427+
/* Test for the availability of MSI support */
428+
if (!pci_msi_domain_supports(dev, 0, ALLOW_LEGACY))
429+
return -ENOTSUPP;
430+
427431
nvec = pci_msi_vec_count(dev);
428432
if (nvec < 0)
429433
return nvec;

0 commit comments

Comments
 (0)