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

[PATCH v4 4/5] [FUTURE] xen/arm: enable vPCI for domUs


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Mon, 30 Oct 2023 19:52:35 -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=arcselector9901; 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=jS463M7ybXNAP2udLjwYqu5FXR0JgJvPA4yJkwmqw18=; b=kt0O3QHGST8XQ+CKYeCZqLvGDs3nSnvJ/XG36k5CgWshkzcdIgnF/hKx8PVX7ebbXcWMSU2b7cTde1fUrYe3HzRfVMzXTlP1ZgxjhySg8tybaUE1Sn2xYtEW5LZGFi2RKd2Bfff+xKCJT9x5B55QFKbsrCblp7RTkYJ/GbKIf+oX1EDstbC3zdxbnN/ExhevL8aiky8fEq5bOj2mFK1/IBATr3Cp8mp3AZUq2hlF5CWp4auiG8AogQh/SDh7tJd4SuiSkQvqc9jDR2PYA919TzTBik4oubmslFMOQhHMeyeRd5vdVCeaxKxYnQT6UONiU6/qikFURFI1LuCRr8/m5Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DfpWf7l70nhSaMpg85PxIlTl5R0YEKaPntc0JtUjLlnj/IBgF0Um8YSKVGbjMIoCEzgnlWNRAaDEDRgNTnf/BAReeiRJBr61bMjiwBMZSX8+zhECPmzlNfEhoffkeL5748onj7GLWLz8a+pv72Hj6dW+1A54AutVsR4ShPz4XRGsvLC5Jc9mR5CFAOXnerrn/uvnVq1nLnPtlCgcNJDp3/YHiG4beGlYoKbZ4jlC8v/L6VJ5rfGyHrNNjrZ8ERop5jn9bt8B3Xa23f9SVLD+7pIK4tA4/Qk6F4A12TNI2ksvgyyzg/8HSkFsem59Fkw2aaadDDeS+nuRdV2zSBTepg==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Paul Durrant <paul@xxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Mon, 30 Oct 2023 23:54:04 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Select HAS_VPCI_GUEST_SUPPORT in Kconfig for enabling vPCI support for
domUs.

Add checks to fail guest creation if the configuration is invalid.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
As the tag implies, this patch is not intended to be merged (yet).

Note that CONFIG_HAS_VPCI_GUEST_SUPPORT is not currently used in the upstream
code base. It will be used by the vPCI series [1]. This patch is intended to be
merged as part of the vPCI series. I'll coordinate with Volodymyr to include
this in the vPCI series or resend afterwards. Meanwhile, I'll include it here
until the Kconfig and xen_arch_domainconfig prerequisites have been committed.

v3->v4:
* refuse to create domain if configuration is invalid
* split toolstack change into separate patch

v2->v3:
* set pci flags in toolstack

v1->v2:
* new patch

[1] https://lists.xenproject.org/archives/html/xen-devel/2023-08/msg02361.html
---
 xen/arch/arm/Kconfig          |  1 +
 xen/arch/arm/vpci.c           |  8 ++++++++
 xen/drivers/passthrough/pci.c | 10 ++++++++++
 3 files changed, 19 insertions(+)

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 5ff68e5d5979..3845b238a33f 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -195,6 +195,7 @@ config PCI_PASSTHROUGH
        depends on ARM_64
        select HAS_PCI
        select HAS_VPCI
+       select HAS_VPCI_GUEST_SUPPORT
        default n
        help
          This option enables PCI device passthrough
diff --git a/xen/arch/arm/vpci.c b/xen/arch/arm/vpci.c
index 3bc4bb55082a..61e0edcedea9 100644
--- a/xen/arch/arm/vpci.c
+++ b/xen/arch/arm/vpci.c
@@ -2,6 +2,7 @@
 /*
  * xen/arch/arm/vpci.c
  */
+#include <xen/lib.h>
 #include <xen/sched.h>
 #include <xen/vpci.h>
 
@@ -90,8 +91,15 @@ int domain_vpci_init(struct domain *d)
             return ret;
     }
     else
+    {
+        if ( !IS_ENABLED(CONFIG_HAS_VPCI_GUEST_SUPPORT) )
+        {
+            gdprintk(XENLOG_ERR, "vPCI requested but guest support not 
enabled\n");
+            return -EINVAL;
+        }
         register_mmio_handler(d, &vpci_mmio_handler,
                               GUEST_VPCI_ECAM_BASE, GUEST_VPCI_ECAM_SIZE, 
NULL);
+    }
 
     return 0;
 }
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 04d00c7c37df..bbdc926eda2c 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -1618,6 +1618,16 @@ int iommu_do_pci_domctl(
         bus = PCI_BUS(machine_sbdf);
         devfn = PCI_DEVFN(machine_sbdf);
 
+        if ( IS_ENABLED(CONFIG_ARM) &&
+             !is_hardware_domain(d) &&
+             !is_system_domain(d) &&
+             (!IS_ENABLED(CONFIG_HAS_VPCI_GUEST_SUPPORT) || !has_vpci(d)) )
+        {
+            printk(XENLOG_G_WARNING "Cannot assign %pp to %pd: vPCI support 
not enabled\n",
+                   &PCI_SBDF(seg, bus, devfn), d);
+            break;
+        }
+
         pcidevs_lock();
         ret = device_assigned(seg, bus, devfn);
         if ( domctl->cmd == XEN_DOMCTL_test_assign_device )
-- 
2.42.0




 


Rackspace

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