Skip to contentSkip to conversation

hw/usb/hcd-xhci-pci: Fail if user requested MSIX but it can't be used

PATCH In review Philippe Mathieu-Daudé 1 participant 4 messages Jul 19, 2023 – Aug 31, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/usb/hcd-xhci-pci: Fail if user requested MSIX but it can't be used

Do not silently ignore the user request of using MSIX. Remove the TODO. Coverity reported this as CID 1508725.

---
 hw/usb/hcd-xhci-pci.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)
hw/usb/hcd-xhci-pci.c +16 -5
index 643d4643e4..416656b78c 100644
@@ -155,11 +155,22 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp)
     }
 
     if (s->msix != ON_OFF_AUTO_OFF) {
-        /* TODO check for errors, and should fail when msix=on */
-        msix_init(dev, s->xhci.numintrs,
-                  &s->xhci.mem, 0, OFF_MSIX_TABLE,
-                  &s->xhci.mem, 0, OFF_MSIX_PBA,
-                  0x90, NULL);
+        ret = msix_init(dev, s->xhci.numintrs,
+                        &s->xhci.mem, 0, OFF_MSIX_TABLE,
+                        &s->xhci.mem, 0, OFF_MSIX_PBA,
+                        0x90, &err);
+        if (ret < 0) {
+            if (s->msi == ON_OFF_AUTO_ON) {
+                /* Can't satisfy user's explicit msi=on request, fail */
+                error_append_hint(&err, "You might have to use msi=auto"
+                                        " (default) or msi=off with this"
+                                        " machine type.\n");
+                error_propagate(errp, err);
+                return;
+            }
+            /* report that msix is not supported, but do not error out */
+            warn_report_err(err);
+        }
     }
     s->xhci.as = pci_get_address_space(dev);
 }
Signature · 1 line
2.38.1
#1 lore raw

Ping?

Quoted 40 lines · Philippe Mathieu-Daudé

Do not silently ignore the user request of using MSIX. Remove the TODO. Coverity reported this as CID 1508725.

---
  hw/usb/hcd-xhci-pci.c | 21 ++++++++++++++++-----
  1 file changed, 16 insertions(+), 5 deletions(-)
hw/usb/hcd-xhci-pci.c +16 -5
index 643d4643e4..416656b78c 100644
@@ -155,11 +155,22 @@ static void usb_xhci_pci_realize(struct PCIDevice *dev, Error **errp)
      }
 
      if (s->msix != ON_OFF_AUTO_OFF) {
-        /* TODO check for errors, and should fail when msix=on */
-        msix_init(dev, s->xhci.numintrs,
-                  &s->xhci.mem, 0, OFF_MSIX_TABLE,
-                  &s->xhci.mem, 0, OFF_MSIX_PBA,
-                  0x90, NULL);
+        ret = msix_init(dev, s->xhci.numintrs,
+                        &s->xhci.mem, 0, OFF_MSIX_TABLE,
+                        &s->xhci.mem, 0, OFF_MSIX_PBA,
+                        0x90, &err);
+        if (ret < 0) {
+            if (s->msi == ON_OFF_AUTO_ON) {
+                /* Can't satisfy user's explicit msi=on request, fail */
+                error_append_hint(&err, "You might have to use msi=auto"
+                                        " (default) or msi=off with this"
+                                        " machine type.\n");
+                error_propagate(errp, err);
+                return;
+            }
+            /* report that msix is not supported, but do not error out */
+            warn_report_err(err);
+        }
      }
      s->xhci.as = pci_get_address_space(dev);
  }
#2 lore raw

kind ping?

Quoted 46 lines · Philippe Mathieu-Daudé

Ping?

Quoted 42 lines · Philippe Mathieu-Daudé

Do not silently ignore the user request of using MSIX. Remove the TODO. Coverity reported this as CID 1508725.

---
  hw/usb/hcd-xhci-pci.c | 21 ++++++++++++++++-----

  1 file changed, 16 insertions(+), 5 deletions(-)
hw/usb/hcd-xhci-pci.c +9 -5
index 643d4643e4..416656b78c 100644
@@ -155,11 +155,22 @@ static void usb_xhci_pci_realize(struct 
 PCIDevice *dev, Error **errp)
       }
       if (s->msix != ON_OFF_AUTO_OFF) {
-        /* TODO check for errors, and should fail when msix=on */
-        msix_init(dev, s->xhci.numintrs,
-                  &s->xhci.mem, 0, OFF_MSIX_TABLE,
-                  &s->xhci.mem, 0, OFF_MSIX_PBA,
-                  0x90, NULL);
+        ret = msix_init(dev, s->xhci.numintrs,
+                        &s->xhci.mem, 0, OFF_MSIX_TABLE,
+                        &s->xhci.mem, 0, OFF_MSIX_PBA,
+                        0x90, &err);
+        if (ret < 0) {
+            if (s->msi == ON_OFF_AUTO_ON) {
+                /* Can't satisfy user's explicit msi=on request, fail */
+                error_append_hint(&err, "You might have to use msi=auto"
+                                        " (default) or msi=off with 

this"
+                                        " machine type.\n"); +                error_propagate(errp, err);
+                return;
+            }
+            /* report that msix is not supported, but do not error out */
+            warn_report_err(err);
+        }
      }
      s->xhci.as = pci_get_address_space(dev);
  }

#3 lore raw

Cc'ing Markus and Marc-André

Quoted 52 lines · Philippe Mathieu-Daudé

kind ping?

Quoted 48 lines · Philippe Mathieu-Daudé

Ping?

Quoted 44 lines · Philippe Mathieu-Daudé

Do not silently ignore the user request of using MSIX. Remove the TODO. Coverity reported this as CID 1508725.

---
  hw/usb/hcd-xhci-pci.c | 21 ++++++++++++++++-----

  1 file changed, 16 insertions(+), 5 deletions(-)
hw/usb/hcd-xhci-pci.c +7 -5
index 643d4643e4..416656b78c 100644
@@ -155,11 +155,22 @@ static void usb_xhci_pci_realize(struct 
 PCIDevice *dev, Error **errp)
       }
       if (s->msix != ON_OFF_AUTO_OFF) {
-        /* TODO check for errors, and should fail when msix=on */
-        msix_init(dev, s->xhci.numintrs,
-                  &s->xhci.mem, 0, OFF_MSIX_TABLE,
-                  &s->xhci.mem, 0, OFF_MSIX_PBA,
-                  0x90, NULL);
+        ret = msix_init(dev, s->xhci.numintrs,
+                        &s->xhci.mem, 0, OFF_MSIX_TABLE,
+                        &s->xhci.mem, 0, OFF_MSIX_PBA,
+                        0x90, &err);
+        if (ret < 0) {
+            if (s->msi == ON_OFF_AUTO_ON) {
+                /* Can't satisfy user's explicit msi=on request, 

fail */
+                error_append_hint(&err, "You might have to use msi=auto"
+                                        " (default) or msi=off with this"
+                                        " machine type.\n"); +                error_propagate(errp, err);
+                return;
+            }
+            /* report that msix is not supported, but do not error out */
+            warn_report_err(err);
+        }
      }
      s->xhci.as = pci_get_address_space(dev);
  }