render / rpms / qemu

Forked from rpms/qemu 10 months ago
Clone

Blame 0140-usb-ehci-sanity-check-iso-xfers.patch

Hans de Goede 1b1995
From 985b7cfbd45960bb74a13ad8044765a8e35f2251 Mon Sep 17 00:00:00 2001
Hans de Goede 1b1995
From: Gerd Hoffmann <kraxel@redhat.com>
Hans de Goede 1b1995
Date: Sun, 4 Mar 2012 12:41:11 +0100
Hans de Goede 1b1995
Subject: [PATCH 140/140] usb-ehci: sanity-check iso xfers
Hans de Goede 1b1995
Hans de Goede 1b1995
This patch adds a sanity check to itd processing to make sure the
Hans de Goede 1b1995
endpoint addressed by the guest is actually an iso endpoint.  Also
Hans de Goede 1b1995
verify that usb drivers don't return USB_RET_ASYNC which is illegal for
Hans de Goede 1b1995
iso xfers.
Hans de Goede 1b1995
Hans de Goede 1b1995
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Hans de Goede 1b1995
(Cherry picked from: aa0568ff2559d7717f4684af6a83d0bd1a125f56)
Hans de Goede 1b1995
Hans de Goede 1b1995
[qemu-kvm-1.0: we don't track ep types on RHEL-6 like we do upstream, so we
Hans de Goede 1b1995
cannot check if an itd is pointing to a non iso ep in advance, but we do still
Hans de Goede 1b1995
need to make sure that we never handle an iso xfer async. So check if the
Hans de Goede 1b1995
device does want to handle it async, and if so cancel the xfer and treat it as
Hans de Goede 1b1995
a NAK, like upstream does when the ep type check fails.]
Hans de Goede 1b1995
Hans de Goede 1b1995
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Hans de Goede 1b1995
---
Hans de Goede 1b1995
 hw/usb-ehci.c |    4 ++++
Hans de Goede 1b1995
 1 file changed, 4 insertions(+)
Hans de Goede 1b1995
Hans de Goede 1b1995
diff --git a/hw/usb-ehci.c b/hw/usb-ehci.c
Hans de Goede 1b1995
index ad0f6e1..b5d7037 100644
Hans de Goede 1b1995
--- a/hw/usb-ehci.c
Hans de Goede 1b1995
+++ b/hw/usb-ehci.c
Hans de Goede 1b1995
@@ -1485,6 +1485,10 @@ static int ehci_process_itd(EHCIState *ehci,
Hans de Goede 1b1995
                     itd->transact[i] |= ITD_XACT_BABBLE;
Hans de Goede 1b1995
                     ehci_record_interrupt(ehci, USBSTS_ERRINT);
Hans de Goede 1b1995
                     break;
Hans de Goede 1b1995
+                case USB_RET_ASYNC:
Hans de Goede 1b1995
+                    /* ISO endpoints are never ASYNC, not an iso endpoint? */
Hans de Goede 1b1995
+                    usb_cancel_packet(&ehci->ipacket);
Hans de Goede 1b1995
+                    /* Treat this as a NAK (fall through) */
Hans de Goede 1b1995
                 case USB_RET_NAK:
Hans de Goede 1b1995
                     /* no data for us, so do a zero-length transfer */
Hans de Goede 1b1995
                     ret = 0;
Hans de Goede 1b1995
-- 
Hans de Goede 1b1995
1.7.9.3
Hans de Goede 1b1995