From nobody Sat Nov 1 07:32:25 2025 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.zohomail.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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1526377515843834.3002207387427; Tue, 15 May 2018 02:45:15 -0700 (PDT) Received: from localhost ([::1]:55124 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIWW3-00044z-HU for importer@patchew.org; Tue, 15 May 2018 05:45:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fIWUa-0002wy-TG for qemu-devel@nongnu.org; Tue, 15 May 2018 05:43:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fIWUX-0004ut-QN for qemu-devel@nongnu.org; Tue, 15 May 2018 05:43:36 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:37044 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fIWUX-0004tg-MR for qemu-devel@nongnu.org; Tue, 15 May 2018 05:43:33 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A2424021BA0; Tue, 15 May 2018 09:43:33 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-116-49.ams2.redhat.com [10.36.116.49]) by smtp.corp.redhat.com (Postfix) with ESMTP id C14DF215CDA7; Tue, 15 May 2018 09:43:32 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1A1FE31F23; Tue, 15 May 2018 11:43:32 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Tue, 15 May 2018 11:43:31 +0200 Message-Id: <20180515094332.4907-2-kraxel@redhat.com> In-Reply-To: <20180515094332.4907-1-kraxel@redhat.com> References: <20180515094332.4907-1-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 15 May 2018 09:43:33 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 15 May 2018 09:43:33 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'kraxel@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 1/2] ps2: Clear the PS/2 queue and obey disable 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: Geoffrey McRae , 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: Geoffrey McRae This allows guest's to correctly reinitialize and identify the mouse should the guest decide to re-scan or reset during mouse input events. When the guest sends the "Identify" command, due to the PC's hardware architecutre it is impossible to reliably determine the response from the command amongst other streaming data, such as mouse or keyboard events. Standard practice is for the guest to disable the device and then issue the identify command, so this must be obeyed. Signed-off-by: Geoffrey McRae Message-Id: <20180507150303.7486B381924@moya.office.hostfission.com> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 06f5d2ac4a..4abc8cecdd 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -232,6 +232,11 @@ static void ps2_keyboard_event(DeviceState *dev, QemuC= onsole *src, uint16_t keycode =3D 0; int mod; =20 + /* do not process events while disabled to prevent stream corruption */ + if (!s->scan_enabled) { + return; + } + qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); assert(evt->type =3D=3D INPUT_EVENT_KIND_KEY); qcode =3D qemu_input_key_value_to_qcode(key->key); @@ -673,6 +678,11 @@ static void ps2_mouse_sync(DeviceState *dev) { PS2MouseState *s =3D (PS2MouseState *)dev; =20 + /* do not sync while disabled to prevent stream corruption */ + if (!(s->mouse_status & MOUSE_STATUS_ENABLED)) { + return; + } + if (s->mouse_buttons) { qemu_system_wakeup_request(QEMU_WAKEUP_REASON_OTHER); } @@ -776,6 +786,7 @@ void ps2_write_mouse(void *opaque, int val) s->mouse_resolution =3D 2; s->mouse_status =3D 0; s->mouse_type =3D 0; + ps2_reset_queue(&s->common); ps2_queue(&s->common, AUX_ACK); ps2_queue(&s->common, 0xaa); ps2_queue(&s->common, s->mouse_type); --=20 2.9.3