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

[PATCH v2 RFC 4/5] x86/ioreq: report extended destination ID support by emulators


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Wed, 16 Feb 2022 11:30:25 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=XYwFCVS+ocU5eNhwXct/uBxkJGH3tqXX4XbY/zZKx+U=; b=JFaGh/16tx+W/G4q4YjPIVXzYUvG6gsRFv/nx5aHsdLJQtBHEjcBdg4ivJPLlTa+m/8Chzm4hsUbh1CZHrCdSDL5z7QMBYw4WB3A0LoMu/Wu7QvB+WWB2uCZI5+YCzPZYQsvIb8Bq+D7CRFdtnOPc8aXfkWcdu7sq0JplMIMEifCxavxnag2VwtwkS0ihDyMuF/xVDU9mntW+qvZcF5bpX1GZnqBD37sbXFHiCnpdxTbxm158c660+/XfZeFBtCMo6/b21V5sQp9BMkDjNsWvpqB7oMrPt/Ezp51Zsp0XfKMM4cDuDw20tNwsEO6WTBR0IVdd+D+ecxIK5SSPP5IWQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=juG7/FEdqHumFa+gHTrl5r6QMIltR7s/13Q6RqdSclJnLUKqcyaHz6eh7AROR8zHUjsnZTMmg5ELQk9N4uhgoq0V/bZlWuwvmtb/AxpY+ld9o1DXsVDHj+xpu8DPF45Un8rR2bEYPBRcr3D3C3WALU95Jw7VCWaueC+E6nlxs6ZF5YdRGX4A34TSW6ep/mBcnaBGNe6UkAPNXlaVCCO4rP6QayBtOpXiF2d5FCpItysIiHCxRR85PVmQKJMHGVoE1O1DAwKguZePs1WGa7G8+LO4ey33dNlKQSsXI2aF5EUZrtNcvP2puUEbeYmpCq90wMr69SPqWHc2eq3gnCIT5w==
  • Authentication-results: esa1.hc3370-68.iphmx.com; dkim=pass (signature verified) header.i=@citrix.onmicrosoft.com
  • Cc: <dwmw2@xxxxxxxxxxxxx>, Roger Pau Monne <roger.pau@xxxxxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, "Bertrand Marquis" <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>, Paul Durrant <paul@xxxxxxx>
  • Delivery-date: Wed, 16 Feb 2022 10:31:27 +0000
  • Ironport-data: A9a23:YPwM1qDd/H3NyxVW/3blw5YqxClBgxIJ4kV8jS/XYbTApG4lhTABy WMWUGGHbKyKM2TzKYpwa4628kIFucWEz99jQQY4rX1jcSlH+JHPbTi7wuYcHM8wwunrFh8PA xA2M4GYRCwMo/u1Si6FatANl1ElvU2zbue6WL6s1hxZH1c+En970Ew7wobVv6Yz6TSHK1LV0 T/Ni5W31G+Ng1aY5UpNtspvADs21BjDkGtwUm4WPJinj3eH/5UhN7oNJLnZEpfNatI88thW5 Qr05OrREmvxp3/BAz4++1rxWhVirrX6ZWBihpfKMkQLb9crSiEai84G2PQghUh/kASDgvwqk +90n8avExUPLKjItPheekwNe81+FfUuFL7vJHG+tYqYzlHccmuqyPJrZK00FdRGoKAtWzgIr KFGbmBWBvyAr7veLLaTUO5ji95lNMD2FIgepmth3XfSCvNOrZXrHfmVvoQCg21YasZmJOzxT pIHRBlWZUqbZSYMZmk3F5supbL97pX4W2IB8w/EzUYt2EDRxgFs1LnmMPLOZ8eHA85Smy6wm G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0UmO GbJ1q/LhrAazUveaXsjU3PK2LMF15gJvRlLyn4EJkiIxYWZ1qNmgkUJ/GRlVBlRwzVGz/l3a zpiOEBCLKmT+ytl2ZpYVGe2FgAdXBCU9yQdEbfSeLE1m6VwalHwEQ==
  • Ironport-hdrordr: A9a23:zcv1g68hp5DBu5b8h6Zuk+AiI+orL9Y04lQ7vn2ZKSY5TiVXra CTdZUgpHvJYVMqMk3I9uruBEDtex3hHP1OkOws1NWZLWrbUQKTRekP0WKL+Vbd8kbFh4xgPM lbEpSXCLfLfCVHZcSR2njFLz73quP3j5xBho3lvglQpRkBUdAG0+/gYDzraXGfQmN9dPwEPa vZ3OVrjRy6d08aa8yqb0N1JdQq97Xw5evbiQdtPW9e1DWz
  • Ironport-sdr: 9RFSBtBq4Pch33H8W5zita2dZl0xNQOZt0DTr0jfD0dIhVtdBPTHBIhpU2ke/IF1qtV2elJlE5 Rs0Jk6ci02cmzf6E+2bp54ydJ+HQBHzgFQYqA94nFIllpPM1KeYBhKm061/5H4IU0amyaNyagL HVRqDUgW1De9Z2WZX1kKpE+qVs0DkqSeWMavi1LKG85C5ShOhcMYxVp/2RVNFKEmln0nrrkTJb SD3UFpr1bedhXHYme/scgQS6H8TEZBpjApDbirwOLMK/VCL/ETp5Lp8IHqY8Odd4MyRGkXfMD8 GaNJriYGTEpG1CMYQt1XniZb
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Introduce a new arch specific field to report whether an emulator
supports the Extended Destination ID field, so that the hypervisor can
refrain from exposing the feature if one of the emulators doesn't
support it.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Changes since v1:
 - New in this version.
