[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 2/3] vpci/msix: move msix region removal to msix.c


  • To: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • Date: Mon, 26 Oct 2026 12:28:00 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uJs+WFpev3akBFRF+sJ2ujKnrr/5HAnuZXXVTr+5cjU=; b=jHtpRv/DzailNhhC4ldpTIgDhroQM7pApdHTTx+cvDCQ7AX5Imm05kpxr/nbMPCfahOOBaKKbHSX29umRJvF8fjwmBpc2q0Hq03BVtf4PyGLO3iwVx1D3ytaqUxQTAzyKNzWf5o1x7ezFeEmWK0uj1p69F5WleZ9IMlnC9B/Yu6Pq81ddQewxdPg+TX3uzfIh//LUr7/O/16IQUpxuoPI2iKqcVwp7FJzwyDmCH/TkdU61q3+dozDEUauMsEnYVFmOxS1CcvzuWe4hLuqQVHu0TJCfbVOksfm4aS0ZgpWgXb31iF+ING9+Sl5MJutiAQv2gneie/CQ0HB/yTJXrnGQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bDsIIDkLwJLoa8xss8NuToPoT/5Us5WQIbBITC8A+9wreqHMndOAY4PjormcT6F45ppQJ4Eehl7f6fZJHNQLD/iXPpPLiNV8k8OlMin7KiX6NWsHQquhengNIGaAbbJXSVtJXT4oN0W51F0NppqVo9+Ywh7s0RJkFIY3BWya3wF/6zfr5o+Bd9gKq7MYqi4x+M8stR02cynz5rr/83ilaouX38obDx1KooZ2e56evLYUgIflnWBP5CxcVKrEJPv23uW6kMcdx7R9iAQBfT3FdbV/31LFoZoXBZuANG7Yb50lZPxSUWk9SyXud3bYeLW8m/5E1GCDEsywayST1ORiNA==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=epam.com header.i="@epam.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:x-ms-exchange-senderadcheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Mykyta Poturai <Mykyta_Poturai@xxxxxxxx>
  • Delivery-date: Mon, 26 Oct 2026 12:28:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Thread-index: AQHdZUVw/fA35GNZ9kyzCDEBJXJ5MA==
  • Thread-topic: [PATCH v1 2/3] vpci/msix: move msix region removal to msix.c

From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>

This code won't be used on Arm.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
Signed-off-by: Mykyta Poturai <mykyta_poturai@xxxxxxxx>
---
 xen/drivers/vpci/header.c  | 30 +++++-------------------------
 xen/drivers/vpci/msix.c    | 35 +++++++++++++++++++++++++++++++++++
 xen/drivers/vpci/private.h |  2 ++
 3 files changed, 42 insertions(+), 25 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 7e5f4b8a00..9e19e41d0a 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -310,7 +310,6 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t 
cmd, bool rom_only)
     struct vpci_header *header = &pdev->vpci->header;
     struct pci_dev *tmp;
     const struct domain *d;
-    const struct vpci_msix *msix = pdev->vpci->msix;
     unsigned int i, j;
     int rc;
 
@@ -405,30 +404,11 @@ static int modify_bars(const struct pci_dev *pdev, 
uint16_t cmd, bool rom_only)
         }
     }
 
-    /* Remove any MSIX regions if present. */
-    for ( i = 0; msix && i < ARRAY_SIZE(msix->tables); i++ )
-    {
-        unsigned long start = PFN_DOWN(vmsix_table_addr(pdev->vpci, i));
-        unsigned long end = PFN_DOWN(vmsix_table_addr(pdev->vpci, i) +
-                                     vmsix_table_size(pdev->vpci, i) - 1);
-
-        for ( j = 0; j < ARRAY_SIZE(header->bars); j++ )
-        {
-            const struct vpci_bar *bar = &header->bars[j];
-
-            if ( rangeset_is_empty(bar->mem) )
-                continue;
-
-            rc = rangeset_remove_range(bar->mem, start, end);
-            if ( rc )
-            {
-                gprintk(XENLOG_WARNING,
-                       "%pp: failed to remove MSIX table [%lx, %lx]: %d\n",
-                        &pdev->sbdf, start, end, rc);
-                return rc;
-            }
-        }
-    }
+#ifdef CONFIG_HAS_PCI_MSI
+    rc = vpci_remove_msix_regions(pdev);
+    if ( rc )
+        return rc;
+#endif
 
     /*
      * Check for overlaps with other BARs. Note that only BARs that are
diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c
index 05056b5ea1..4a1e7561f6 100644
--- a/xen/drivers/vpci/msix.c
+++ b/xen/drivers/vpci/msix.c
@@ -590,6 +590,41 @@ static const struct hvm_mmio_ops vpci_msix_table_ops = {
     .write = msix_write,
 };
 
+int vpci_remove_msix_regions(const struct pci_dev *pdev)
+{
+    const struct vpci_msix *msix = pdev->vpci->msix;
+    struct vpci_header *header = &pdev->vpci->header;
+    unsigned int i, j;
+    int rc;
+
+    /* Remove any MSIX regions if present. */
+    for ( i = 0; msix && i < ARRAY_SIZE(msix->tables); i++ )
+    {
+        unsigned long start = PFN_DOWN(vmsix_table_addr(pdev->vpci, i));
+        unsigned long end = PFN_DOWN(vmsix_table_addr(pdev->vpci, i) +
+                                     vmsix_table_size(pdev->vpci, i) - 1);
+
+        for ( j = 0; j < ARRAY_SIZE(header->bars); j++ )
+        {
+            const struct vpci_bar *bar = &header->bars[j];
+
+            if ( rangeset_is_empty(bar->mem) )
+                continue;
+
+            rc = rangeset_remove_range(bar->mem, start, end);
+            if ( rc )
+            {
+                gprintk(XENLOG_WARNING,
+                       "%pp: failed to remove MSIX table [%lx, %lx]: %d\n",
+                        &pdev->sbdf, start, end, rc);
+                return rc;
+            }
+        }
+    }
+
+    return 0;
+}
+
 int vpci_make_msix_hole(const struct pci_dev *pdev)
 {
     struct domain *d = pdev->domain;
diff --git a/xen/drivers/vpci/private.h b/xen/drivers/vpci/private.h
index 2907f6b40f..a163efe8ff 100644
--- a/xen/drivers/vpci/private.h
+++ b/xen/drivers/vpci/private.h
@@ -87,6 +87,8 @@ void cf_check vpci_hw_write16(
     const struct pci_dev *pdev, unsigned int reg, uint32_t val, void *data);
 
 #ifdef __XEN__
+int vpci_remove_msix_regions(const struct pci_dev *pdev);
+
 /* Make sure there's a hole in the p2m for the MSIX mmio areas. */
 int vpci_make_msix_hole(const struct pci_dev *pdev);
 
-- 
2.55.0

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.