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

[PATCH v6 8/9] xen/arm: enable dom0 to use PCI devices with pci-passthrough=no


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
  • Date: Thu, 9 Nov 2023 13:27:11 -0500
  • 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=DXLznLV9jxJDbZp4jEN64WVVU95OZkUBv8u9bN72k8w=; b=AzuLaZJ8eR1SjR7eU4tji27qp/szKegWPgSSeTdrfB3qoK86tVkKeouhq6t5r9cPGc7ZhrV7Fmdkv+rnwP375km+hm4YX1ChVDIyI2M50clVNYAVq1vdYnwNeYv5gwKGhjsAI4aFg6gYTSkg4u/UkT8e/fCKhWpOAg0pIJPNa1qPLGpRVLYctvMZVj8JZPQMDYCIUkQIHQ6aIZTA4EjD3zWg8Tj7XdKVxpxQZGFJuwAF9/gW/P9GjVrw7IpG/JwrEM2Pu851zQCjeusI5/nhsC9UPPKuuOteAiWn3NkludVQefF0bg1wstJTxoWUB0AYaC+Gf5tQ59bS2XYpMYSvZg==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jT9g96hjQdgJrxYt/7lrZMCXgKd9uzqipcYPM3uDFD4I0B/tG1DJn+0BEMBFzn7F5PmFPWKj05Uyu2Wij28XkaXERDLFghDLRJSEPFTMfXfKqKw2ugv7mQ3PWDJe3rUytqfgg1ceTbMrLR3S4ww8/OukePq5A/0Ctqfr/Uk8Wl9ve6CAAfzBjLikccI4nO6ibqy8BoZIQ4SG3XD2OX7AzNk5C2xJxVoJR/0q0lTrdALXKFjYQc/I5nK8WW7o+j91MipKT6SeV1/xyXOpjD1KgFlmxDbmI8ZG8cI8VYdIW4O1psMO1uxYDlIDDQi8Nludc7SF0zC+upoHYK2KANEyaQ==
  • Cc: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, "Volodymyr Babchuk" <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Thu, 09 Nov 2023 18:38:03 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Enable the use of IOMMU + PCI in dom0 without having to specify
"pci-passthrough=yes". We rely on dom0 to initialize the PCI controller
and perform a PHYSDEVOP_pci_device_add call to add each device to SMMU.

Enable pci_init() for initializing Xen's internal PCI subsystem, and
allow PHYSDEVOP_pci_device_add when pci-passthrough is disabled.

Signed-off-by: Stewart Hildebrand <stewart.hildebrand@xxxxxxx>
---
v5->v6:
* new patch - this effectively replaces
  ("Revert "xen/arm: Add cmdline boot option "pci-passthrough = <boolean>""")
---
 xen/arch/arm/pci/pci.c    | 3 ++-
 xen/drivers/pci/physdev.c | 6 ------
 2 files changed, 2 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/pci/pci.c b/xen/arch/arm/pci/pci.c
index 78b97beaef12..ba72fbaf1dfc 100644
--- a/xen/arch/arm/pci/pci.c
+++ b/xen/arch/arm/pci/pci.c
@@ -16,6 +16,7 @@
 #include <xen/device_tree.h>
 #include <xen/errno.h>
 #include <xen/init.h>
+#include <xen/iommu.h>
 #include <xen/param.h>
 #include <xen/pci.h>
 
@@ -85,7 +86,7 @@ static int __init pci_init(void)
      * Enable PCI passthrough when has been enabled explicitly
      * (pci-passthrough=on).
      */
-    if ( !pci_passthrough_enabled )
+    if ( !is_pci_passthrough_enabled() && !iommu_enabled )
         return 0;
 
     pci_segments_init();
diff --git a/xen/drivers/pci/physdev.c b/xen/drivers/pci/physdev.c
index 42db3e6d133c..4f3e1a96c0fd 100644
--- a/xen/drivers/pci/physdev.c
+++ b/xen/drivers/pci/physdev.c
@@ -18,9 +18,6 @@ ret_t pci_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) 
arg)
         struct pci_dev_info pdev_info;
         nodeid_t node = NUMA_NO_NODE;
 
-        if ( !is_pci_passthrough_enabled() )
-            return -EOPNOTSUPP;
-
         ret = -EFAULT;
         if ( copy_from_guest(&add, arg, 1) != 0 )
             break;
@@ -56,9 +53,6 @@ ret_t pci_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) 
arg)
     case PHYSDEVOP_pci_device_remove: {
         struct physdev_pci_device dev;
 
-        if ( !is_pci_passthrough_enabled() )
-            return -EOPNOTSUPP;
-
         ret = -EFAULT;
         if ( copy_from_guest(&dev, arg, 1) != 0 )
             break;
-- 
2.42.0




 


Rackspace

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