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

[RFC QEMU PATCH v2 1/1] xen/pci: get gsi from irq for passthrough devices


  • To: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Anthony Perard <anthony.perard@xxxxxxxxxx>, Paul Durrant <paul@xxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>, <qemu-devel@xxxxxxxxxx>
  • From: Jiqian Chen <Jiqian.Chen@xxxxxxx>
  • Date: Fri, 24 Nov 2023 18:49:51 +0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=kernel.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=kKyGINHRoWX/kzEUupQXPi7BRjW+7wniSgf5HCNyhN4=; b=TCYOsSGAzL9yeRHr/cymVHFlMnG2/vme563Sa0it6/BPPouRWhs0WMzE2B9WzcyDz6w2h6rlDHS8zPuvwpsTQpznPLuZXyp91ZKFQYjaufLLtD+JnOImJxRTivTkfNld1qapvcsW0Zt1UCY8S9WjFZLBJnghckJmIed00At+b8huPcFqOhybOHGE/LDhDfa59wfH8aw/w85GktRUJkJcITNlXEm2Cal9FF42hQE2Stz1pV7Qug48P51d6Tw5fx4nPtFD3PPYrZnLMevJXdrmo1Uqv3ZWxWIAELV9Eza56vwSRtyWvCsUOqM+wPMO+E6vvCu0Knsa2cmuiBNBfwWTiQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QnEyl2FgJ/V3hgFoB0Tbqtn0+/sGKFKLn2XWuQgPVFud4gZ0NfhX3OBDDMK9LN28Qbf4pDb9pubswKR6C7jSygtwnpf5j2RngYm4QUvVXIsFCe7p2TH5BYX8RZ329Yrjc/ICIVuW6kWk78+Icz+cGrpcsUDP/comCGASXhS2RnnFharABFa9AsEu1dCM3iYb83HEHEYlGmMFneAcnZ8MTZye/4eaVU8d9axgOrbEK75RPnvLqbx5IdY8jp9P7sRmb+urc0smYQ2iahPDY6c4Kl9/OUbyxYiIB9rlublRT572fZG6jNKhVqIYn5t2gK2n8cZfijz+Ni6z3bWaN/OgpQ==
  • Cc: Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx>, Stewart Hildebrand <Stewart.Hildebrand@xxxxxxx>, Alex Deucher <Alexander.Deucher@xxxxxxx>, Stefano Stabellini <stefano.stabellini@xxxxxxx>, Huang Rui <Ray.Huang@xxxxxxx>, Honglei Huang <Honglei1.Huang@xxxxxxx>, Julia Zhang <Julia.Zhang@xxxxxxx>, Jiqian Chen <Jiqian.Chen@xxxxxxx>, Huang Rui <ray.huang@xxxxxxx>
  • Delivery-date: Fri, 24 Nov 2023 10:50:30 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

In PVH dom0, it uses the linux local interrupt mechanism,
when it allocs irq for a gsi, it is dynamic, and follow
the principle of applying first, distributing first. And
if you debug the kernel codes, you will find the irq
number is alloced from small to large, but the applying
gsi number is not, may gsi 38 comes before gsi 28, that
causes the irq number is not equal with the gsi number.
And when we passthrough a device, QEMU will use its gsi
number to do mapping actions, see xen_pt_realize->
xc_physdev_map_pirq, but the gsi number is got from file
/sys/bus/pci/devices/xxxx:xx:xx.x/irq in current code,
that is irq not gsi, so it will fail when mapping.

For above reason, on Xen side, we add a new function to
translate irq to gsi. And at here, we call that function
to get the correct gsi number.

Signed-off-by: Jiqian Chen <Jiqian.Chen@xxxxxxx>
Signed-off-by: Huang Rui <ray.huang@xxxxxxx>
---
 hw/xen/xen-host-pci-device.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/hw/xen/xen-host-pci-device.c b/hw/xen/xen-host-pci-device.c
index 8c6e9a1716..00218f9080 100644
--- a/hw/xen/xen-host-pci-device.c
+++ b/hw/xen/xen-host-pci-device.c
@@ -10,6 +10,7 @@
 #include "qapi/error.h"
 #include "qemu/cutils.h"
 #include "xen-host-pci-device.h"
+#include "hw/xen/xen_native.h"
 
 #define XEN_HOST_PCI_MAX_EXT_CAP \
     ((PCIE_CONFIG_SPACE_SIZE - PCI_CONFIG_SPACE_SIZE) / (PCI_CAP_SIZEOF + 4))
@@ -368,7 +369,7 @@ void xen_host_pci_device_get(XenHostPCIDevice *d, uint16_t 
domain,
     if (*errp) {
         goto error;
     }
-    d->irq = v;
+    d->irq = xc_physdev_gsi_from_irq(xen_xc, v);
 
     xen_host_pci_get_hex_value(d, "class", &v, errp);
     if (*errp) {
-- 
2.34.1




 


Rackspace

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