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

[PATCH] vpci/msix: conditionally invoke vpci_make_msix_hole


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Tue, 12 Aug 2025 11:17:42 -0400
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • 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=GIvbQ47y4UfUXUSyDirAujuj6G/Pn2yQMXJlyF+3Vbo=; b=t1z8prrMyFcZiiBG38ZieotgwlM5SnrjAYp9IfSh3Omz+HId4L4inCIjS90vUdxONC8J/la4M7mIIrpL5qEXBOm74PIqg3BAvqqJu1jh3vvkCWxVZxJWC+9n1KTYDklDPkrMH/0YmZv2C/0MxD/Af+oY7m6I2dLVNXOF+GI2qLcEj0u8KlYi0MtxLNLc5smzDEP999rkMzhmILwkXAHfr1w6PbJ842vVwrS4fYYKEmYdLfahal7I690TKUFB1F2qz4sQ6jh3xCAcMHA/6elxU/V/tFHYjwz2vP5FxF5ZKw85gaZBfouYvQIe4lCNgsWQvblr8fZnPqA4Hpzbn9NK5w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vhgeJ3ckbxU2OCZbcYhSV1hpYtXR/lpEgKJTnwwr3UYAM82+1+KgvEF2YzP+4BVzuNCkUc88FAdsERJLGZVZwmZiXF6XFXbuA9iTOIzU1+0LZEx08xf4ylHWuOo4Wl8cL1+1Vc6wVk/dTQAC8dQ4E3IuHPUbipTXGZIuuXtUOJSJ7JxQbqz64y9F2ykLJbxCLysxvtNYJzP6FpVOwrlC2FFGlOQ3nnDB+FOJjMR/oeVtlyPhKjNuvucjBsMT5dD/co1ox4YcAqfTizfslFPGofA6neHx1LNgQ30VjfBa9yKVmpbcBRKLiJr8gvaPV2yLLWH5/UUeZHPdakjhLb04jA==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jiqian Chen <Jiqian.Chen@xxxxxxx>
  • Delivery-date: Tue, 12 Aug 2025 15:18:00 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

A hotplugged PCI device may be added uninitialized. In particular,
memory decoding may be disabled and the BARs may be zeroed. In this
case, the BARs will not be mapped in p2m. However, currently
vpci_make_msix_hole is called unconditionally in init_msix, and the
initialization fails in this case:

(XEN) d0v0 0000:01:00.0: existing mapping (mfn: 1c1880 type: 0) at 0 clobbers 
MSIX MMIO area
(XEN) d0 0000:01:00.0: init legacy cap 17 fail rc=-17, mask it

vpci_make_msix_hole should only be called if the BARs containing the
MSI-X/PBA tables are mapped in p2m.

Take the opportunity to fix a typo in the preceding comment.

Fixes: ee2eb6849d50 ("vpci: Refactor REGISTER_VPCI_INIT")
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
 xen/drivers/vpci/msix.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c
index 54a5070733aa..39d1c45bd296 100644
--- a/xen/drivers/vpci/msix.c
+++ b/xen/drivers/vpci/msix.c
@@ -705,10 +705,16 @@ static int cf_check init_msix(struct pci_dev *pdev)
 
     /*
      * vPCI header initialization will have mapped the whole BAR into the
-     * p2m, as MSI-X capability was not yet initialized.  Crave a hole for
+     * p2m, as MSI-X capability was not yet initialized.  Carve a hole for
      * the MSI-X table here, so that Xen can trap accesses.
      */
-    return vpci_make_msix_hole(pdev);
+    if ( pdev->vpci->header.bars[
+             msix->tables[VPCI_MSIX_TABLE] & PCI_MSIX_BIRMASK].enabled ||
+         pdev->vpci->header.bars[
+             msix->tables[VPCI_MSIX_PBA] & PCI_MSIX_BIRMASK].enabled )
+        return vpci_make_msix_hole(pdev);
+
+    return 0;
 }
 REGISTER_VPCI_CAP(MSIX, init_msix, NULL);
 

base-commit: 4cde4a552ed35f3cc74df877d5a7cfbbfced8fb3
-- 
2.50.1




 


Rackspace

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