From nobody Thu Nov 6 01:09:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1538295538135656.0004648133275; Sun, 30 Sep 2018 01:18:58 -0700 (PDT) Received: from localhost ([::1]:54230 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6WwK-0006gr-PX for importer@patchew.org; Sun, 30 Sep 2018 04:18:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1g6Wr3-00023L-0S for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:13:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1g6Wr1-0008LF-Bn for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:13:28 -0400 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:54210) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1g6Wqz-0008Fi-9y for qemu-devel@nongnu.org; Sun, 30 Sep 2018 04:13:27 -0400 Received: by mail-wm1-x342.google.com with SMTP id b19-v6so5798623wme.3 for ; Sun, 30 Sep 2018 01:13:24 -0700 (PDT) Received: from 640k.lan (94-36-187-248.adsl-ull.clienti.tiscali.it. [94.36.187.248]) by smtp.gmail.com with ESMTPSA id u76-v6sm11369194wmd.10.2018.09.30.01.13.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Sep 2018 01:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=njTdKD14lsEtZiEO6Aw3burMs2/rCCEHZuLgKsGcCQE=; b=TGsLvfR7dghPckHnRGILBt9z35i+ybtEsFOiYjmMNuaELkgPVcnSUTWs+i4HpCBoch ar3NfR+HXWnJlWpWKk0DWpdlYGY6950R1QuipQfUM/+F+i5Th223SsQ4VPNRY2CZSvQa kYxjgV5asZ4KwUU4z68o/a5AwmkpMp5kquPbLpNcRYTdBAxVyqkq6l/JhhEokRVxYnW3 G7GRMR0r31E+AC7Wp/v+WBPpVU3VfF8AVM1VDfmwPQA4k1f4ZPqQlPAml5L63/RQ+gir 6o1MFkc24T9qBkUdXkaQXGyrIOuv/wGguQi3xR4c9suJfNhtUzqkauRsRR9sKDjkW58l pPNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=njTdKD14lsEtZiEO6Aw3burMs2/rCCEHZuLgKsGcCQE=; b=Jl/PTK2QRBd0MSSQl58FbAXL27mT7TlktzafPIAz2wXMECseo1grJKumJF9VAPOkiz VCdbWS+EYDG2dAujyqkvTz3hugzdJFAqQJoicQnud4yGo6+n8DzvWXrYqnIoAJrw7F6e qLslphV1GJPgxKdVJWG+ItjPyeraBwRWznQtW+qBydy+S4zSiR994tLM9wRBqzTPeYkv +B48OU7ECA9ISJQWAryXaUMWqIkKU/ni+uDsxoUXFz1MbTAQqHNbGjuUDV1lFdR5Drbk Y7wryqw3H4dH9w+mhcH3sahAzo0XS30tPgacMmH7ZcIzz9S+3PI/T/eEXeXOKAdOUGMV XCyA== X-Gm-Message-State: ABuFfogrmlhp9pNPYHPoFZpfJgw2RSsXEnVmSgnhXt/AkeN7rAW2DH5X +6ihcigmzC3/XTu2JTHKEBwsVSru X-Google-Smtp-Source: ACcGV638MfUJBbQDGHL05Wi4/CkmF0YSqAy/YK9B9YfrvnSPcC82mr+w6UEhAUi+jKbDeIQ+e/KhKQ== X-Received: by 2002:a1c:7406:: with SMTP id p6-v6mr6323468wmc.62.1538295203271; Sun, 30 Sep 2018 01:13:23 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Sun, 30 Sep 2018 10:12:02 +0200 Message-Id: <1538295197-23704-5-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> References: <1538295197-23704-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PULL 04/79] ps2: prevent changing irq state on save and load X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Pavel Dovgalyuk Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Pavel Dovgalyuk Commit 2858ab09e6f708e381fc1a1cc87e747a690c4884 changed PS/2 keyboard/mouse buffers to the standard size. However, its state may change when migrating from the old buffer size and therefore irq needs updating. But this change made wrong, because it throws the whole queue if there are too much data instead of cropping it. That commit also updates irq (because the queue state may change). But updating the irq may change the VM state (and determinism of the execution). E.g., when replaying the execution, one may save the VM state and the state of the interrupt controller will be updated at the moment of saving, instead of using the recorded update events. This patch makes the queue update deterministic: it removes the update_irq call and crops the queue to prevent losing the characters and changing the required irq status. Signed-off-by: Pavel Dovgalyuk Message-Id: <20180511081601.14610.39946.stgit@pasha-VirtualBox> Signed-off-by: Paolo Bonzini --- hw/input/ps2.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hw/input/ps2.c b/hw/input/ps2.c index fdfcadf..6c43fc2 100644 --- a/hw/input/ps2.c +++ b/hw/input/ps2.c @@ -914,7 +914,12 @@ static void ps2_common_post_load(PS2State *s) uint8_t tmp_data[PS2_QUEUE_SIZE]; =20 /* set the useful data buffer queue size, < PS2_QUEUE_SIZE */ - size =3D (q->count < 0 || q->count > PS2_QUEUE_SIZE) ? 0 : q->count; + size =3D q->count; + if (q->count < 0) { + size =3D 0; + } else if (q->count > PS2_QUEUE_SIZE) { + size =3D PS2_QUEUE_SIZE; + } =20 /* move the queue elements to the start of data array */ for (i =3D 0; i < size; i++) { @@ -929,7 +934,6 @@ static void ps2_common_post_load(PS2State *s) q->rptr =3D 0; q->wptr =3D (size =3D=3D PS2_QUEUE_SIZE) ? 0 : size; q->count =3D size; - s->update_irq(s->update_arg, q->count !=3D 0); } =20 static void ps2_kbd_reset(void *opaque) --=20 1.8.3.1