From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58633) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpENo-000530-5V for qemu-devel@nongnu.org; Wed, 28 Sep 2016 08:54:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpENj-00041o-6V for qemu-devel@nongnu.org; Wed, 28 Sep 2016 08:54:44 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57000) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpENj-00040w-0M for qemu-devel@nongnu.org; Wed, 28 Sep 2016 08:54:39 -0400 From: Gerd Hoffmann Date: Wed, 28 Sep 2016 14:54:29 +0200 Message-Id: <1475067272-11714-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1475067272-11714-1-git-send-email-kraxel@redhat.com> References: <1475067272-11714-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 2/5] ps2: correctly handle 'get/set scancode' command List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Gerd Hoffmann From: Herv=C3=A9 Poussineau When getting scancode, current scancode must be preceded from reply ack. When setting scancode, we must reject invalid scancodes. Signed-off-by: Herv=C3=A9 Poussineau Message-id: 1473969987-5890-3-git-send-email-hpoussin@reactos.org Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 00a1792..2105e51 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -296,16 +296,18 @@ void ps2_write_keyboard(void *opaque, int val) break; case KBD_CMD_SCANCODE: if (val =3D=3D 0) { + ps2_queue(&s->common, KBD_REPLY_ACK); if (s->scancode_set =3D=3D 1) ps2_put_keycode(s, 0x43); else if (s->scancode_set =3D=3D 2) ps2_put_keycode(s, 0x41); else if (s->scancode_set =3D=3D 3) ps2_put_keycode(s, 0x3f); - } else { - if (val >=3D 1 && val <=3D 3) - s->scancode_set =3D val; + } else if (val >=3D 1 && val <=3D 3) { + s->scancode_set =3D val; ps2_queue(&s->common, KBD_REPLY_ACK); + } else { + ps2_queue(&s->common, KBD_REPLY_RESEND); } s->common.write_cmd =3D -1; break; --=20 1.8.3.1