From nobody Mon Feb 9 19:54:25 2026 Delivered-To: importer@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+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1622038318; cv=none; d=zohomail.com; s=zohoarc; b=QYW4AYA+yd4whCL9H30mWyb5hcBb9OyzYoUXjLKKPIgPsXMmMc9puyKpIMGo4Mn4TJPeuw3/IHykd8gsNjYaFAYLSnohbzg/kRadJNrRH7Qnqduc0T/2ZLYcBgc1RYHdReiRV64G1/y3Nn8+JnARuuUKPDls58B1n9x23nb1D34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622038318; 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=jy2b8mwGi6esc97r1FihEqktvd7zyspRU9fXviC6i0Uf3/X9Sg3A5qHtzmwxoKChtkiV5HWSqfIIq1Debg19KwH06UyTzXhrurjhm4gKZKS8O2Gze33YE738pnLJoQmwH5CvXnOLjK2ao/nQoSni7oU0mWKtOK/Hl27tnI2duQ4= 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+importer=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 1622038318670311.6218349772033; Wed, 26 May 2021 07:11:58 -0700 (PDT) Received: from localhost ([::1]:48990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lluGL-0003Eu-Kz for importer@patchew.org; Wed, 26 May 2021 10:11:57 -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+importer=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+importer=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