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

[RFC PATCH v1 2/4] xen/arm: Discovering PCI devices and add the PCI devices in XEN.


  • To: xen-devel@xxxxxxxxxxxxxxxxxxxx
  • From: Rahul Singh <rahul.singh@xxxxxxx>
  • Date: Thu, 23 Jul 2020 16:40:22 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • 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-SenderADCheck; bh=+qBrQE/prViUqVQSn9QqWxYINAyZdBmv/u8R521Hni8=; b=lunZUay2OG4xjT+2Kg+xqoqv97Oic6hMTjuQuOuM0RcrU0osK1NMhX0a9XdrKtFa3qBEFptutI3xAQrpSXu1Z7/fU6zWRCIBoCENx/wmWTHNyV6LV2ZqjiF8v87NBzq9nCmSmgqaplhyHcWPI9ZCay3C7OzBBXX6IENRUllmK5Z/4dCXY7Je1gbqK+tVIoQouVWgb3d//Yfiks0eO9BWWL3N54k2qSPdEedhjYmMCbqCz138o9dhiCQb/3WCFKco7p3z64WC4FDB5zp+ldTRL174RU8nUpRq4pReymw1vbwoaDgnl4xTDa9F1zxHiRd+kMa8srqCPKTZA/6mRmFk4w==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hUvJLRv4MULblw8+//xIveknlhcwLLYeI2U8tsdvu3/rZS6GKQePe6ut6k+u779wAHBxNcd1F8wvG82oTUArLyTBhDhOvJ8mmeuwwNG9IXnAyzK5T4p86q0L9ooCF4q5kdvEY2iFG5gxCYZHGCaxlrgHjA47IJ7WsQXzCW+QTJWaoJlJibk7b3g3vNb3XIXbpgYM93t/nbyEMsztf9OcPd2gley3Rt4IZA3ZW74pF69ZlLzuQ8x7Ljfee/aJBvDTR8zBur8RPJ3neI1HbV8s3J2S7KR8c+dtpJ9aT95b4gGsvxJ1u+YTd3RPuEFrnFuTdSNi9If8HJWoUzwD21V9Og==
  • Authentication-results-original: lists.xenproject.org; dkim=none (message not signed) header.d=none; lists.xenproject.org; dmarc=none action=none header.from=arm.com;
  • Cc: rahul.singh@xxxxxxx, Julien Grall <julien@xxxxxxx>, Bertrand.Marquis@xxxxxxx, Stefano Stabellini <sstabellini@xxxxxxxxxx>, nd@xxxxxxx, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 23 Jul 2020 15:40:56 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: lists.xenproject.org; dkim=none (message not signed) header.d=none;lists.xenproject.org; dmarc=none action=none header.from=arm.com;

Hardware domain is in charge of doing the PCI enumeration and will
discover the PCI devices and then will communicate to XEN via hyper
call PHYSDEVOP_pci_device_add to add the PCI devices in XEN.

Change-Id: Ie87e19741689503b4b62da911c8dc2ee318584ac
Signed-off-by: Rahul Singh <rahul.singh@xxxxxxx>
---
 xen/arch/arm/physdev.c | 42 +++++++++++++++++++++++++++++++++++++++---
 1 file changed, 39 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/physdev.c b/xen/arch/arm/physdev.c
index e91355fe22..274720f98a 100644
--- a/xen/arch/arm/physdev.c
+++ b/xen/arch/arm/physdev.c
@@ -9,12 +9,48 @@
 #include <xen/errno.h>
 #include <xen/sched.h>
 #include <asm/hypercall.h>
-
+#include <xen/guest_access.h>
+#include <xsm/xsm.h>
 
 int do_physdev_op(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
 {
-    gdprintk(XENLOG_DEBUG, "PHYSDEVOP cmd=%d: not implemented\n", cmd);
-    return -ENOSYS;
+    int ret = 0;
+
+    switch ( cmd )
+    {
+#ifdef CONFIG_HAS_PCI
+        case PHYSDEVOP_pci_device_add:
+            {
+                struct physdev_pci_device_add add;
+                struct pci_dev_info pdev_info;
+                nodeid_t node = NUMA_NO_NODE;
+
+                ret = -EFAULT;
+                if ( copy_from_guest(&add, arg, 1) != 0 )
+                    break;
+
+                pdev_info.is_extfn = !!(add.flags & XEN_PCI_DEV_EXTFN);
+                if ( add.flags & XEN_PCI_DEV_VIRTFN )
+                {
+                    pdev_info.is_virtfn = 1;
+                    pdev_info.physfn.bus = add.physfn.bus;
+                    pdev_info.physfn.devfn = add.physfn.devfn;
+                }
+                else
+                    pdev_info.is_virtfn = 0;
+
+                ret = pci_add_device(add.seg, add.bus, add.devfn,
+                                &pdev_info, node);
+
+                break;
+            }
+#endif
+        default:
+            gdprintk(XENLOG_DEBUG, "PHYSDEVOP cmd=%d: not implemented\n", cmd);
+            ret = -ENOSYS;
+    }
+
+    return ret;
 }
 
 /*
-- 
2.17.1




 


Rackspace

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