lkml.org 
[lkml]   [2023]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Date
SubjectRe: revert bab65e48cb064 PCI/MSI Sanitize MSI-X checks
On Thu, Apr 6, 2023 at 4:05 AM David Laight <David.Laight@aculab.com> wrote:
>
> So code like:
> for (i = 0; i < 16; i++)
> msix_tbl[i].entry = i;
> nvec = pci_enable_msix_range(dev, msix_tbl, 1, 16);
> Now returns -22 if the hardware only supports 8 interrupts.
>
> Previously it returned 8.

Does just moving the pci_msix_validate_entries() down to below the
hwsize update code fix it?

IOW, something like this attached patch?

ENTIRELY UNTESTED! This may be seriously broken for some reason, but
it does seem like the current code makes no sense (that "Keep the IRQ
virtual hackery working" comment seems to not possibly be true since
the MSIX nvec has effectively been checked against hwsize by the
pci_msix_validate_entries() code before).

I don't know this code. Thomas?

Linus
drivers/pci/msi/msi.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c
index 1f716624ca56..8edc7beebf6f 100644
--- a/drivers/pci/msi/msi.c
+++ b/drivers/pci/msi/msi.c
@@ -805,9 +805,6 @@ int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int
if (hwsize < 0)
return hwsize;

- if (!pci_msix_validate_entries(dev, entries, nvec, hwsize))
- return -EINVAL;
-
if (hwsize < nvec) {
/* Keep the IRQ virtual hackery working */
if (flags & PCI_IRQ_VIRTUAL)
@@ -819,6 +816,9 @@ int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int
if (nvec < minvec)
return -ENOSPC;

+ if (!pci_msix_validate_entries(dev, entries, nvec, hwsize))
+ return -EINVAL;
+
rc = pci_setup_msi_context(dev);
if (rc)
return rc;
\
 
 \ /
  Last update: 2023-04-06 21:36    [W:0.080 / U:0.328 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site