From nobody Thu May 2 15:25:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148638094135379.32469198218962; Mon, 6 Feb 2017 03:35:41 -0800 (PST) Received: from localhost ([::1]:46785 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caha8-0007P0-2B for importer@patchew.org; Mon, 06 Feb 2017 06:35:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahTN-0002LH-Ee for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cahTJ-0002wG-Dl for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55018) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cahTJ-0002vJ-6c for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:37 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DF73480F7C; Mon, 6 Feb 2017 11:28:36 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16BSZiW005685; Mon, 6 Feb 2017 06:28:36 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 8AF048088D; Mon, 6 Feb 2017 12:28:33 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 12:28:13 +0100 Message-Id: <1486380501-13431-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1486380501-13431-1-git-send-email-kraxel@redhat.com> References: <1486380501-13431-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 06 Feb 2017 11:28:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/9] hw/usb/dev-hid: Improve guest compatibility of usb-tablet X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Phil Dennis-Jordan , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Phil Dennis-Jordan 1. Set bInterfaceProtocol to 0x00 for usb-tablet. This should be non-zero for boot protocol devices only, which the usb-tablet is not. 2. Set the usb-tablet's usage to "mouse" in the report descriptor. The boot protocol of 0x02 specifically confused OS X/macOS' HID driver stack, causing it to generate additional bogus HID events with relative motion in addition to the tablet's absolute coordinate events. Absolute pointing devices with HID Report Descriptor usage of 0x01 (pointing) are treated by the macOS HID driver as analog sticks, and absolute coordinates are not directly translated to absolute mouse cursor positions. Changing it to 0x02 (mouse) fixes the problem, and does not have any adverse effect in other operating systems and windowing systems. (VMWare does the same thing.) Signed-off-by: Phil Dennis-Jordan Message-id: 1485365075-32702-1-git-send-email-phil@philjordan.eu Signed-off-by: Gerd Hoffmann --- hw/usb/dev-hid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/usb/dev-hid.c b/hw/usb/dev-hid.c index 24d05f7..dda0bf0 100644 --- a/hw/usb/dev-hid.c +++ b/hw/usb/dev-hid.c @@ -144,7 +144,7 @@ static const USBDescIface desc_iface_tablet =3D { .bInterfaceNumber =3D 0, .bNumEndpoints =3D 1, .bInterfaceClass =3D USB_CLASS_HID, - .bInterfaceProtocol =3D 0x02, + .bInterfaceProtocol =3D 0x00, .ndesc =3D 1, .descs =3D (USBDescOther[]) { { @@ -174,7 +174,7 @@ static const USBDescIface desc_iface_tablet2 =3D { .bInterfaceNumber =3D 0, .bNumEndpoints =3D 1, .bInterfaceClass =3D USB_CLASS_HID, - .bInterfaceProtocol =3D 0x02, + .bInterfaceProtocol =3D 0x00, .ndesc =3D 1, .descs =3D (USBDescOther[]) { { @@ -487,7 +487,7 @@ static const uint8_t qemu_mouse_hid_report_descriptor[]= =3D { =20 static const uint8_t qemu_tablet_hid_report_descriptor[] =3D { 0x05, 0x01, /* Usage Page (Generic Desktop) */ - 0x09, 0x01, /* Usage (Pointer) */ + 0x09, 0x02, /* Usage (Mouse) */ 0xa1, 0x01, /* Collection (Application) */ 0x09, 0x01, /* Usage (Pointer) */ 0xa1, 0x00, /* Collection (Physical) */ --=20 1.8.3.1 From nobody Thu May 2 15:25:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148638121477838.26681250858701; Mon, 6 Feb 2017 03:40:14 -0800 (PST) Received: from localhost ([::1]:46811 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caheX-0002o6-Cl for importer@patchew.org; Mon, 06 Feb 2017 06:40:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43108) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahTN-0002LD-Bb for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cahTJ-0002vy-CS for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50074) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cahTJ-0002vA-5Q for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:37 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AB79C3B71B for ; Mon, 6 Feb 2017 11:28:36 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16BSZFN014518; Mon, 6 Feb 2017 06:28:36 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 9D67180837; Mon, 6 Feb 2017 12:28:33 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 12:28:14 +0100 Message-Id: <1486380501-13431-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1486380501-13431-1-git-send-email-kraxel@redhat.com> References: <1486380501-13431-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 06 Feb 2017 11:28:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/9] usb/uas: more verbose error message X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Print some more details in case we get a unknown control request, to ease trouble-shooting. Signed-off-by: Gerd Hoffmann Message-id: 1485870727-21956-1-git-send-email-kraxel@redhat.com --- hw/usb/dev-uas.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/usb/dev-uas.c b/hw/usb/dev-uas.c index 3a8ff18..da2fb70 100644 --- a/hw/usb/dev-uas.c +++ b/hw/usb/dev-uas.c @@ -653,7 +653,8 @@ static void usb_uas_handle_control(USBDevice *dev, USBP= acket *p, if (ret >=3D 0) { return; } - error_report("%s: unhandled control request", __func__); + error_report("%s: unhandled control request (req 0x%x, val 0x%x, idx 0= x%x", + __func__, request, value, index); p->status =3D USB_RET_STALL; } =20 --=20 1.8.3.1 From nobody Thu May 2 15:25:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486380945429247.0850932387607; Mon, 6 Feb 2017 03:35:45 -0800 (PST) Received: from localhost ([::1]:46786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahaB-0007RU-Lo for importer@patchew.org; Mon, 06 Feb 2017 06:35:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43120) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahTN-0002LI-Et for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cahTJ-0002vt-BQ for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39978) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cahTJ-0002v3-5X for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:37 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8ECE264D9B for ; Mon, 6 Feb 2017 11:28:36 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16BSZDa030570; Mon, 6 Feb 2017 06:28:36 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id B17018092B; Mon, 6 Feb 2017 12:28:33 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 12:28:15 +0100 Message-Id: <1486380501-13431-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1486380501-13431-1-git-send-email-kraxel@redhat.com> References: <1486380501-13431-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 06 Feb 2017 11:28:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/9] usb: accept usb3 control requests X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Windows 10 reportedly sends these, so accept them in case the device in question is a superspeed (usb3) device. Signed-off-by: Gerd Hoffmann Message-id: 1485870727-21956-2-git-send-email-kraxel@redhat.com --- hw/usb/desc.c | 7 +++++++ include/hw/usb.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/hw/usb/desc.c b/hw/usb/desc.c index 7828e52..c36bf30 100644 --- a/hw/usb/desc.c +++ b/hw/usb/desc.c @@ -774,6 +774,13 @@ int usb_desc_handle_control(USBDevice *dev, USBPacket = *p, trace_usb_set_device_feature(dev->addr, value, ret); break; =20 + case DeviceOutRequest | USB_REQ_SET_SEL: + case DeviceOutRequest | USB_REQ_SET_ISOCH_DELAY: + if (dev->speed =3D=3D USB_SPEED_SUPER) { + ret =3D 0; + } + break; + case InterfaceRequest | USB_REQ_GET_INTERFACE: if (index < 0 || index >=3D dev->ninterfaces) { break; diff --git a/include/hw/usb.h b/include/hw/usb.h index 43838c9..c42b29c 100644 --- a/include/hw/usb.h +++ b/include/hw/usb.h @@ -135,6 +135,8 @@ #define USB_REQ_GET_INTERFACE 0x0A #define USB_REQ_SET_INTERFACE 0x0B #define USB_REQ_SYNCH_FRAME 0x0C +#define USB_REQ_SET_SEL 0x30 +#define USB_REQ_SET_ISOCH_DELAY 0x31 =20 #define USB_DEVICE_SELF_POWERED 0 #define USB_DEVICE_REMOTE_WAKEUP 1 --=20 1.8.3.1 From nobody Thu May 2 15:25:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148638093842674.85224363875204; Mon, 6 Feb 2017 03:35:38 -0800 (PST) Received: from localhost ([::1]:46783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caha4-0007Mv-0O for importer@patchew.org; Mon, 06 Feb 2017 06:35:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43106) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahTN-0002LB-BK for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cahTJ-0002vz-BU for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36512) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cahTJ-0002vB-5a for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:37 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A3DED85363; Mon, 6 Feb 2017 11:28:36 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16BSZMp030804; Mon, 6 Feb 2017 06:28:36 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id C125C8093B; Mon, 6 Feb 2017 12:28:33 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 12:28:16 +0100 Message-Id: <1486380501-13431-5-git-send-email-kraxel@redhat.com> In-Reply-To: <1486380501-13431-1-git-send-email-kraxel@redhat.com> References: <1486380501-13431-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 06 Feb 2017 11:28:36 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 4/9] xhci: only free completed transfers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , 1653384@bugs.launchpad.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Most callsites check already, one was missed. Cc: 1653384@bugs.launchpad.net Fixes: 94b037f2a451b3dc855f9f2c346e5049a361bd55 Reported-by: Fabian Lesniak Signed-off-by: Gerd Hoffmann Message-id: 1485790607-31399-2-git-send-email-kraxel@redhat.com --- hw/usb/hcd-xhci.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index f810678..6a1d3dc 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2198,7 +2198,9 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, uns= igned int streamid) xhci_complete_packet(xfer); } assert(!xfer->running_retry); - xhci_ep_free_xfer(epctx->retry); + if (xfer->complete) { + xhci_ep_free_xfer(epctx->retry); + } epctx->retry =3D NULL; } =20 --=20 1.8.3.1 From nobody Thu May 2 15:25:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486380646513687.9623012844166; Mon, 6 Feb 2017 03:30:46 -0800 (PST) Received: from localhost ([::1]:46768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahVN-0003Xq-6j for importer@patchew.org; Mon, 06 Feb 2017 06:30:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahTN-0002LG-Cc for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cahTJ-0002wU-OA for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39980) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cahTJ-0002vb-JD for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:37 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C47B26572D for ; Mon, 6 Feb 2017 11:28:37 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16BSaNe030823; Mon, 6 Feb 2017 06:28:37 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id D18BF80979; Mon, 6 Feb 2017 12:28:33 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 12:28:17 +0100 Message-Id: <1486380501-13431-6-git-send-email-kraxel@redhat.com> In-Reply-To: <1486380501-13431-1-git-send-email-kraxel@redhat.com> References: <1486380501-13431-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 06 Feb 2017 11:28:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 5/9] xhci: rename xhci_complete_packet to xhci_try_complete_packet X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Make clear that this isn't guaranteed to actually complete the transfer, the usb packet can still be in flight after calling that function. Signed-off-by: Gerd Hoffmann Message-id: 1485790607-31399-3-git-send-email-kraxel@redhat.com --- hw/usb/hcd-xhci.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 6a1d3dc..7e863d3 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -1897,7 +1897,7 @@ static int xhci_setup_packet(XHCITransfer *xfer) return 0; } =20 -static int xhci_complete_packet(XHCITransfer *xfer) +static int xhci_try_complete_packet(XHCITransfer *xfer) { if (xfer->packet.status =3D=3D USB_RET_ASYNC) { trace_usb_xhci_xfer_async(xfer); @@ -2002,7 +2002,7 @@ static int xhci_fire_ctl_transfer(XHCIState *xhci, XH= CITransfer *xfer) =20 usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); =20 - xhci_complete_packet(xfer); + xhci_try_complete_packet(xfer); if (!xfer->running_async && !xfer->running_retry) { xhci_kick_epctx(xfer->epctx, 0); } @@ -2106,7 +2106,7 @@ static int xhci_submit(XHCIState *xhci, XHCITransfer = *xfer, XHCIEPContext *epctx } usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); =20 - xhci_complete_packet(xfer); + xhci_try_complete_packet(xfer); if (!xfer->running_async && !xfer->running_retry) { xhci_kick_epctx(xfer->epctx, xfer->streamid); } @@ -2185,7 +2185,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, uns= igned int streamid) } usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); assert(xfer->packet.status !=3D USB_RET_NAK); - xhci_complete_packet(xfer); + xhci_try_complete_packet(xfer); } else { /* retry nak'ed transfer */ if (xhci_setup_packet(xfer) < 0) { @@ -2195,7 +2195,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, uns= igned int streamid) if (xfer->packet.status =3D=3D USB_RET_NAK) { return; } - xhci_complete_packet(xfer); + xhci_try_complete_packet(xfer); } assert(!xfer->running_retry); if (xfer->complete) { @@ -3492,7 +3492,7 @@ static void xhci_complete(USBPort *port, USBPacket *p= acket) xhci_ep_nuke_one_xfer(xfer, 0); return; } - xhci_complete_packet(xfer); + xhci_try_complete_packet(xfer); xhci_kick_epctx(xfer->epctx, xfer->streamid); if (xfer->complete) { xhci_ep_free_xfer(xfer); --=20 1.8.3.1 From nobody Thu May 2 15:25:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 148638064741727.011861933789874; Mon, 6 Feb 2017 03:30:47 -0800 (PST) Received: from localhost ([::1]:46767 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahVM-0003WX-3t for importer@patchew.org; Mon, 06 Feb 2017 06:30:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahTN-0002LC-BR for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cahTJ-0002wM-Kr for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:59738) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cahTJ-0002vZ-G8 for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:37 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A24808046C; Mon, 6 Feb 2017 11:28:37 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5521D16998; Mon, 6 Feb 2017 11:28:37 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id E227B809B4; Mon, 6 Feb 2017 12:28:33 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 12:28:18 +0100 Message-Id: <1486380501-13431-7-git-send-email-kraxel@redhat.com> In-Reply-To: <1486380501-13431-1-git-send-email-kraxel@redhat.com> References: <1486380501-13431-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 06 Feb 2017 11:28:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 6/9] xhci: don't kick in xhci_submit and xhci_fire_ctl_transfer X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , 1653384@bugs.launchpad.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" xhci_submit and xhci_fire_ctl_transfer are is called from xhci_kick_epctx processing loop only, so there is no need to call xhci_kick_epctx make sure processing continues. Also eecursive calls into xhci_kick_epctx can cause trouble. Drop the xhci_kick_epctx calls. Cc: 1653384@bugs.launchpad.net Fixes: 94b037f2a451b3dc855f9f2c346e5049a361bd55 Reported-by: Fabian Lesniak Signed-off-by: Gerd Hoffmann Message-id: 1485790607-31399-4-git-send-email-kraxel@redhat.com --- hw/usb/hcd-xhci.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 7e863d3..f89d8da 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -2001,11 +2001,7 @@ static int xhci_fire_ctl_transfer(XHCIState *xhci, X= HCITransfer *xfer) xfer->packet.parameter =3D trb_setup->parameter; =20 usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); - xhci_try_complete_packet(xfer); - if (!xfer->running_async && !xfer->running_retry) { - xhci_kick_epctx(xfer->epctx, 0); - } return 0; } =20 @@ -2105,11 +2101,7 @@ static int xhci_submit(XHCIState *xhci, XHCITransfer= *xfer, XHCIEPContext *epctx return -1; } usb_handle_packet(xfer->packet.ep->dev, &xfer->packet); - xhci_try_complete_packet(xfer); - if (!xfer->running_async && !xfer->running_retry) { - xhci_kick_epctx(xfer->epctx, xfer->streamid); - } return 0; } =20 --=20 1.8.3.1 From nobody Thu May 2 15:25:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 14863809409131000.7096859328553; Mon, 6 Feb 2017 03:35:40 -0800 (PST) Received: from localhost ([::1]:46784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caha5-0007O3-1k for importer@patchew.org; Mon, 06 Feb 2017 06:35:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43123) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahTN-0002LJ-Hv for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cahTJ-0002wk-UI for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:57072) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cahTJ-0002vf-P3 for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:37 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EAD75C05678D; Mon, 6 Feb 2017 11:28:37 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16BSaFw023811; Mon, 6 Feb 2017 06:28:37 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id F3C7080A03; Mon, 6 Feb 2017 12:28:33 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 12:28:19 +0100 Message-Id: <1486380501-13431-8-git-send-email-kraxel@redhat.com> In-Reply-To: <1486380501-13431-1-git-send-email-kraxel@redhat.com> References: <1486380501-13431-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 06 Feb 2017 11:28:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 7/9] xhci: guard xhci_kick_epctx against recursive calls X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gerd Hoffmann , 1653384@bugs.launchpad.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Track xhci_kick_epctx processing being active in a variable. Check the variable before calling xhci_kick_epctx from xhci_kick_ep. Add an assert to make sure we don't call recursively into xhci_kick_epctx. Cc: 1653384@bugs.launchpad.net Fixes: 94b037f2a451b3dc855f9f2c346e5049a361bd55 Reported-by: Fabian Lesniak Signed-off-by: Gerd Hoffmann Message-id: 1486035372-3621-1-git-send-email-kraxel@redhat.com Message-id: 1485790607-31399-5-git-send-email-kraxel@redhat.com --- hw/usb/hcd-xhci.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index f89d8da..1878dad 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -390,6 +390,7 @@ struct XHCIEPContext { dma_addr_t pctx; unsigned int max_psize; uint32_t state; + uint32_t kick_active; =20 /* streams */ unsigned int max_pstreams; @@ -2131,6 +2132,9 @@ static void xhci_kick_ep(XHCIState *xhci, unsigned in= t slotid, return; } =20 + if (epctx->kick_active) { + return; + } xhci_kick_epctx(epctx, streamid); } =20 @@ -2146,6 +2150,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, uns= igned int streamid) int i; =20 trace_usb_xhci_ep_kick(epctx->slotid, epctx->epid, streamid); + assert(!epctx->kick_active); =20 /* If the device has been detached, but the guest has not noticed this yet the 2 above checks will succeed, but we must NOT continue */ @@ -2217,6 +2222,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, uns= igned int streamid) } assert(ring->dequeue !=3D 0); =20 + epctx->kick_active++; while (1) { length =3D xhci_ring_chain_length(xhci, ring); if (length <=3D 0) { @@ -2253,6 +2259,7 @@ static void xhci_kick_epctx(XHCIEPContext *epctx, uns= igned int streamid) break; } } + epctx->kick_active--; =20 ep =3D xhci_epid_to_usbep(epctx); if (ep) { --=20 1.8.3.1 From nobody Thu May 2 15:25:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486380644114304.5928221153125; Mon, 6 Feb 2017 03:30:44 -0800 (PST) Received: from localhost ([::1]:46761 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahVI-0003Rx-05 for importer@patchew.org; Mon, 06 Feb 2017 06:30:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43109) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahTN-0002LE-BT for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cahTJ-0002wa-QO for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:35196) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cahTJ-0002vd-LS for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:37 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D1AC2C04B327; Mon, 6 Feb 2017 11:28:37 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A2E116A6B; Mon, 6 Feb 2017 11:28:37 +0000 (UTC) Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 1106C80A74; Mon, 6 Feb 2017 12:28:34 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 12:28:20 +0100 Message-Id: <1486380501-13431-9-git-send-email-kraxel@redhat.com> In-Reply-To: <1486380501-13431-1-git-send-email-kraxel@redhat.com> References: <1486380501-13431-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 06 Feb 2017 11:28:37 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 8/9] usb: ccid: check ccid apdu length X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Prasad J Pandit , Gerd Hoffmann Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Prasad J Pandit CCID device emulator uses Application Protocol Data Units(APDU) to exchange command and responses to and from the host. The length in these units couldn't be greater than 65536. Add check to ensure the same. It'd also avoid potential integer overflow in emulated_apdu_from_guest. Reported-by: Li Qiang Signed-off-by: Prasad J Pandit Message-id: 20170202192228.10847-1-ppandit@redhat.com Signed-off-by: Gerd Hoffmann --- hw/usb/dev-smartcard-reader.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/usb/dev-smartcard-reader.c b/hw/usb/dev-smartcard-reader.c index 89e11b6..1325ea1 100644 --- a/hw/usb/dev-smartcard-reader.c +++ b/hw/usb/dev-smartcard-reader.c @@ -967,7 +967,7 @@ static void ccid_on_apdu_from_guest(USBCCIDState *s, CC= ID_XferBlock *recv) DPRINTF(s, 1, "%s: seq %d, len %d\n", __func__, recv->hdr.bSeq, len); ccid_add_pending_answer(s, (CCID_Header *)recv); - if (s->card) { + if (s->card && len <=3D BULK_OUT_DATA_SIZE) { ccid_card_apdu_from_guest(s->card, recv->abData, len); } else { DPRINTF(s, D_WARN, "warning: discarded apdu\n"); --=20 1.8.3.1 From nobody Thu May 2 15:25:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1486381214873535.2165045932118; Mon, 6 Feb 2017 03:40:14 -0800 (PST) Received: from localhost ([::1]:46813 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1caheX-0002on-Kq for importer@patchew.org; Mon, 06 Feb 2017 06:40:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43126) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cahTN-0002LK-Vy for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cahTK-0002wt-2P for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:51508) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cahTJ-0002vj-RM for qemu-devel@nongnu.org; Mon, 06 Feb 2017 06:28:38 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F397B19D05F; Mon, 6 Feb 2017 11:28:37 +0000 (UTC) Received: from nilsson.home.kraxel.org (ovpn-116-97.ams2.redhat.com [10.36.116.97]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v16BSaDD014522; Mon, 6 Feb 2017 06:28:37 -0500 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 20899808C1; Mon, 6 Feb 2017 12:28:34 +0100 (CET) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 6 Feb 2017 12:28:21 +0100 Message-Id: <1486380501-13431-10-git-send-email-kraxel@redhat.com> In-Reply-To: <1486380501-13431-1-git-send-email-kraxel@redhat.com> References: <1486380501-13431-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 06 Feb 2017 11:28:38 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 9/9] xhci: fix event queue IRQ handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 1373228@bugs.launchpad.net, Gerd Hoffmann , M.Cerveny@computer.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The qemu xhci emulation doesn't handle the ERDP_EHB flag correctly. When the host adapter queues a new event the ERDP_EHB flag is set. The flag is cleared (via w1c) by the guest when it updates the ERDP (event ring dequeue pointer) register to notify the host adapter which events it has fetched. An IRQ must be raised in case the ERDP_EHB flag flips from clear to set. If the flag is set already (which implies there are events queued up which are not yet processed by the guest) xhci must *not* raise a IRQ. Qemu got that wrong and raised an IRQ on every event, thereby generating spurious interrupts in case we've queued events faster than the guest processed them. This patch fixes that. With that change in place we also have to check ERDP updates, to see whenever the guest has fetched all queued events. In case there are still pending events set ERDP_EHB and raise an IRQ again, to make sure the events don't linger unseen forever. The linux kernel driver and the microsoft windows driver (shipped with win8+) can deal with the spurious interrupts without problems. The renesas windows driver (v2.1.39) which can be used on older windows versions is quite upset though. It does spurious ERDP updates now and then (not every time, seems we must hit a race window for this to happen), which in turn makes the qemu xhci emulation think the event ring is full. Things go south from here ... tl;dr: This is the "fix xhci on win7" patch. Cc: M.Cerveny@computer.org Cc: 1373228@bugs.launchpad.net Signed-off-by: Gerd Hoffmann Message-id: 1486104705-13761-1-git-send-email-kraxel@redhat.com --- hw/usb/hcd-xhci.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/usb/hcd-xhci.c b/hw/usb/hcd-xhci.c index 1878dad..54b3901 100644 --- a/hw/usb/hcd-xhci.c +++ b/hw/usb/hcd-xhci.c @@ -789,11 +789,15 @@ static void xhci_msix_update(XHCIState *xhci, int v) static void xhci_intr_raise(XHCIState *xhci, int v) { PCIDevice *pci_dev =3D PCI_DEVICE(xhci); + bool pending =3D (xhci->intr[v].erdp_low & ERDP_EHB); =20 xhci->intr[v].erdp_low |=3D ERDP_EHB; xhci->intr[v].iman |=3D IMAN_IP; xhci->usbsts |=3D USBSTS_EINT; =20 + if (pending) { + return; + } if (!(xhci->intr[v].iman & IMAN_IE)) { return; } @@ -3352,6 +3356,15 @@ static void xhci_runtime_write(void *ptr, hwaddr reg, intr->erdp_low &=3D ~ERDP_EHB; } intr->erdp_low =3D (val & ~ERDP_EHB) | (intr->erdp_low & ERDP_EHB); + if (val & ERDP_EHB) { + dma_addr_t erdp =3D xhci_addr64(intr->erdp_low, intr->erdp_hig= h); + unsigned int dp_idx =3D (erdp - intr->er_start) / TRB_SIZE; + if (erdp >=3D intr->er_start && + erdp < (intr->er_start + TRB_SIZE * intr->er_size) && + dp_idx !=3D intr->er_ep_idx) { + xhci_intr_raise(xhci, v); + } + } break; case 0x1c: /* ERDP high */ intr->erdp_high =3D val; --=20 1.8.3.1