5544c1b
From 074f49c02e7f2fd50533a246b4060051f95f8b09 Mon Sep 17 00:00:00 2001
c8dfc65
From: Hans de Goede <hdegoede@redhat.com>
c8dfc65
Date: Fri, 17 Aug 2012 11:39:16 +0200
5544c1b
Subject: [PATCH] usb: controllers do not need to check for babble themselves
c8dfc65
c8dfc65
If an (emulated) usb-device tries to write more data to a packet then
c8dfc65
its iov len, this will trigger an assert in usb_packet_copy(), and if
c8dfc65
a driver somehow circumvents that check and writes more data to the
c8dfc65
iov then there is space, we have a much bigger problem then not correctly
c8dfc65
reporting babble to the guest.
c8dfc65
c8dfc65
In practice babble will only happen with (real) redirected devices, and there
c8dfc65
both the usb-host os and the qemu usb-device code already check for it.
c8dfc65
c8dfc65
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
c8dfc65
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
5544c1b
(cherry picked from commit 45b339b18c660eb85af2ba25bfcaed5469660d77)
5544c1b
5544c1b
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
c8dfc65
---
c8dfc65
 hw/usb/hcd-ehci.c | 4 ----
c8dfc65
 hw/usb/hcd-uhci.c | 5 -----
c8dfc65
 2 files changed, 9 deletions(-)
c8dfc65
c8dfc65
diff --git a/hw/usb/hcd-ehci.c b/hw/usb/hcd-ehci.c
c8dfc65
index 017342b..9523247 100644
c8dfc65
--- a/hw/usb/hcd-ehci.c
c8dfc65
+++ b/hw/usb/hcd-ehci.c
c8dfc65
@@ -1481,10 +1481,6 @@ static void ehci_execute_complete(EHCIQueue *q)
c8dfc65
             assert(0);
c8dfc65
             break;
c8dfc65
         }
c8dfc65
-    } else if ((p->usb_status > p->tbytes) && (p->pid == USB_TOKEN_IN)) {
c8dfc65
-        p->usb_status = USB_RET_BABBLE;
c8dfc65
-        q->qh.token |= (QTD_TOKEN_HALT | QTD_TOKEN_BABBLE);
c8dfc65
-        ehci_raise_irq(q->ehci, USBSTS_ERRINT);
c8dfc65
     } else {
c8dfc65
         // TODO check 4.12 for splits
c8dfc65
 
c8dfc65
diff --git a/hw/usb/hcd-uhci.c b/hw/usb/hcd-uhci.c
c8dfc65
index b0db921..c7c8786 100644
c8dfc65
--- a/hw/usb/hcd-uhci.c
c8dfc65
+++ b/hw/usb/hcd-uhci.c
c8dfc65
@@ -729,11 +729,6 @@ static int uhci_complete_td(UHCIState *s, UHCI_TD *td, UHCIAsync *async, uint32_
c8dfc65
         *int_mask |= 0x01;
c8dfc65
 
c8dfc65
     if (pid == USB_TOKEN_IN) {
c8dfc65
-        if (len > max_len) {
c8dfc65
-            ret = USB_RET_BABBLE;
c8dfc65
-            goto out;
c8dfc65
-        }
c8dfc65
-
c8dfc65
         if ((td->ctrl & TD_CTRL_SPD) && len < max_len) {
c8dfc65
             *int_mask |= 0x02;
c8dfc65
             /* short packet: do not update QH */