---
RFC: I find this kind of clumsy. In fact fully emulated devices
should already support Extended Destination ID without any
modifications, because XEN_DMOP_inject_msi gets passed the address and
data fields, so the hypervisor extracts the extended destination ID
from there.

PCI passthrough devices however use xc_domain_update_msi_irq and that
has leaked the gflags parameter in the API, even worse the position
of the flags are hardcoded in QEMU.

Should the clearing of ext_dest_id be limited to the domain using an
IOMMU?

RFC: Only enable ext_dest_id if max_cpu > 128? So the device model is
aware the domain must use ext_dest_id? (implies device model knows
APIC ID = CPU ID * 2)
---
 xen/arch/arm/ioreq.c           | 5 +++++
 xen/arch/x86/hvm/ioreq.c       | 7 +++++++
 xen/common/ioreq.c             | 8 +++++---
 xen/include/public/hvm/dm_op.h | 6 +++++-
 xen/include/xen/ioreq.h        | 2 ++
 5 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/xen/arch/arm/ioreq.c b/xen/arch/arm/ioreq.c
index 308650b400..7d56d022c8 100644
--- a/xen/arch/arm/ioreq.c
+++ b/xen/arch/arm/ioreq.c
@@ -185,6 +185,11 @@ void arch_ioreq_domain_init(struct domain *d)
 {
 }
 
+void arch_ioreq_server_create(struct domain *d, int bufioreq_handling,
+                              ioservid_t *id, unsigned int arch_flags)
+{
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c
index 02ad9db565..3276f0360d 100644
--- a/xen/arch/x86/hvm/ioreq.c
+++ b/xen/arch/x86/hvm/ioreq.c
@@ -336,6 +336,13 @@ void arch_ioreq_domain_init(struct domain *d)
     register_portio_handler(d, 0xcf8, 4, hvm_access_cf8);
 }
 
+void arch_ioreq_server_create(struct domain *d, int bufioreq_handling,
+                              ioservid_t *id, unsigned int arch_flags)
+{
+    if ( !(arch_flags & X86_SUPPORTS_EXT_DEST_ID) )
+        d->arch.ext_dest_id = false;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/common/ioreq.c b/xen/common/ioreq.c
index 689d256544..d4d5c653c7 100644
--- a/xen/common/ioreq.c
+++ b/xen/common/ioreq.c
@@ -636,7 +636,7 @@ static void ioreq_server_deinit(struct ioreq_server *s)
 }
 
 static int ioreq_server_create(struct domain *d, int bufioreq_handling,
-                               ioservid_t *id)
+                               ioservid_t *id, unsigned int arch_flags)
 {
     struct ioreq_server *s;
     unsigned int i;
@@ -681,6 +681,8 @@ static int ioreq_server_create(struct domain *d, int 
bufioreq_handling,
     if ( id )
         *id = i;
 
+    arch_ioreq_server_create(d, bufioreq_handling, id, arch_flags);
+
     spin_unlock_recursive(&d->ioreq_server.lock);
     domain_unpause(d);
 
@@ -1340,11 +1342,11 @@ int ioreq_server_dm_op(struct xen_dm_op *op, struct 
domain *d, bool *const_op)
         *const_op = false;
 
         rc = -EINVAL;
-        if ( data->pad[0] || data->pad[1] || data->pad[2] )
+        if ( data->pad[0] || data->pad[1] )
             break;
 
         rc = ioreq_server_create(d, data->handle_bufioreq,
-                                 &data->id);
+                                 &data->id, data->arch_flags);
         break;
     }
 
diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h
index fa3f083fed..c6c575328b 100644
--- a/xen/include/public/hvm/dm_op.h
+++ b/xen/include/public/hvm/dm_op.h
@@ -67,7 +67,11 @@ typedef uint16_t ioservid_t;
 struct xen_dm_op_create_ioreq_server {
     /* IN - should server handle buffered ioreqs */
     uint8_t handle_bufioreq;
-    uint8_t pad[3];
+
+/* Signals Xen the emulator supports the Extended Destination ID field. */
+#define X86_SUPPORTS_EXT_DEST_ID (1u << 0)
+    uint8_t arch_flags;
+    uint8_t pad[2];
     /* OUT - server id */
     ioservid_t id;
 };
diff --git a/xen/include/xen/ioreq.h b/xen/include/xen/ioreq.h
index a26614d331..f4566a1254 100644
--- a/xen/include/xen/ioreq.h
+++ b/xen/include/xen/ioreq.h
@@ -127,6 +127,8 @@ bool arch_ioreq_server_destroy_all(struct domain *d);
 bool arch_ioreq_server_get_type_addr(const struct domain *d, const ioreq_t *p,
                                      uint8_t *type, uint64_t *addr);
 void arch_ioreq_domain_init(struct domain *d);
+void arch_ioreq_server_create(struct domain *d, int bufioreq_handling,
+                              ioservid_t *id, unsigned int arch_flags);
 
 #endif /* __XEN_IOREQ_H__ */
 
-- 
2.34.1




 


Rackspace

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