From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038320; cv=none; d=zohomail.com; s=zohoarc; b=F1eXr87ujmcL/EUnMrIPbmjYSYlDXY5J8PMYyjdAoOsBWdOKRUjENV4ItNKcZElg8Xgj0zyV0aspOnTqfXLV2ph7mnLt8tSeD/CsiXqiHZheMWQ3t/FhS+5r44T2KUIauBvHcIzvzLHyQuCZYA/x/VZGLeOTPIAgP5ZLKZ4brO0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038320; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2pXx6GyMHS25jso5WEPUuISioE99hR5k3RFrVIBZbIU=; b=cI6nb9f65PYVYsdGB/u2gm7KMwi7kUt/J3NcapzyoT1OFY4PV5aMDGE4cA2tuR1CKvFXoyTNO/PNcAMUS0rgrHuEia8L0dj1i/FQhWfYmVRzkJ9t5Z0pjQrhAo4nObLslMqldpvoDGxq86nJ2fQTvxxRXe3enHij7x9NtfFF6T8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038320368349.53289416463383; Wed, 26 May 2021 07:12:00 -0700 (PDT) Received: from localhost ([::1]:47988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluGN-0002bN-53 for importer2@patchew.org; Wed, 26 May 2021 10:11:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBJ-0002zb-0h for qemu-devel@nongnu.org; Wed, 26 May 2021 10:06:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56800) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBF-0003oN-04 for qemu-devel@nongnu.org; Wed, 26 May 2021 10:06:44 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-287-P5KRL7COOmq3IVAs4eS6hw-1; Wed, 26 May 2021 10:06:37 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D016D107ACC7; Wed, 26 May 2021 14:06:36 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D808C61094; Wed, 26 May 2021 14:06:28 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 73B7418000B9; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622037999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2pXx6GyMHS25jso5WEPUuISioE99hR5k3RFrVIBZbIU=; b=D0nS6miVq60aLgGZeFz6EMDGU+4uy2A1S4PBhGZQSLLFSiY+Wv8XBbb6vbczpYmuQbxIQw gZkzNKVrlKkJ5V/oNrQgs+3jcys1Z8XpZ29xd3xlDPUEJ8UUvonW16wOVkzNsRljnQ1hWE vbFnfS8tYbqNHmGJtUwIxYyT8W1SHVc= X-MC-Unique: P5KRL7COOmq3IVAs4eS6hw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 01/14] hw/input: expand trace info reported for ps2 device Date: Wed, 26 May 2021 16:06:14 +0200 Message-Id: <20210526140627.381857-2-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Eduardo Habkost , "Michael S. Tsirkin" , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Daniel P. Berrang=C3=A9 It is interesting to know if the PS2 keyboard is in translated mode, and which of the three scancode sets are in use. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Daniel P. Berrang=C3=A9 Message-Id: <20210309155804.306051-1-berrange@redhat.com> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 3 ++- hw/input/trace-events | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 72cdb80ae1cd..5352e417a408 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -293,7 +293,8 @@ static void ps2_keyboard_event(DeviceState *dev, QemuCo= nsole *src, qcode =3D qemu_input_key_value_to_qcode(key->key); =20 mod =3D ps2_modifier_bit(qcode); - trace_ps2_keyboard_event(s, qcode, key->down, mod, s->modifiers); + trace_ps2_keyboard_event(s, qcode, key->down, mod, + s->modifiers, s->scancode_set, s->translate); if (key->down) { s->modifiers |=3D mod; } else { diff --git a/hw/input/trace-events b/hw/input/trace-events index 33741e74f5a2..109bdf7a184f 100644 --- a/hw/input/trace-events +++ b/hw/input/trace-events @@ -30,7 +30,7 @@ pckbd_kbd_write_data(uint64_t val) "0x%02"PRIx64 =20 # ps2.c ps2_put_keycode(void *opaque, int keycode) "%p keycode 0x%02x" -ps2_keyboard_event(void *opaque, int qcode, int down, unsigned int modifie= r, unsigned int modifiers) "%p qcode %d down %d modifier 0x%x modifiers 0x%= x" +ps2_keyboard_event(void *opaque, int qcode, int down, unsigned int modifie= r, unsigned int modifiers, int set, int xlate) "%p qcode %d down %d modifie= r 0x%x modifiers 0x%x set %d xlate %d" ps2_read_data(void *opaque) "%p" ps2_set_ledstate(void *s, int ledstate) "%p ledstate %d" ps2_reset_keyboard(void *s) "%p" --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038440; cv=none; d=zohomail.com; s=zohoarc; b=NmSNSa6BEKkZwoqakX79YoNkkvCIO3cmlBvgwkcvYFUbw8+lZdd5HNIHqSir6KLsCRxlkQ+Ww1dtR9nl/DYhkEtx4puY018ZL9xvh7eduhPKCCaaCGViiBiVFxeO4lZv1mPZKAzYtbLuDnYzG/z2/sTKyuC1Tc6OvFFNO3KvsfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038440; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6j6uSV8f20gUUG+tUdrJ3NyF9kzmIJQN9ZIKjubWWU4=; b=ZIjQcQvd+5qNeST9/ANjje0u79HqOtZTrHz0w50y0WQwlwt31QEXQ+oM/P8aIz4XYmmKjfDb2SREhJgWvuWrg9wueCMMuDDJkDbBzTaxrqKtqCZEpWslsTPQ+iX9P6Im5v17gMF/+TsWrm1VVkkwsD7JnV9F2WayK7HMkC8vt8Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038440651573.9428461972061; Wed, 26 May 2021 07:14:00 -0700 (PDT) Received: from localhost ([::1]:56596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluIJ-0008Id-PM for importer2@patchew.org; Wed, 26 May 2021 10:13:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBL-00031o-T3 for qemu-devel@nongnu.org; Wed, 26 May 2021 10:06:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32416) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBG-0003pk-Ms for qemu-devel@nongnu.org; Wed, 26 May 2021 10:06:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-1G0RsTySPT-MDRpSwS4TNQ-1; Wed, 26 May 2021 10:06:40 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2FEF8801107; Wed, 26 May 2021 14:06:39 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BE6691001281; Wed, 26 May 2021 14:06:38 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 7DF76180038E; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6j6uSV8f20gUUG+tUdrJ3NyF9kzmIJQN9ZIKjubWWU4=; b=GZCQfxpjBqU5xrZO76XEVC/KwZz4tZIWzxQaXLwduP+Lt3m27sh4lUKcbF6+Zcqn7wHyrn z59R3mmQer8N3BKk1nw3OypFNBAwpsf2PMXEAtb7LOOdumIirtGOV33llYg9nDZj0w/AvK zRhDLAPcmP0RCppZKbpjkFiRI8P9Lrs= X-MC-Unique: 1G0RsTySPT-MDRpSwS4TNQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 02/14] ps2: fix mouse stream corruption Date: Wed, 26 May 2021 16:06:15 +0200 Message-Id: <20210526140627.381857-3-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin Commit 7abe7eb294 "ps2: Fix mouse stream corruption due to lost data" added code to avoid mouse stream corruptions but the calculation of the needed free queue size was wrong. Fix this. To reproduce, open a text file with the vim 7.3 32 bit for DOS exe- cutable in a FreeDOS client started with -display sdl and move the mouse around for a few seconds. You will quickly see erratic mouse movements and unexpected mouse clicks. CuteMouse (ctmouse.exe) in FreeDOS doesn't try to re-sync the mouse stream. Fixes: 7abe7eb294 ("ps2: Fix mouse stream corruption due to lost data") Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-1-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 5352e417a408..7a3fb2b9f639 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -646,7 +646,8 @@ void ps2_keyboard_set_translation(void *opaque, int mod= e) =20 static int ps2_mouse_send_packet(PS2MouseState *s) { - const int needed =3D 3 + (s->mouse_type - 2); + /* IMPS/2 and IMEX send 4 bytes, PS2 sends 3 bytes */ + const int needed =3D s->mouse_type ? 4 : 3; unsigned int b; int dx1, dy1, dz1; =20 --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038141; cv=none; d=zohomail.com; s=zohoarc; b=mj6OwDzEyttKrUsfTK+11vh2b7D0+I7qV9B8t4Euyrr3+dRt2dkS9IZxeCsCDQXt7BWZzkPpPmIG6ujY8MPMeCBoLdc9ymJIvjCdXshv2YJzBPgvT2G6/w3kFJ9uZkSlq1s9vYF9F2tfkyuuk4UaYT2trD8oYJiIRBFFQbUd8dQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038141; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j+ByWNfBQl077NakT3CN6Nqd8I1j/6kexSaJYZ7FxVU=; b=Nvv4K2rbfrbYdFvxnEnktmG+E577Gy33QY26IhSIraNWHaCJ1q7oVVFs7TMDhL+6NjwXzNKB/qvofieW6tP+pN+GwoDubu/d8h/KvvUDKaW6jMCUC+RL69E8VBO/zAl9dBzClFYvd75D2h4roOsfODvLf0ikgY1piy9afJzhr0o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038141078891.9535884719849; Wed, 26 May 2021 07:09:01 -0700 (PDT) Received: from localhost ([::1]:40206 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluDS-0005fr-F3 for importer2@patchew.org; Wed, 26 May 2021 10:08:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35166) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBL-00031d-Og for qemu-devel@nongnu.org; Wed, 26 May 2021 10:06:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBG-0003pn-QW for qemu-devel@nongnu.org; Wed, 26 May 2021 10:06:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-MFVSBATsNGma12xY6HZJ-w-1; Wed, 26 May 2021 10:06:40 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 32C5690E643; Wed, 26 May 2021 14:06:39 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD81B101E5AF; Wed, 26 May 2021 14:06:38 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 88E04180039F; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038002; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j+ByWNfBQl077NakT3CN6Nqd8I1j/6kexSaJYZ7FxVU=; b=C3a3kivPvvPAiXDEDIabnZ3F94oKk1SwFCAGayJ0lZ+GDNKM724T1WOmrgZXimidNYV49L SxZO4TGwQCGM3Hl3apJ6Ht39KtEXL0wRwDfDZcuy7y6E8K7ikgQUuX1cUL0v0wT0c+zLRm /n52xW4mxCFStFsr1U3XSJDnfXcYFqs= X-MC-Unique: MFVSBATsNGma12xY6HZJ-w-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 03/14] ps2: don't raise an interrupt if queue is full Date: Wed, 26 May 2021 16:06:16 +0200 Message-Id: <20210526140627.381857-4-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin ps2_queue() behaves differently than the very similar functions ps2_queue_2() to ps2_queue_4(). The first one calls update_irq() even if the queue is full, the others don't. Change ps2_queue() to be consistent with the others. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-2-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 7a3fb2b9f639..7c7a158e3139 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -212,6 +212,10 @@ void ps2_raise_irq(PS2State *s) =20 void ps2_queue(PS2State *s, int b) { + if (PS2_QUEUE_SIZE - s->queue.count < 1) { + return; + } + ps2_queue_noirq(s, b); s->update_irq(s->update_arg, 1); } --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038327; cv=none; d=zohomail.com; s=zohoarc; b=ippgmYtPB4Ahk/Ad7kRjHkV3dxfkgcVyhAvRYNECBN2otMaQg/gQ8mkl9/9OxQbK6MgATnHwd426pWtUycU3jPe/xq3z6Ewhnymw/FbOXoFJbEBquGbT5NFUHRWWMEjoLzAcRulUXUxX0e4eG0kG37WuTchg9/cZ2C1cuZAM8q4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038327; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wapvoU9/BzxeKHg5D5SZCCmBnDRLK12bdpOj7BwKdl4=; b=hz598wFPxHotPO0ycyfdP6C7metZEv8m8UlcZ4K7bcPPQylMjr5CE0rkCQMbRaE43wCVndgm4AxPuLA67rodqEVChA6U8MI+t4R1s/dQDymkKbX9rGQIp4c3JkZ8d6itHV4ixOjqOAjCceKkZrHqQwkGm8Y50bJwt1rASjAcIDs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038327620454.11323854948944; Wed, 26 May 2021 07:12:07 -0700 (PDT) Received: from localhost ([::1]:48812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluGU-00037q-H1 for importer2@patchew.org; Wed, 26 May 2021 10:12:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBT-0003LJ-DA for qemu-devel@nongnu.org; Wed, 26 May 2021 10:06:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44085) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBR-0003wo-Pa for qemu-devel@nongnu.org; Wed, 26 May 2021 10:06:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-580-Sh5_tjPTOZifGKdXUdVwHw-1; Wed, 26 May 2021 10:06:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C5AF1034B20; Wed, 26 May 2021 14:06:49 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CA545D9DC; Wed, 26 May 2021 14:06:41 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9322A18003B6; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038013; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wapvoU9/BzxeKHg5D5SZCCmBnDRLK12bdpOj7BwKdl4=; b=dkYcVX/YKzu+IEyHB9Wby7ja6u1cWOlttgPaoGrLp+LgE50RJqWcaKBJQl1q5qT0I7WJNV a751Ys0KT5gnthA7ZY+W631Zn4/SkuAy99eUin4DEazjbbRwukg3lodrwtcW1b6ctwwPPm n8EK/4U9B4LF/2/pDA8I2L/Y521FAHQ= X-MC-Unique: Sh5_tjPTOZifGKdXUdVwHw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 04/14] ps2: don't deassert irq twice if queue is empty Date: Wed, 26 May 2021 16:06:17 +0200 Message-Id: <20210526140627.381857-5-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin Don't deassert the irq twice if the queue is empty. While the second deassertion doesn't do any harm, it's unnecessary. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-3-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 7c7a158e3139..5cf95b4dd3eb 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -520,7 +520,9 @@ uint32_t ps2_read_data(PS2State *s) /* reading deasserts IRQ */ s->update_irq(s->update_arg, 0); /* reassert IRQs if data left */ - s->update_irq(s->update_arg, q->count !=3D 0); + if (q->count) { + s->update_irq(s->update_arg, 1); + } } return val; } --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038150; cv=none; d=zohomail.com; s=zohoarc; b=iJK8VtOFihBqOKr47pSabXGVY71yvtuHqilyxeamLxM14vw0k8sENWtNDsYcmzrHpLEc4GghZOi+FKj4PWq9RU/E1PxUkPHhQcEb8K1ZGebCYIaRPmdgeseOAzKdHRvrqDwn/+b0dvOOFMA/x/ujtzskI1FUGcmDUZKou3Vi3Ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038150; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LjdxxPm/3a5lUA42yV8gfOpAA+r0ZCkN+8OqMTgFe7o=; b=KY7z04I38atfrIupPmQ1lOJIg4RLH7Ud4kcgb8//GH18r8oTc3CzjokNSObNK0nM406FX1XjrwiJUJCW66rCQAkUsJN9vTPTNzoH+jGiMU53SoIJxi1GBTrYEh8Y/noY9+f5Qfc6wYzLCOW6PQPMVYK37BwmAqro5EMfScxrBOA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038150907304.79007753987867; Wed, 26 May 2021 07:09:10 -0700 (PDT) Received: from localhost ([::1]:40384 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluDd-0005n8-Q7 for importer2@patchew.org; Wed, 26 May 2021 10:09:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBO-00036c-Cx for qemu-devel@nongnu.org; Wed, 26 May 2021 10:06:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:58566) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBL-0003rZ-7L for qemu-devel@nongnu.org; Wed, 26 May 2021 10:06:50 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-374-4agDk1NdP6a03SmyVj4qUQ-1; Wed, 26 May 2021 10:06:43 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 529A0802938; Wed, 26 May 2021 14:06:42 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0CB9118BAF; Wed, 26 May 2021 14:06:42 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 9F03A18007A2; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038006; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LjdxxPm/3a5lUA42yV8gfOpAA+r0ZCkN+8OqMTgFe7o=; b=TLcykn3eVqmOiSkjb0toxrdcgUAORMK06hvgWmeXQ6DVNTNJWPv0WAPGeKYqAFBjdR/Oe9 +UlG1/cgIXaQJcuvgXK9za6quSELABhksNgwp0veysbL13lEsJVbNbLz/iKQUIhfcQcNlz bN0XOXNDAIYbQ/A3JQgHjVwK/BCcF8A= X-MC-Unique: 4agDk1NdP6a03SmyVj4qUQ-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 05/14] pckbd: split out interrupt line changing code Date: Wed, 26 May 2021 16:06:18 +0200 Message-Id: <20210526140627.381857-6-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin Split out the interrupt line changing code from kbd_update_irq(). This is a preparation for the next patch. There is no functional change. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-4-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/pckbd.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index dde85ba6c683..90b33954a8e9 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -148,15 +148,34 @@ typedef struct KBDState { hwaddr mask; } KBDState; =20 -/* update irq and KBD_STAT_[MOUSE_]OBF */ /* XXX: not generating the irqs if KBD_MODE_DISABLE_KBD is set may be incorrect, but it avoids having to simulate exact delays */ -static void kbd_update_irq(KBDState *s) +static void kbd_update_irq_lines(KBDState *s) { int irq_kbd_level, irq_mouse_level; =20 irq_kbd_level =3D 0; irq_mouse_level =3D 0; + + if (s->status & KBD_STAT_OBF) { + if (s->status & KBD_STAT_MOUSE_OBF) { + if (s->mode & KBD_MODE_MOUSE_INT) { + irq_mouse_level =3D 1; + } + } else { + if ((s->mode & KBD_MODE_KBD_INT) && + !(s->mode & KBD_MODE_DISABLE_KBD)) { + irq_kbd_level =3D 1; + } + } + } + qemu_set_irq(s->irq_kbd, irq_kbd_level); + qemu_set_irq(s->irq_mouse, irq_mouse_level); +} + +/* update irq and KBD_STAT_[MOUSE_]OBF */ +static void kbd_update_irq(KBDState *s) +{ s->status &=3D ~(KBD_STAT_OBF | KBD_STAT_MOUSE_OBF); s->outport &=3D ~(KBD_OUT_OBF | KBD_OUT_MOUSE_OBF); if (s->pending) { @@ -166,16 +185,9 @@ static void kbd_update_irq(KBDState *s) if (s->pending =3D=3D KBD_PENDING_AUX) { s->status |=3D KBD_STAT_MOUSE_OBF; s->outport |=3D KBD_OUT_MOUSE_OBF; - if (s->mode & KBD_MODE_MOUSE_INT) - irq_mouse_level =3D 1; - } else { - if ((s->mode & KBD_MODE_KBD_INT) && - !(s->mode & KBD_MODE_DISABLE_KBD)) - irq_kbd_level =3D 1; } } - qemu_set_irq(s->irq_kbd, irq_kbd_level); - qemu_set_irq(s->irq_mouse, irq_mouse_level); + kbd_update_irq_lines(s); } =20 static void kbd_update_kbd_irq(void *opaque, int level) --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038449; cv=none; d=zohomail.com; s=zohoarc; b=njmL0Zw74zkf0xxdhU8wkmOgO0eWNlm1xb2UdQ0Ly0uqjIL/szYmFOLQY7YtM9Kfimo/zq+WP4NhCQsf0Kx3pacV/QDcEAwV7nFbIwzq1aKgbJHLilhStv991ONrwptk2DED/ULYC8MW+v6+EWMJO0Cdosmab6FQlQX0BqzZbLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038449; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WXz815r8Lbg5bqcS1ElYYh79dCj4U9AEf5bagVD8VK0=; b=dj0+IFMvozK0rUNOMNawft/0eXzJJCOYZpbhORdofPBXS/FOr5+UZXGxfvuTz+HdyoPSUrH/PQsrTzk2QFJ2JzYSOEE2T8XjEJqT50xrVzPlxbAz7KOqYmk2O9lKxdnp5FtYgf2agcK9jpdFikFlmcilXVt/GxKwA5tTriAQS4Y= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038449334189.86968993738594; Wed, 26 May 2021 07:14:09 -0700 (PDT) Received: from localhost ([::1]:57412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluIS-0000QF-FN for importer2@patchew.org; Wed, 26 May 2021 10:14:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBb-0003TW-T1 for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:03 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49237) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBX-000430-D4 for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-344-8uWVpRbROiaNBh8Gbgbfew-1; Wed, 26 May 2021 10:06:55 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8F82C1034B37; Wed, 26 May 2021 14:06:54 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DC07290BE; Wed, 26 May 2021 14:06:43 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id ADA971800874; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WXz815r8Lbg5bqcS1ElYYh79dCj4U9AEf5bagVD8VK0=; b=RJqGhXvmp1UJvZnvdmRuZ7iV2jwGbqDu2aRKHtVEFEAl08wSnNXzN+HqN8EwAdTT3VsjN+ uJMA9pQBZYT2cK2/d/MDPVI7cdtZE9L3kgDYC6Smtavp4rcQaKp/WCLdTjtetBPAarg+Nm nc+tLMkbTbS3S6Scol98hMIW/3ezgRI= X-MC-Unique: 8uWVpRbROiaNBh8Gbgbfew-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 06/14] pckbd: don't update OBF flags if KBD_STAT_OBF is set Date: Wed, 26 May 2021 16:06:19 +0200 Message-Id: <20210526140627.381857-7-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin Don't update the OBF flags in the status register and the cor- responding IRQ lines if KBD_STAT_OBF is set. Otherwise this may change the PS/2 event type. If the guest ISR was already scheduled, the changed event type will be rather surprising for the guest. This fixes a mouse event stream corruption. To reproduce the problem start a FreeDOS 1.2 guest with -machine pc,accel=3Dkvm and -display gtk. The KVM in-kernel irqchip has to be enabled. Now open a text file with edit.exe in the guest and hold down the cursor right key and at the same time move the mouse around. You will quickly notice erratic mouse movements and unexpected mouse clicks. A trace file shows the mouse event stream corruption. Guest rip 0xce93 (f000:ce93) is the in al,0x60 instruction in the seabios mouse ISR, guest rip 0xceca (f000:ceca) is the in al,0x60 instruction in the seabios keyboard ISR. qemu-system-x86-5659 [007] .... 280.971116: tracing_mark_write: pckbd_kbd_update_irq kbd=3D0 aux=3D1 # gtk queues a mouse event qemu-system-x86-5665 [000] .... 280.971121: kvm_exit: reason EXTERNAL_INTERRUPT rip 0x22da info 0 800000fd qemu-system-x86-5665 [000] d..1 280.971122: kvm_entry: vcpu 0, rip 0x22da qemu-system-x86-5665 [000] .... 280.971123: kvm_exit: reason EXTERNAL_INTERRUPT rip 0x22da info 0 800000fd qemu-system-x86-5665 [000] d..1 280.971124: kvm_entry: vcpu 0, rip 0x22da qemu-system-x86-5665 [000] .... 280.971126: kvm_exit: reason IO_INSTRUCTION rip 0x110c8c info 640008 0 qemu-system-x86-5665 [000] .... 280.971176: tracing_mark_write: pckbd_kbd_read_status 0x3d # KBD_STAT_OBF and KBD_STAT_MOUSE_OBF set, the mouse ISR will # read data from the PS/2 controller. qemu-system-x86-5665 [000] d..1 280.971180: kvm_entry: vcpu 0, rip 0x110c8d qemu-system-x86-5665 [000] .... 280.971191: kvm_exit: reason EXTERNAL_INTERRUPT rip 0x110c8d info 0 800000f6 qemu-system-x86-5665 [000] d..1 280.971191: kvm_entry: vcpu 0, rip 0x110c8d qemu-system-x86-5665 [000] .... 280.971193: kvm_exit: reason IO_INSTRUCTION rip 0xce93 info 600048 0 # the mouse ISR wants to read data from the PS/2 controller qemu-system-x86-5659 [007] .... 280.971231: tracing_mark_write: pckbd_kbd_update_irq kbd=3D1 aux=3D0 qemu-system-x86-5659 [007] .... 280.971238: tracing_mark_write: pckbd_kbd_update_irq kbd=3D1 aux=3D0 # gtk queues a keyboard event 0xe0 0x4d (key right) qemu-system-x86-5665 [000] .... 280.971257: tracing_mark_write: pckbd_kbd_update_irq kbd=3D0 aux=3D1 qemu-system-x86-5665 [000] .... 280.971262: tracing_mark_write: pckbd_kbd_update_irq kbd=3D1 aux=3D0 # ps2_read_data() deasserts and reasserts the keyboard IRQ qemu-system-x86-5665 [000] .... 280.971266: tracing_mark_write: pckbd_kbd_read_data 0xe0 kbd # -> the mouse ISR receives keyboard data qemu-system-x86-5665 [000] d..1 280.971268: kvm_entry: vcpu 0, rip 0xce95 qemu-system-x86-5665 [000] .... 280.971269: kvm_exit: reason IO_INSTRUCTION rip 0xe828 info a00040 0 qemu-system-x86-5665 [000] .... 280.971270: kvm_ack_irq: irqchip PIC slave pin 12 qemu-system-x86-5665 [000] d..1 280.971270: kvm_entry: vcpu 0, rip 0xe82a qemu-system-x86-5665 [000] .... 280.971271: kvm_exit: reason IO_INSTRUCTION rip 0xe82a info 200040 0 qemu-system-x86-5665 [000] .... 280.971271: kvm_ack_irq: irqchip PIC master pin 2 qemu-system-x86-5665 [000] d..1 280.971271: kvm_entry: vcpu 0, rip 0xe82c qemu-system-x86-5665 [000] .... 280.971272: kvm_exit: reason PENDING_INTERRUPT rip 0x22da info 0 0 qemu-system-x86-5665 [000] d..1 280.971273: kvm_entry: vcpu 0, rip 0x22da qemu-system-x86-5665 [000] .... 280.971274: kvm_exit: reason IO_INSTRUCTION rip 0x110c8c info 640008 0 qemu-system-x86-5665 [000] .... 280.971275: tracing_mark_write: pckbd_kbd_read_status 0x1d qemu-system-x86-5665 [000] d..1 280.971276: kvm_entry: vcpu 0, rip 0x110c8d qemu-system-x86-5665 [000] .... 280.971277: kvm_exit: reason IO_INSTRUCTION rip 0xceca info 600048 0 # the keyboard ISR wants to read data from the PS/2 controller qemu-system-x86-5665 [000] .... 280.971279: tracing_mark_write: pckbd_kbd_update_irq kbd=3D0 aux=3D1 qemu-system-x86-5665 [000] .... 280.971282: tracing_mark_write: pckbd_kbd_read_data 0x4d kbd # the keyboard ISR receives the second byte of the keyboard event Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-5-vr_qemu@t-online.de> [ kraxel: add missing include ] Signed-off-by: Gerd Hoffmann --- hw/core/machine.c | 1 + hw/input/pckbd.c | 103 +++++++++++++++++++++++++++++++++++++--------- 2 files changed, 84 insertions(+), 20 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 1bf0e687b94a..55b9bc7817d8 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -38,6 +38,7 @@ =20 GlobalProperty hw_compat_6_0[] =3D { { "gpex-pcihost", "allow-unmapped-accesses", "false" }, + { "i8042", "extended-state", "false"}, }; const size_t hw_compat_6_0_len =3D G_N_ELEMENTS(hw_compat_6_0); =20 diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index 90b33954a8e9..fbd57bf0f572 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -30,6 +30,7 @@ #include "hw/input/ps2.h" #include "hw/irq.h" #include "hw/input/i8042.h" +#include "hw/qdev-properties.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" =20 @@ -137,8 +138,10 @@ typedef struct KBDState { uint8_t mode; uint8_t outport; bool outport_present; + bool extended_state; /* Bitmask of devices with data available. */ uint8_t pending; + uint8_t obdata; void *kbd; void *mouse; =20 @@ -173,6 +176,13 @@ static void kbd_update_irq_lines(KBDState *s) qemu_set_irq(s->irq_mouse, irq_mouse_level); } =20 +static void kbd_deassert_irq(KBDState *s) +{ + s->status &=3D ~(KBD_STAT_OBF | KBD_STAT_MOUSE_OBF); + s->outport &=3D ~(KBD_OUT_OBF | KBD_OUT_MOUSE_OBF); + kbd_update_irq_lines(s); +} + /* update irq and KBD_STAT_[MOUSE_]OBF */ static void kbd_update_irq(KBDState *s) { @@ -181,7 +191,6 @@ static void kbd_update_irq(KBDState *s) if (s->pending) { s->status |=3D KBD_STAT_OBF; s->outport |=3D KBD_OUT_OBF; - /* kbd data takes priority over aux data. */ if (s->pending =3D=3D KBD_PENDING_AUX) { s->status |=3D KBD_STAT_MOUSE_OBF; s->outport |=3D KBD_OUT_MOUSE_OBF; @@ -190,26 +199,42 @@ static void kbd_update_irq(KBDState *s) kbd_update_irq_lines(s); } =20 +static void kbd_safe_update_irq(KBDState *s) +{ + /* + * with KBD_STAT_OBF set, a call to kbd_read_data() will eventually ca= ll + * kbd_update_irq() + */ + if (s->status & KBD_STAT_OBF) { + return; + } + if (s->pending) { + kbd_update_irq(s); + } +} + static void kbd_update_kbd_irq(void *opaque, int level) { - KBDState *s =3D (KBDState *)opaque; + KBDState *s =3D opaque; =20 - if (level) + if (level) { s->pending |=3D KBD_PENDING_KBD; - else + } else { s->pending &=3D ~KBD_PENDING_KBD; - kbd_update_irq(s); + } + kbd_safe_update_irq(s); } =20 static void kbd_update_aux_irq(void *opaque, int level) { - KBDState *s =3D (KBDState *)opaque; + KBDState *s =3D opaque; =20 - if (level) + if (level) { s->pending |=3D KBD_PENDING_AUX; - else + } else { s->pending &=3D ~KBD_PENDING_AUX; - kbd_update_irq(s); + } + kbd_safe_update_irq(s); } =20 static uint64_t kbd_read_status(void *opaque, hwaddr addr, @@ -290,11 +315,10 @@ static void kbd_write_command(void *opaque, hwaddr ad= dr, break; case KBD_CCMD_KBD_DISABLE: s->mode |=3D KBD_MODE_DISABLE_KBD; - kbd_update_irq(s); break; case KBD_CCMD_KBD_ENABLE: s->mode &=3D ~KBD_MODE_DISABLE_KBD; - kbd_update_irq(s); + kbd_safe_update_irq(s); break; case KBD_CCMD_READ_INPORT: kbd_queue(s, 0x80, 0); @@ -327,15 +351,19 @@ static uint64_t kbd_read_data(void *opaque, hwaddr ad= dr, unsigned size) { KBDState *s =3D opaque; - uint32_t val; + uint8_t status =3D s->status; =20 - if (s->pending =3D=3D KBD_PENDING_AUX) - val =3D ps2_read_data(s->mouse); - else - val =3D ps2_read_data(s->kbd); + if (status & KBD_STAT_OBF) { + kbd_deassert_irq(s); + if (status & KBD_STAT_MOUSE_OBF) { + s->obdata =3D ps2_read_data(s->mouse); + } else { + s->obdata =3D ps2_read_data(s->kbd); + } + } =20 - trace_pckbd_kbd_read_data(val); - return val; + trace_pckbd_kbd_read_data(s->obdata); + return s->obdata; } =20 static void kbd_write_data(void *opaque, hwaddr addr, @@ -352,8 +380,16 @@ static void kbd_write_data(void *opaque, hwaddr addr, case KBD_CCMD_WRITE_MODE: s->mode =3D val; ps2_keyboard_set_translation(s->kbd, (s->mode & KBD_MODE_KCC) !=3D= 0); - /* ??? */ - kbd_update_irq(s); + /* + * a write to the mode byte interrupt enable flags directly updates + * the irq lines + */ + kbd_update_irq_lines(s); + /* + * a write to the mode byte disable interface flags may raise + * an irq if there is pending data in the PS/2 queues. + */ + kbd_safe_update_irq(s); break; case KBD_CCMD_WRITE_OBUF: kbd_queue(s, val, 0); @@ -381,6 +417,8 @@ static void kbd_reset(void *opaque) s->status =3D KBD_STAT_CMD | KBD_STAT_UNLOCKED; s->outport =3D KBD_OUT_RESET | KBD_OUT_A20 | KBD_OUT_ONES; s->outport_present =3D false; + s->pending =3D 0; + kbd_deassert_irq(s); } =20 static uint8_t kbd_outport_default(KBDState *s) @@ -415,6 +453,22 @@ static const VMStateDescription vmstate_kbd_outport = =3D { } }; =20 +static bool kbd_extended_state_needed(void *opaque) +{ + KBDState *s =3D opaque; + + return s->extended_state; +} + +static const VMStateDescription vmstate_kbd_extended_state =3D { + .name =3D "pckbd/extended_state", + .needed =3D kbd_extended_state_needed, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8(obdata, KBDState), + VMSTATE_END_OF_LIST() + } +}; + static int kbd_post_load(void *opaque, int version_id) { KBDState *s =3D opaque; @@ -439,6 +493,7 @@ static const VMStateDescription vmstate_kbd =3D { }, .subsections =3D (const VMStateDescription*[]) { &vmstate_kbd_outport, + &vmstate_kbd_extended_state, NULL } }; @@ -484,6 +539,8 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq, s->irq_mouse =3D mouse_irq; s->mask =3D mask; =20 + s->extended_state =3D true; + vmstate_register(NULL, 0, &vmstate_kbd, s); =20 memory_region_init_io(region, NULL, &i8042_mmio_ops, s, "i8042", size); @@ -600,11 +657,17 @@ static void i8042_build_aml(ISADevice *isadev, Aml *s= cope) aml_append(scope, mou); } =20 +static Property i8042_properties[] =3D { + DEFINE_PROP_BOOL("extended-state", ISAKBDState, kbd.extended_state, tr= ue), + DEFINE_PROP_END_OF_LIST(), +}; + static void i8042_class_initfn(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); ISADeviceClass *isa =3D ISA_DEVICE_CLASS(klass); =20 + device_class_set_props(dc, i8042_properties); dc->realize =3D i8042_realizefn; dc->vmsd =3D &vmstate_kbd_isa; isa->build_aml =3D i8042_build_aml; --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038160; cv=none; d=zohomail.com; s=zohoarc; b=b6zczowzviq6srbayYvdjqFrLX8x4VG1vFa0Afx6HtVPKZXRqzc9s4dKUjB1YUiWu2RPTjc5Vzu/JMEhLIrEb7wBONRHH4Vh8ancK8B8S5k7XPbKqGukklNTbjGnU4inIsozPbXQ+MjtRPfrLChh0CQlLL1G78QVJy0mwvT8jcA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038160; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Hdu8ay89cibhhwgLBEbFgoAkk0h2Aqwyp7m2Ec4zUFk=; b=b++VRt3ETV1RT6be8RFNJT2EI2X2VsBb3Ks4DSrOR4D+4N3bJgpHHp82B8MSV21XEUoCximIdRwF9JcKVtsxb8wqL1O472TrGwkbPhTeVwB6gShsAhDw2dLoNiLRGCeIEAGN4WnV5oZVqyOrx83tCSEgsKz5TEGvJmjiIdR764E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038160375631.3644433057539; Wed, 26 May 2021 07:09:20 -0700 (PDT) Received: from localhost ([::1]:41098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluDn-0006Hi-8H for importer2@patchew.org; Wed, 26 May 2021 10:09:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35266) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBg-0003VS-9B for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:40121) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBd-00045z-Ki for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-343-Dmy9qcqOOoyDGhCbiCEEhA-1; Wed, 26 May 2021 10:06:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 639EF107ACCD; Wed, 26 May 2021 14:06:58 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E07A53A47; Wed, 26 May 2021 14:06:50 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id BA0FE1800905; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038023; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Hdu8ay89cibhhwgLBEbFgoAkk0h2Aqwyp7m2Ec4zUFk=; b=DyUB25xUNdZIssxbo1lvnlawaZtImoqOerDRfbwQ03peO7Rs7WZSJk7Vi3TWac2jkxCxVo Y5HFGMEnLaG9oH+J4O5hJ/Nq3FJtkgPY2ovd4z8tFhzZ7TH0zCZUs0xNQZNPE3PF3re7vk e/ECP2mdh+RuirJ2thDy5NZpZ3QBAQA= X-MC-Unique: Dmy9qcqOOoyDGhCbiCEEhA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 07/14] pckbd: PS/2 keyboard throttle Date: Wed, 26 May 2021 16:06:20 +0200 Message-Id: <20210526140627.381857-8-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin Limit the keyboard data rate to the serial link speed. Some old DOS software relies on being able to read an incoming scan-code more than once. After reading keyboard data from the i8042 controller, the guest software has 1ms to read the same data again. Use -global i8042.kbd-throttle=3Don to enable this feature. To see how this patch works, start a FreeDOS 1.2 guest with the qemu option -global i8042.kbd-throttle=3Don and open a text file with the vim 7.3 32 bit for DOS executable. Then use the cursor keys (not the cursor keys on the numeric keypad) to move through the text. Without the kbd-throttle option enabled each keystroke will move the cursor two positions. Buglink: https://bugs.launchpad.net/bugs/1895363 Buglink: https://bugs.launchpad.net/bugs/1897568 Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-6-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/pckbd.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index fbd57bf0f572..516ed5a397cd 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -23,7 +23,9 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "qemu/log.h" +#include "qemu/timer.h" #include "hw/isa/isa.h" #include "migration/vmstate.h" #include "hw/acpi/aml-build.h" @@ -132,11 +134,14 @@ #define KBD_PENDING_KBD 1 #define KBD_PENDING_AUX 2 =20 +#define KBD_MIGR_TIMER_PENDING 0x1 + typedef struct KBDState { uint8_t write_cmd; /* if non zero, write data to port 60 is expected */ uint8_t status; uint8_t mode; uint8_t outport; + uint32_t migration_flags; bool outport_present; bool extended_state; /* Bitmask of devices with data available. */ @@ -144,6 +149,7 @@ typedef struct KBDState { uint8_t obdata; void *kbd; void *mouse; + QEMUTimer *throttle_timer; =20 qemu_irq irq_kbd; qemu_irq irq_mouse; @@ -208,6 +214,10 @@ static void kbd_safe_update_irq(KBDState *s) if (s->status & KBD_STAT_OBF) { return; } + /* the throttle timer is pending and will call kbd_update_irq() */ + if (s->throttle_timer && timer_pending(s->throttle_timer)) { + return; + } if (s->pending) { kbd_update_irq(s); } @@ -237,6 +247,15 @@ static void kbd_update_aux_irq(void *opaque, int level) kbd_safe_update_irq(s); } =20 +static void kbd_throttle_timeout(void *opaque) +{ + KBDState *s =3D opaque; + + if (s->pending) { + kbd_update_irq(s); + } +} + static uint64_t kbd_read_status(void *opaque, hwaddr addr, unsigned size) { @@ -358,6 +377,10 @@ static uint64_t kbd_read_data(void *opaque, hwaddr add= r, if (status & KBD_STAT_MOUSE_OBF) { s->obdata =3D ps2_read_data(s->mouse); } else { + if (s->throttle_timer) { + timer_mod(s->throttle_timer, + qemu_clock_get_us(QEMU_CLOCK_VIRTUAL) + 1000); + } s->obdata =3D ps2_read_data(s->kbd); } } @@ -419,6 +442,9 @@ static void kbd_reset(void *opaque) s->outport_present =3D false; s->pending =3D 0; kbd_deassert_irq(s); + if (s->throttle_timer) { + timer_del(s->throttle_timer); + } } =20 static uint8_t kbd_outport_default(KBDState *s) @@ -453,6 +479,29 @@ static const VMStateDescription vmstate_kbd_outport = =3D { } }; =20 +static int kbd_extended_state_pre_save(void *opaque) +{ + KBDState *s =3D opaque; + + s->migration_flags =3D 0; + if (s->throttle_timer && timer_pending(s->throttle_timer)) { + s->migration_flags |=3D KBD_MIGR_TIMER_PENDING; + } + + return 0; +} + +static int kbd_extended_state_post_load(void *opaque, int version_id) +{ + KBDState *s =3D opaque; + + if (s->migration_flags & KBD_MIGR_TIMER_PENDING) { + kbd_throttle_timeout(s); + } + + return 0; +} + static bool kbd_extended_state_needed(void *opaque) { KBDState *s =3D opaque; @@ -462,8 +511,11 @@ static bool kbd_extended_state_needed(void *opaque) =20 static const VMStateDescription vmstate_kbd_extended_state =3D { .name =3D "pckbd/extended_state", + .post_load =3D kbd_extended_state_post_load, + .pre_save =3D kbd_extended_state_pre_save, .needed =3D kbd_extended_state_needed, .fields =3D (VMStateField[]) { + VMSTATE_UINT32(migration_flags, KBDState), VMSTATE_UINT8(obdata, KBDState), VMSTATE_END_OF_LIST() } @@ -554,6 +606,7 @@ struct ISAKBDState { ISADevice parent_obj; =20 KBDState kbd; + bool kbd_throttle; MemoryRegion io[2]; }; =20 @@ -626,6 +679,13 @@ static void i8042_realizefn(DeviceState *dev, Error **= errp) =20 s->kbd =3D ps2_kbd_init(kbd_update_kbd_irq, s); s->mouse =3D ps2_mouse_init(kbd_update_aux_irq, s); + if (isa_s->kbd_throttle && !isa_s->kbd.extended_state) { + warn_report(TYPE_I8042 ": can't enable kbd-throttle without" + " extended-state, disabling kbd-throttle"); + } else if (isa_s->kbd_throttle) { + s->throttle_timer =3D timer_new_us(QEMU_CLOCK_VIRTUAL, + kbd_throttle_timeout, s); + } qemu_register_reset(kbd_reset, s); } =20 @@ -659,6 +719,7 @@ static void i8042_build_aml(ISADevice *isadev, Aml *sco= pe) =20 static Property i8042_properties[] =3D { DEFINE_PROP_BOOL("extended-state", ISAKBDState, kbd.extended_state, tr= ue), + DEFINE_PROP_BOOL("kbd-throttle", ISAKBDState, kbd_throttle, false), DEFINE_PROP_END_OF_LIST(), }; =20 --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038448; cv=none; d=zohomail.com; s=zohoarc; b=I5j28gUREGj+0UA7JDBnLL+NgLYQzN/j5t1jPbKiKKGeuqeZQkX7GU28x5WmqpgLxM8CjMc/Vp7p5kyZJEhXmomsfp4/FV4zxsqcFt7cNvYFeHCFMg03/PRukwW58ckhMoc1d1dXd9Hyht4B6KwzqOA/QbonTyclRattSHEvNNQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038448; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UcnVKP4AiCmMNYZTOcKhold/3r5KHD8Ypv5K8LqF7po=; b=Qu9266mVMWfybpNMKUONv+fBGpG6yYUxQB17wdjySezaQjFLN0wtBX3lxiKwlnmEGx1AgbcmFCz7HjKrZ2yCy2OgEVGPl82e2idBUHK5sU92TE4ABgq+wjYYpsXNWjiMrgepDZ2gV0/I1u5pRRsIkMvpRJKJE9DDw4zAhekFOl4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038448964547.5448510653941; Wed, 26 May 2021 07:14:08 -0700 (PDT) Received: from localhost ([::1]:57410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluIS-0000Q9-5C for importer2@patchew.org; Wed, 26 May 2021 10:14:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35340) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBp-0003oA-8M for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33856) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBn-0004Dv-9r for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-363-XbStAZC3PjOQhTe1qkEoAw-1; Wed, 26 May 2021 10:07:05 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE9058031FE; Wed, 26 May 2021 14:07:04 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1A68C18BAF; Wed, 26 May 2021 14:06:56 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C5D501800906; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UcnVKP4AiCmMNYZTOcKhold/3r5KHD8Ypv5K8LqF7po=; b=BGASzKbWtHgNpprmSCu74E/Qq2j0vVAG7al+cACfXGVtI07q4R6dieOuwaIb24B6fZg2kx cV3hM7Zujo0HRXYGkL2w4+SeUVmVGdXPuc1Z2/mxhtV7s5cwrpWpWI+y7jQaZCkzXrzZHT tfprf1BtDYgP+u9RXS62wkKgiyzhexQ= X-MC-Unique: XbStAZC3PjOQhTe1qkEoAw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 08/14] pckbd: add state variable for interrupt source Date: Wed, 26 May 2021 16:06:21 +0200 Message-Id: <20210526140627.381857-9-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin Currently there is only one flag to distinguish between two interrupt sources and there are no available flags for more sources. Add an internal state variable to store the interrupt source. The next patch will introduce an additional interrupt source. There is no functional change. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-7-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/pckbd.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index 516ed5a397cd..62a3b29074b8 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -136,14 +136,19 @@ =20 #define KBD_MIGR_TIMER_PENDING 0x1 =20 +#define KBD_OBSRC_KBD 0x01 +#define KBD_OBSRC_MOUSE 0x02 + typedef struct KBDState { uint8_t write_cmd; /* if non zero, write data to port 60 is expected */ uint8_t status; uint8_t mode; uint8_t outport; uint32_t migration_flags; + uint32_t obsrc; bool outport_present; bool extended_state; + bool extended_state_loaded; /* Bitmask of devices with data available. */ uint8_t pending; uint8_t obdata; @@ -200,6 +205,9 @@ static void kbd_update_irq(KBDState *s) if (s->pending =3D=3D KBD_PENDING_AUX) { s->status |=3D KBD_STAT_MOUSE_OBF; s->outport |=3D KBD_OUT_MOUSE_OBF; + s->obsrc =3D KBD_OBSRC_MOUSE; + } else { + s->obsrc =3D KBD_OBSRC_KBD; } } kbd_update_irq_lines(s); @@ -370,18 +378,17 @@ static uint64_t kbd_read_data(void *opaque, hwaddr ad= dr, unsigned size) { KBDState *s =3D opaque; - uint8_t status =3D s->status; =20 - if (status & KBD_STAT_OBF) { + if (s->status & KBD_STAT_OBF) { kbd_deassert_irq(s); - if (status & KBD_STAT_MOUSE_OBF) { - s->obdata =3D ps2_read_data(s->mouse); - } else { + if (s->obsrc & KBD_OBSRC_KBD) { if (s->throttle_timer) { timer_mod(s->throttle_timer, qemu_clock_get_us(QEMU_CLOCK_VIRTUAL) + 1000); } s->obdata =3D ps2_read_data(s->kbd); + } else if (s->obsrc & KBD_OBSRC_MOUSE) { + s->obdata =3D ps2_read_data(s->mouse); } } =20 @@ -498,6 +505,7 @@ static int kbd_extended_state_post_load(void *opaque, i= nt version_id) if (s->migration_flags & KBD_MIGR_TIMER_PENDING) { kbd_throttle_timeout(s); } + s->extended_state_loaded =3D true; =20 return 0; } @@ -516,11 +524,20 @@ static const VMStateDescription vmstate_kbd_extended_= state =3D { .needed =3D kbd_extended_state_needed, .fields =3D (VMStateField[]) { VMSTATE_UINT32(migration_flags, KBDState), + VMSTATE_UINT32(obsrc, KBDState), VMSTATE_UINT8(obdata, KBDState), VMSTATE_END_OF_LIST() } }; =20 +static int kbd_pre_load(void *opaque) +{ + KBDState *s =3D opaque; + + s->extended_state_loaded =3D false; + return 0; +} + static int kbd_post_load(void *opaque, int version_id) { KBDState *s =3D opaque; @@ -528,6 +545,11 @@ static int kbd_post_load(void *opaque, int version_id) s->outport =3D kbd_outport_default(s); } s->outport_present =3D false; + if (!s->extended_state_loaded) { + s->obsrc =3D s->status & KBD_STAT_OBF ? + (s->status & KBD_STAT_MOUSE_OBF ? KBD_OBSRC_MOUSE : KBD_OBSRC_= KBD) : + 0; + } return 0; } =20 @@ -535,6 +557,7 @@ static const VMStateDescription vmstate_kbd =3D { .name =3D "pckbd", .version_id =3D 3, .minimum_version_id =3D 3, + .pre_load =3D kbd_pre_load, .post_load =3D kbd_post_load, .fields =3D (VMStateField[]) { VMSTATE_UINT8(write_cmd, KBDState), --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038386; cv=none; d=zohomail.com; s=zohoarc; b=Fg9+fjtUHPjpwWr96mpFnNSZcYdbn284fuMphfcTp7SwKLg4qAMbbMrnUKEQdM72K0eMXey1ydv4AOcCid+nFTfs3Bl7w9n9ha/WQVFWxHwADn2bKZqEs1PbiCaBILgeD8eCjk1GORUeHXLMFUh0l1WA8Ra0v5fywnCJqxa8ImA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038386; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=q4sHrVns34mb2mUy1auX9d9foecyllYeTIx7GAIRdJg=; b=abXWjXrd9NUP7mcx4y3oRQOtlfxeldinZPKAn946/opkuw5K5Bg6DFUmeA0hevJ/fgI09e4DOIwXor9P6IfpnU7ggFNWliPEW0Eh04VTZkiKmKKN2BOnlTGBT4OoQhO0wROJ0uwMOzjWkOGRe8FSGneabHX9w1kjryMKI4xvBmo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038386837512.9983307197325; Wed, 26 May 2021 07:13:06 -0700 (PDT) Received: from localhost ([::1]:48990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluGV-0003Eu-6x for importer2@patchew.org; Wed, 26 May 2021 10:12:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35318) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBn-0003fe-5Z for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:45342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBl-0004DG-94 for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-423-1tm3sCyGMUKg9H48HhhiYA-1; Wed, 26 May 2021 10:07:09 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D071F1922962; Wed, 26 May 2021 14:07:08 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CCA1E60C5A; Wed, 26 May 2021 14:06:59 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D17D41800935; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038032; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=q4sHrVns34mb2mUy1auX9d9foecyllYeTIx7GAIRdJg=; b=Ss/wugwxvxFZrg2HTfLAmsWNob7PvcEDWjypHXe947rV4X0f8iqX8KRu4txunFLSOk6EyU GvNgoPPR9pnXXix8ubWyZj7O4ocTme7Ick9cCrNGREDsHU41go9xedwvo/1Nb8VJkntgcM 2Al+vIAhXAHYVJe1Z9U3FFcsxGv6vl8= X-MC-Unique: 1tm3sCyGMUKg9H48HhhiYA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 09/14] pckbd: add controller response queue Date: Wed, 26 May 2021 16:06:22 +0200 Message-Id: <20210526140627.381857-10-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin Add a separate queue for PS/2 controller responses. The responses no longer get queued in the keyboard or mouse queues. The advantage of this can be seen after the next two patches, where the guest can disable the PS/2 communication with keyboard and mouse and still talk to the PS/2 controller. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-8-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/pckbd.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index 62a3b29074b8..294b31590196 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -133,11 +133,14 @@ =20 #define KBD_PENDING_KBD 1 #define KBD_PENDING_AUX 2 +#define KBD_PENDING_CTRL_KBD 0x04 +#define KBD_PENDING_CTRL_AUX 0x08 =20 #define KBD_MIGR_TIMER_PENDING 0x1 =20 #define KBD_OBSRC_KBD 0x01 #define KBD_OBSRC_MOUSE 0x02 +#define KBD_OBSRC_CTRL 0x04 =20 typedef struct KBDState { uint8_t write_cmd; /* if non zero, write data to port 60 is expected */ @@ -152,6 +155,7 @@ typedef struct KBDState { /* Bitmask of devices with data available. */ uint8_t pending; uint8_t obdata; + uint8_t cbdata; void *kbd; void *mouse; QEMUTimer *throttle_timer; @@ -202,12 +206,18 @@ static void kbd_update_irq(KBDState *s) if (s->pending) { s->status |=3D KBD_STAT_OBF; s->outport |=3D KBD_OUT_OBF; - if (s->pending =3D=3D KBD_PENDING_AUX) { + if (s->pending & KBD_PENDING_CTRL_KBD) { + s->obsrc =3D KBD_OBSRC_CTRL; + } else if (s->pending & KBD_PENDING_CTRL_AUX) { s->status |=3D KBD_STAT_MOUSE_OBF; s->outport |=3D KBD_OUT_MOUSE_OBF; - s->obsrc =3D KBD_OBSRC_MOUSE; - } else { + s->obsrc =3D KBD_OBSRC_CTRL; + } else if (s->pending & KBD_PENDING_KBD) { s->obsrc =3D KBD_OBSRC_KBD; + } else { + s->status |=3D KBD_STAT_MOUSE_OBF; + s->outport |=3D KBD_OUT_MOUSE_OBF; + s->obsrc =3D KBD_OBSRC_MOUSE; } } kbd_update_irq_lines(s); @@ -276,10 +286,25 @@ static uint64_t kbd_read_status(void *opaque, hwaddr = addr, =20 static void kbd_queue(KBDState *s, int b, int aux) { - if (aux) - ps2_queue(s->mouse, b); - else - ps2_queue(s->kbd, b); + if (s->extended_state) { + s->cbdata =3D b; + s->pending &=3D ~KBD_PENDING_CTRL_KBD & ~KBD_PENDING_CTRL_AUX; + s->pending |=3D aux ? KBD_PENDING_CTRL_AUX : KBD_PENDING_CTRL_KBD; + kbd_safe_update_irq(s); + } else { + ps2_queue(aux ? s->mouse : s->kbd, b); + } +} + +static uint8_t kbd_dequeue(KBDState *s) +{ + uint8_t b =3D s->cbdata; + + s->pending &=3D ~KBD_PENDING_CTRL_KBD & ~KBD_PENDING_CTRL_AUX; + if (s->pending) { + kbd_update_irq(s); + } + return b; } =20 static void outport_write(KBDState *s, uint32_t val) @@ -389,6 +414,8 @@ static uint64_t kbd_read_data(void *opaque, hwaddr addr, s->obdata =3D ps2_read_data(s->kbd); } else if (s->obsrc & KBD_OBSRC_MOUSE) { s->obdata =3D ps2_read_data(s->mouse); + } else if (s->obsrc & KBD_OBSRC_CTRL) { + s->obdata =3D kbd_dequeue(s); } } =20 @@ -526,6 +553,7 @@ static const VMStateDescription vmstate_kbd_extended_st= ate =3D { VMSTATE_UINT32(migration_flags, KBDState), VMSTATE_UINT32(obsrc, KBDState), VMSTATE_UINT8(obdata, KBDState), + VMSTATE_UINT8(cbdata, KBDState), VMSTATE_END_OF_LIST() } }; --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038766; cv=none; d=zohomail.com; s=zohoarc; b=FMwnxNFQvu7IzvLh6UeIjQ78rObRbPn0lYSQuv9mmM7cjM1g16IWB1z7vrAhXTYk3oap+O51wa9gLel9J4fA6VDlFXg2DAhQFMr8Uz99B/nzlHfzEJClcVZoNBurYUcKF2CWsz2rtXbxZen75kEQcmeSb0MtJZdDvjM88qJqrY8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038766; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yweZ022dQXpkY9SZ4669BEpuLFg/ywULhqQmb4b7GHI=; b=TMH9iLvI2HuukFS2BiOPE3Fu8SFoNtSlGnJQu29lfY3gG5skCzBhPF9JzxOOOWw1pgoo5mPtiKPL/6P8y6gBfBP8d1WrUgj3ZB2J5vYQidhYz+clLaCQnT5ZNtywnTmvrVA+HhW4G+PDjfM1zcvgNNj4DbjPjPxKr9B6oF9aMJQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038766539196.0662096588727; Wed, 26 May 2021 07:19:26 -0700 (PDT) Received: from localhost ([::1]:42702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluNW-00019z-AH for importer2@patchew.org; Wed, 26 May 2021 10:19:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35370) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBs-000405-8B for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:22984) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBq-0004G7-EF for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:19 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-259-VuJ-xEsfNb6ZQq6iW6zGrg-1; Wed, 26 May 2021 10:07:15 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6CCE3800D55; Wed, 26 May 2021 14:07:14 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6185219D9D; Wed, 26 May 2021 14:07:07 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DCF0A1800936; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yweZ022dQXpkY9SZ4669BEpuLFg/ywULhqQmb4b7GHI=; b=YDpTDQxpz4hfK28iRWJ5uo3Xnz0MJ7mM4zND5kjtJSrYJg0v41MvftiU86cz3pQSC1Fl39 OxFrSAduFqAhpee8yPPLvbRB1/YuWF9XZkBBDg5C4o5KuT6m3sr7wRB1SdZE12ysHeam3Y 55XFiVhxNvUDJw6ZStZ95GNhrBhjdZ0= X-MC-Unique: VuJ-xEsfNb6ZQq6iW6zGrg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 10/14] pckbd: add function kbd_pending() Date: Wed, 26 May 2021 16:06:23 +0200 Message-Id: <20210526140627.381857-11-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin Replace reads of the variable s->pending with a call to a new function kbd_pending() to ease the review of the next patch. There is no functional change. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-9-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/pckbd.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index 294b31590196..e9905e1c6b8c 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -198,21 +198,28 @@ static void kbd_deassert_irq(KBDState *s) kbd_update_irq_lines(s); } =20 +static uint8_t kbd_pending(KBDState *s) +{ + return s->pending; +} + /* update irq and KBD_STAT_[MOUSE_]OBF */ static void kbd_update_irq(KBDState *s) { + uint8_t pending =3D kbd_pending(s); + s->status &=3D ~(KBD_STAT_OBF | KBD_STAT_MOUSE_OBF); s->outport &=3D ~(KBD_OUT_OBF | KBD_OUT_MOUSE_OBF); - if (s->pending) { + if (pending) { s->status |=3D KBD_STAT_OBF; s->outport |=3D KBD_OUT_OBF; - if (s->pending & KBD_PENDING_CTRL_KBD) { + if (pending & KBD_PENDING_CTRL_KBD) { s->obsrc =3D KBD_OBSRC_CTRL; - } else if (s->pending & KBD_PENDING_CTRL_AUX) { + } else if (pending & KBD_PENDING_CTRL_AUX) { s->status |=3D KBD_STAT_MOUSE_OBF; s->outport |=3D KBD_OUT_MOUSE_OBF; s->obsrc =3D KBD_OBSRC_CTRL; - } else if (s->pending & KBD_PENDING_KBD) { + } else if (pending & KBD_PENDING_KBD) { s->obsrc =3D KBD_OBSRC_KBD; } else { s->status |=3D KBD_STAT_MOUSE_OBF; @@ -236,7 +243,7 @@ static void kbd_safe_update_irq(KBDState *s) if (s->throttle_timer && timer_pending(s->throttle_timer)) { return; } - if (s->pending) { + if (kbd_pending(s)) { kbd_update_irq(s); } } @@ -269,7 +276,7 @@ static void kbd_throttle_timeout(void *opaque) { KBDState *s =3D opaque; =20 - if (s->pending) { + if (kbd_pending(s)) { kbd_update_irq(s); } } @@ -301,7 +308,7 @@ static uint8_t kbd_dequeue(KBDState *s) uint8_t b =3D s->cbdata; =20 s->pending &=3D ~KBD_PENDING_CTRL_KBD & ~KBD_PENDING_CTRL_AUX; - if (s->pending) { + if (kbd_pending(s)) { kbd_update_irq(s); } return b; --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038572; cv=none; d=zohomail.com; s=zohoarc; b=f+dUFc20hC+ynEDSuvGeTMNROCLuGrKuPk3MuoPtuYt0R/o9vJgX6zUhl1CugwA5mHNIBbege75/d2fYYahMMAL0+0sqn+YM66AUyBuPqCrEQZMGxGWVpCepdIOLzw199mGa6XP9Thub+gjkla7WjOrVO5vzU/NNrAMv8PpTSXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038572; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g3zxtObz7CwwlAK0TDVpJnJqWHyrye+hGJYI0zTV6bA=; b=TntQi4fu6PHjCjs6DSj6kTy3D2bs2UD+itNAV9cH7KdcKgJG5U2IwZXO/UvzCjcJGQlPFOKxIDJRTDukl1q/VsoyZKBN+LHU653H1gyyo052qChZplgl81Eh2M04nsTdHEKmxGmwCV7t8o92cYhAD5IrGTNJEoDWTrHUBsJjKmk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038572944110.51426265780242; Wed, 26 May 2021 07:16:12 -0700 (PDT) Received: from localhost ([::1]:36524 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluKS-0005Hu-7H for importer2@patchew.org; Wed, 26 May 2021 10:16:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBq-0003s2-BE for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBn-0004Dy-Bp for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-C438MvkCNc6u49zdWrPXyA-1; Wed, 26 May 2021 10:07:12 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 025BB107ACCD; Wed, 26 May 2021 14:07:11 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8762260875; Wed, 26 May 2021 14:07:10 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E92B41800937; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038034; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=g3zxtObz7CwwlAK0TDVpJnJqWHyrye+hGJYI0zTV6bA=; b=fS/GhbAUt9/L2eqlKwU54JFbbzhoAWwySPItPvY4DBwf0VoA4Y/vdavfEDekoLDGSAr7Oc qMyYbkyiZWpBS7jYu6p7oH2f82+PcruElNtKYX42nb8MxEQMqDOmlGmr3z895Sb6Ec6YmQ OIj0FCFiD4J61tZp5aj6n1DRAGTRVKY= X-MC-Unique: C438MvkCNc6u49zdWrPXyA-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 11/14] pckbd: correctly disable PS/2 communication Date: Wed, 26 May 2021 16:06:24 +0200 Message-Id: <20210526140627.381857-12-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin Currently the PS/2 controller command KBD_CCMD_MOUSE_DISABLE doesn't disable the PS/2 mouse communication at all, and the PS/2 controller commands KBD_CCMD_KBD_DISABLE and KBD_CCMD_KBD_ENABLE only disable and enable the keyboard interrupt, which is very different from what a real PS/2 controller does. A guest may notice the difference. Mask out pending data on disabled queues to correctly disable the PS/2 controller communication. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-10-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/pckbd.c | 51 ++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index e9905e1c6b8c..e73bc8181cff 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -131,10 +131,12 @@ #define MOUSE_STATUS_ENABLED 0x20 #define MOUSE_STATUS_SCALE21 0x10 =20 -#define KBD_PENDING_KBD 1 -#define KBD_PENDING_AUX 2 +#define KBD_PENDING_KBD_COMPAT 0x01 +#define KBD_PENDING_AUX_COMPAT 0x02 #define KBD_PENDING_CTRL_KBD 0x04 #define KBD_PENDING_CTRL_AUX 0x08 +#define KBD_PENDING_KBD KBD_MODE_DISABLE_KBD /* 0x10 */ +#define KBD_PENDING_AUX KBD_MODE_DISABLE_MOUSE /* 0x20 */ =20 #define KBD_MIGR_TIMER_PENDING 0x1 =20 @@ -156,6 +158,7 @@ typedef struct KBDState { uint8_t pending; uint8_t obdata; uint8_t cbdata; + uint8_t pending_tmp; void *kbd; void *mouse; QEMUTimer *throttle_timer; @@ -200,7 +203,11 @@ static void kbd_deassert_irq(KBDState *s) =20 static uint8_t kbd_pending(KBDState *s) { - return s->pending; + if (s->extended_state) { + return s->pending & (~s->mode | ~(KBD_PENDING_KBD | KBD_PENDING_AU= X)); + } else { + return s->pending; + } } =20 /* update irq and KBD_STAT_[MOUSE_]OBF */ @@ -361,6 +368,7 @@ static void kbd_write_command(void *opaque, hwaddr addr, break; case KBD_CCMD_MOUSE_ENABLE: s->mode &=3D ~KBD_MODE_DISABLE_MOUSE; + kbd_safe_update_irq(s); break; case KBD_CCMD_TEST_MOUSE: kbd_queue(s, 0x00, 0); @@ -440,6 +448,9 @@ static void kbd_write_data(void *opaque, hwaddr addr, switch(s->write_cmd) { case 0: ps2_write_keyboard(s->kbd, val); + /* sending data to the keyboard reenables PS/2 communication */ + s->mode &=3D ~KBD_MODE_DISABLE_KBD; + kbd_safe_update_irq(s); break; case KBD_CCMD_WRITE_MODE: s->mode =3D val; @@ -466,6 +477,9 @@ static void kbd_write_data(void *opaque, hwaddr addr, break; case KBD_CCMD_WRITE_MOUSE: ps2_write_mouse(s->mouse, val); + /* sending data to the mouse reenables PS/2 communication */ + s->mode &=3D ~KBD_MODE_DISABLE_MOUSE; + kbd_safe_update_irq(s); break; default: break; @@ -565,6 +579,24 @@ static const VMStateDescription vmstate_kbd_extended_s= tate =3D { } }; =20 +static int kbd_pre_save(void *opaque) +{ + KBDState *s =3D opaque; + + if (s->extended_state) { + s->pending_tmp =3D s->pending; + } else { + s->pending_tmp =3D 0; + if (s->pending & KBD_PENDING_KBD) { + s->pending_tmp |=3D KBD_PENDING_KBD_COMPAT; + } + if (s->pending & KBD_PENDING_AUX) { + s->pending_tmp |=3D KBD_PENDING_AUX_COMPAT; + } + } + return 0; +} + static int kbd_pre_load(void *opaque) { KBDState *s =3D opaque; @@ -580,11 +612,21 @@ static int kbd_post_load(void *opaque, int version_id) s->outport =3D kbd_outport_default(s); } s->outport_present =3D false; + s->pending =3D s->pending_tmp; if (!s->extended_state_loaded) { s->obsrc =3D s->status & KBD_STAT_OBF ? (s->status & KBD_STAT_MOUSE_OBF ? KBD_OBSRC_MOUSE : KBD_OBSRC_= KBD) : 0; + if (s->pending & KBD_PENDING_KBD_COMPAT) { + s->pending |=3D KBD_PENDING_KBD; + } + if (s->pending & KBD_PENDING_AUX_COMPAT) { + s->pending |=3D KBD_PENDING_AUX; + } } + /* clear all unused flags */ + s->pending &=3D KBD_PENDING_CTRL_KBD | KBD_PENDING_CTRL_AUX | + KBD_PENDING_KBD | KBD_PENDING_AUX; return 0; } =20 @@ -594,11 +636,12 @@ static const VMStateDescription vmstate_kbd =3D { .minimum_version_id =3D 3, .pre_load =3D kbd_pre_load, .post_load =3D kbd_post_load, + .pre_save =3D kbd_pre_save, .fields =3D (VMStateField[]) { VMSTATE_UINT8(write_cmd, KBDState), VMSTATE_UINT8(status, KBDState), VMSTATE_UINT8(mode, KBDState), - VMSTATE_UINT8(pending, KBDState), + VMSTATE_UINT8(pending_tmp, KBDState), VMSTATE_END_OF_LIST() }, .subsections =3D (const VMStateDescription*[]) { --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038870; cv=none; d=zohomail.com; s=zohoarc; b=b0c69A+WbeYfL874JUPazqB4JYyiROGNhWfI9X7KL6Hh2nzHxTdHsnGXHWv9y1ri5asDVlHuC0RpYfbcZQKCzJoNR9tM0vYtWYozYCPNkXrgnh9z/yjyUZRzV/JKCPA/v82svQNv3hCJSaIPgDLtBgjbAbEMbEv74ZY6wNvnyc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038870; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=M48wh+UrpunSmFHYj/8wc+W2iAj2SmHwMMGaNrSBIMw=; b=isLGRqKP5uTT3XtTeXYu1PC3OtDHnIiQZYuBd5y/XPgU1QOXGb4AExEqR+wItQqqRy40KFnrLZbG47q432lMlWYO0MOANBc6jIBrrWD8/ZZf+Tz9MLgnxX+LkZzjnWvzmwyK6WDT5wn41L0oknaLTHQnOXEhuXcbrL5n1jIyFxM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038870467376.6450857689873; Wed, 26 May 2021 07:21:10 -0700 (PDT) Received: from localhost ([::1]:46996 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluPF-000455-EJ for importer2@patchew.org; Wed, 26 May 2021 10:21:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35438) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluC5-0004IM-7e for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:33 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:46765) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBy-0004KR-OR for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-383-lLJr7Nm5OOaGwVEaSxp3vg-1; Wed, 26 May 2021 10:07:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3C9D690E64E; Wed, 26 May 2021 14:07:20 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 74C6C5D9C6; Wed, 26 May 2021 14:07:12 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 007251800938; Wed, 26 May 2021 16:06:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038046; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=M48wh+UrpunSmFHYj/8wc+W2iAj2SmHwMMGaNrSBIMw=; b=T8R93mSoCYpoiEXsvlaQ44TqwO2iUB5T0gXQFH7tbGnaSM0mTuLwSuxBw9KX8h9XJOOZlI 0EB3kRlFkEKQW6u01oGGH9cnQpQJfbnzFJSRe9JYNGyH/4rBTAbUDFVy6ScG2zPBtyk8Yx pQzecim29SLPsfASuQ7CtrzfF1a/EJ4= X-MC-Unique: lLJr7Nm5OOaGwVEaSxp3vg-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 12/14] pckbd: remove duplicated keyboard and mouse defines Date: Wed, 26 May 2021 16:06:25 +0200 Message-Id: <20210526140627.381857-13-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin In 2005 the author of commit daa579632d "PS2 mouse and keyboard separation (Paul Brook)" and 0e43e99c04 "PS2 mouse and keyboard separation (Paul Brook)" separated the PS/2 controller code and the PS/2 keyboard and mouse code. It seems he forgot to remove a few defines. Remove them now. Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-11-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/pckbd.c | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index e73bc8181cff..de867abc06b7 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -62,21 +62,6 @@ #define KBD_CCMD_RESET 0xFE /* Pulse bit 0 of the output port = P2 =3D CPU reset. */ #define KBD_CCMD_NO_OP 0xFF /* Pulse no bits of the output por= t P2. */ =20 -/* Keyboard Commands */ -#define KBD_CMD_SET_LEDS 0xED /* Set keyboard leds */ -#define KBD_CMD_ECHO 0xEE -#define KBD_CMD_GET_ID 0xF2 /* get keyboard ID */ -#define KBD_CMD_SET_RATE 0xF3 /* Set typematic rate */ -#define KBD_CMD_ENABLE 0xF4 /* Enable scanning */ -#define KBD_CMD_RESET_DISABLE 0xF5 /* reset and disable scanning */ -#define KBD_CMD_RESET_ENABLE 0xF6 /* reset and enable scanning */ -#define KBD_CMD_RESET 0xFF /* Reset */ - -/* Keyboard Replies */ -#define KBD_REPLY_POR 0xAA /* Power on reset */ -#define KBD_REPLY_ACK 0xFA /* Command ACK */ -#define KBD_REPLY_RESEND 0xFE /* Command NACK, send the cmd again */ - /* Status Register Bits */ #define KBD_STAT_OBF 0x01 /* Keyboard output buffer full */ #define KBD_STAT_IBF 0x02 /* Keyboard input buffer full */ @@ -109,28 +94,6 @@ */ #define KBD_OUT_ONES 0xcc =20 -/* Mouse Commands */ -#define AUX_SET_SCALE11 0xE6 /* Set 1:1 scaling */ -#define AUX_SET_SCALE21 0xE7 /* Set 2:1 scaling */ -#define AUX_SET_RES 0xE8 /* Set resolution */ -#define AUX_GET_SCALE 0xE9 /* Get scaling factor */ -#define AUX_SET_STREAM 0xEA /* Set stream mode */ -#define AUX_POLL 0xEB /* Poll */ -#define AUX_RESET_WRAP 0xEC /* Reset wrap mode */ -#define AUX_SET_WRAP 0xEE /* Set wrap mode */ -#define AUX_SET_REMOTE 0xF0 /* Set remote mode */ -#define AUX_GET_TYPE 0xF2 /* Get type */ -#define AUX_SET_SAMPLE 0xF3 /* Set sample rate */ -#define AUX_ENABLE_DEV 0xF4 /* Enable aux device */ -#define AUX_DISABLE_DEV 0xF5 /* Disable aux device */ -#define AUX_SET_DEFAULT 0xF6 -#define AUX_RESET 0xFF /* Reset aux device */ -#define AUX_ACK 0xFA /* Command byte ACK. */ - -#define MOUSE_STATUS_REMOTE 0x40 -#define MOUSE_STATUS_ENABLED 0x20 -#define MOUSE_STATUS_SCALE21 0x10 - #define KBD_PENDING_KBD_COMPAT 0x01 #define KBD_PENDING_AUX_COMPAT 0x02 #define KBD_PENDING_CTRL_KBD 0x04 --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038572; cv=none; d=zohomail.com; s=zohoarc; b=QCRQJzymc8pc0Mm3fC6mczEO541364uwe3qrZHGvovFz6iua5e9t8iUERmhqMVJn7IK+B5UVvhrdF81dMRfEuc0YX73UHHn3PZpxqW1ldiS0JMxqDEiwC1N5I+/4BEg0OMkhPWw8QqJMN9rH8v76OrQ+ZxSKLK1wqEF04Kidkio= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038572; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iQ0/lgssc1eafWvuKxJ1n/R+E4upeZXznjWu7OYJQHQ=; b=VbUmo9Ey7DbBD/LZHCEPd7FDYTweiVCMwpQFRTEhuFneEbbT7kMFd3/fR/cpRC+HXXkiFkPYeooNfC+24jbQ9KHctguz1xWl8NrPLRMGIl5aIxGW7W6UO+r3bNkq2P50DZAaYC18HD4f03fiP/rzDEVwtEd31RW4TKt0qhm3La8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038572124893.6645323325606; Wed, 26 May 2021 07:16:12 -0700 (PDT) Received: from localhost ([::1]:36518 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluKR-0005Hj-C4 for importer2@patchew.org; Wed, 26 May 2021 10:16:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBu-00047B-5t for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluBs-0004HX-GR for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-99-emGLDmxeMm-r1Zqbpb4zcw-1; Wed, 26 May 2021 10:07:17 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6A6E2107ACCD; Wed, 26 May 2021 14:07:16 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 313DA60875; Wed, 26 May 2021 14:07:16 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 0BB5B1800939; Wed, 26 May 2021 16:06:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038039; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iQ0/lgssc1eafWvuKxJ1n/R+E4upeZXznjWu7OYJQHQ=; b=DfdInjdBFCdmUMBiIqQqmxIe66Z9NIhbMXFyIeAdyH5Ua6Aaumb+0/YQup1HjID3+aRIDV uTqZ4E/NKES54iVVrjBDs6rgB8Hk8OBi6ctyKVfBkpeuyArcUa61Mu/Qd5bdslcmYqSqvK jq99W5Vj9Wjd6PztY+f8odv/CqOybDw= X-MC-Unique: emGLDmxeMm-r1Zqbpb4zcw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 13/14] pckbd: clear outport_present in outer pre_load() Date: Wed, 26 May 2021 16:06:26 +0200 Message-Id: <20210526140627.381857-14-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , Gerd Hoffmann , Paolo Bonzini Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Volker R=C3=BCmelin The variable outport_present is a flag to show if the outport subsection was loaded. Clear the outport_present flag in the outer pre_load() function. This method is recommended in the QEMU manual for developers in the chapter "Migration, Subsections". Signed-off-by: Volker R=C3=BCmelin Message-Id: <20210525181441.27768-12-vr_qemu@t-online.de> Signed-off-by: Gerd Hoffmann --- hw/input/pckbd.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/input/pckbd.c b/hw/input/pckbd.c index de867abc06b7..baba62f357a2 100644 --- a/hw/input/pckbd.c +++ b/hw/input/pckbd.c @@ -457,7 +457,6 @@ static void kbd_reset(void *opaque) s->mode =3D KBD_MODE_KBD_INT | KBD_MODE_MOUSE_INT; s->status =3D KBD_STAT_CMD | KBD_STAT_UNLOCKED; s->outport =3D KBD_OUT_RESET | KBD_OUT_A20 | KBD_OUT_ONES; - s->outport_present =3D false; s->pending =3D 0; kbd_deassert_irq(s); if (s->throttle_timer) { @@ -564,6 +563,7 @@ static int kbd_pre_load(void *opaque) { KBDState *s =3D opaque; =20 + s->outport_present =3D false; s->extended_state_loaded =3D false; return 0; } @@ -574,7 +574,6 @@ static int kbd_post_load(void *opaque, int version_id) if (!s->outport_present) { s->outport =3D kbd_outport_default(s); } - s->outport_present =3D false; s->pending =3D s->pending_tmp; if (!s->extended_state_loaded) { s->obsrc =3D s->status & KBD_STAT_OBF ? --=20 2.31.1 From nobody Sat May 4 20:38:23 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038558; cv=none; d=zohomail.com; s=zohoarc; b=lyZ1RrINfkzPThkd6942q6HfiMEppmc3hRRy+Qyk3kVdO9U35PyaQKMF+m2cRspSjzt9qq76o89AvPxdLubDThyy6hXxE3/GLD0w16vbswr80nJ17y5OgGyT35DbkJju2pTMXzh4PivfqvI2TX/huW6DZp/R2e6Mf+jtje1c6C0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038558; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PECO0g06hLDjOu3d7I9Nb0+6uo2MxEBlaUky8/Wav6k=; b=VDTjT5USpWJequ/GBz7u3djRYZYi3JVVQTPKOrduGJ02JPNrluWHiYXwsG2ykgUA5oZWqwF7ME1m8Enaxgz8f+5y1FNNxe6QWfe+snwm4NKRyFWO1LPBWpzWHmUMB1pwtIik9UJt+kDZAZN8Tbi326MNckzVIvNdujnVCPFKeP0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622038558580245.6715352525341; Wed, 26 May 2021 07:15:58 -0700 (PDT) Received: from localhost ([::1]:35850 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluKD-0004qO-Px for importer2@patchew.org; Wed, 26 May 2021 10:15:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35450) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluC8-0004RT-0g for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:35083) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lluC3-0004MQ-KE for qemu-devel@nongnu.org; Wed, 26 May 2021 10:07:35 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-503-b75u_6B1PFG9_p7n2DO0yw-1; Wed, 26 May 2021 10:07:26 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3082D90E647; Wed, 26 May 2021 14:07:25 +0000 (UTC) Received: from sirius.home.kraxel.org (ovpn-112-84.ams2.redhat.com [10.36.112.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CAAFD61094; Wed, 26 May 2021 14:07:17 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 161E6180093A; Wed, 26 May 2021 16:06:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622038050; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PECO0g06hLDjOu3d7I9Nb0+6uo2MxEBlaUky8/Wav6k=; b=EcRilCN5VHREqjmEzPHcPfBOTxbdu1wPOV+ghFhREyx0qMlUNd4fVD4SwVSiuPrnqwBFup ZayaHEByPfpSHS+bs/3OwA4cn4rUytecmRIutGfiX2N1GVsRzny7PnLQGOiBW4fJ5BcecZ sf692DIhjjc3YXhL5gl+2YEB22IHzwU= X-MC-Unique: b75u_6B1PFG9_p7n2DO0yw-1 From: Gerd Hoffmann To: qemu-devel@nongnu.org Subject: [PULL 14/14] hw/input/ps2: Use ps2_raise_irq() instead of open coding it Date: Wed, 26 May 2021 16:06:27 +0200 Message-Id: <20210526140627.381857-15-kraxel@redhat.com> In-Reply-To: <20210526140627.381857-1-kraxel@redhat.com> References: <20210526140627.381857-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=216.205.24.124; envelope-from=kraxel@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.371, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Volker=20R=C3=BCmelin?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Paolo Bonzini , Bin Meng Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) From: Philippe Mathieu-Daud=C3=A9 Inspired-by: Volker R=C3=BCmelin Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Volker R=C3=BCmelin Reviewed-by: Bin Meng Message-Id: <20210513171244.3940519-1-f4bug@amsat.org> Signed-off-by: Gerd Hoffmann --- hw/input/ps2.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index 5cf95b4dd3eb..8dd482c1f65b 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -217,7 +217,7 @@ void ps2_queue(PS2State *s, int b) } =20 ps2_queue_noirq(s, b); - s->update_irq(s->update_arg, 1); + ps2_raise_irq(s); } =20 void ps2_queue_2(PS2State *s, int b1, int b2) @@ -228,7 +228,7 @@ void ps2_queue_2(PS2State *s, int b1, int b2) =20 ps2_queue_noirq(s, b1); ps2_queue_noirq(s, b2); - s->update_irq(s->update_arg, 1); + ps2_raise_irq(s); } =20 void ps2_queue_3(PS2State *s, int b1, int b2, int b3) @@ -240,7 +240,7 @@ void ps2_queue_3(PS2State *s, int b1, int b2, int b3) ps2_queue_noirq(s, b1); ps2_queue_noirq(s, b2); ps2_queue_noirq(s, b3); - s->update_irq(s->update_arg, 1); + ps2_raise_irq(s); } =20 void ps2_queue_4(PS2State *s, int b1, int b2, int b3, int b4) @@ -253,7 +253,7 @@ void ps2_queue_4(PS2State *s, int b1, int b2, int b3, i= nt b4) ps2_queue_noirq(s, b2); ps2_queue_noirq(s, b3); ps2_queue_noirq(s, b4); - s->update_irq(s->update_arg, 1); + ps2_raise_irq(s); } =20 /* keycode is the untranslated scancode in the current scancode set. */ --=20 2.31.1