9290838
From ef07a05e357649d52058bcd980924b107a85fb56 Mon Sep 17 00:00:00 2001
c8dfc65
From: Hans de Goede <hdegoede@redhat.com>
c8dfc65
Date: Mon, 3 Sep 2012 12:04:49 +0200
5544c1b
Subject: [PATCH] usb-redir: Ensure our peer has the necessary caps when
5544c1b
 redirecting to XHCI
c8dfc65
c8dfc65
In order for redirection to work properly when redirecting to an emulated
c8dfc65
XHCI controller, the usb-redir-host must support both
c8dfc65
usb_redir_cap_ep_info_max_packet_size and usb_redir_cap_64bits_ids,
c8dfc65
reject any devices redirected to an XHCI controller when these are not
c8dfc65
supported.
c8dfc65
c8dfc65
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
c8dfc65
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
c8dfc65
---
c8dfc65
 hw/usb/redirect.c | 11 +++++++++++
c8dfc65
 1 file changed, 11 insertions(+)
c8dfc65
c8dfc65
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
5544c1b
index a590cb2..f1bb692 100644
c8dfc65
--- a/hw/usb/redirect.c
c8dfc65
+++ b/hw/usb/redirect.c
5544c1b
@@ -833,6 +833,17 @@ static void usbredir_do_attach(void *opaque)
c8dfc65
 {
c8dfc65
     USBRedirDevice *dev = opaque;
c8dfc65
 
c8dfc65
+    /* In order to work properly with XHCI controllers we need these caps */
c8dfc65
+    if ((dev->dev.port->speedmask & USB_SPEED_MASK_SUPER) && !(
c8dfc65
+        usbredirparser_peer_has_cap(dev->parser,
c8dfc65
+                                    usb_redir_cap_ep_info_max_packet_size) &&
c8dfc65
+        usbredirparser_peer_has_cap(dev->parser,
c8dfc65
+                                    usb_redir_cap_64bits_ids))) {
c8dfc65
+        ERROR("usb-redir-host lacks capabilities needed for use with XHCI\n");
c8dfc65
+        usbredir_reject_device(dev);
c8dfc65
+        return;
c8dfc65
+    }
c8dfc65
+
c8dfc65
     if (usb_device_attach(&dev->dev) != 0) {
c8dfc65
         usbredir_reject_device(dev);
c8dfc65
     }