From nobody Mon Feb 9 14:35:44 2026 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.zoho.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; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1491399303659638.241974889628; Wed, 5 Apr 2017 06:35:03 -0700 (PDT) Received: from localhost ([::1]:40588 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvl5R-0003zg-8N for importer@patchew.org; Wed, 05 Apr 2017 09:35:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvkw0-0004iy-Dd for qemu-devel@nongnu.org; Wed, 05 Apr 2017 09:25:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cvkvz-0000M2-Fy for qemu-devel@nongnu.org; Wed, 05 Apr 2017 09:25:16 -0400 Received: from mail-wr0-x233.google.com ([2a00:1450:400c:c0c::233]:36490) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cvkvz-0000La-90 for qemu-devel@nongnu.org; Wed, 05 Apr 2017 09:25:15 -0400 Received: by mail-wr0-x233.google.com with SMTP id w11so13738593wrc.3 for ; Wed, 05 Apr 2017 06:25:15 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id q131sm7828568wmd.0.2017.04.05.06.25.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Apr 2017 06:25:07 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id F15C93E1061; Wed, 5 Apr 2017 14:25:03 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ILPIZmbHiNNGn4LVBXUsUnQ4gCN+e11KWzBQMi4gCzc=; b=jxbGibZgUkHA2NMyxqCfOSGHHK9BRkxvi0uAJduVdSypoV2aPXOxHSahbmJEkYNVF+ nn/4B/5mDYtEXLRekkWddjrWyleuNCZ+lUNzoqunwNB7EeKK9VlsCSAq+MGUeuma+7sA T49RWarxXja03rIhWwkoRaDu/4dOn4hhqkLfM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ILPIZmbHiNNGn4LVBXUsUnQ4gCN+e11KWzBQMi4gCzc=; b=fevHsYnZ+PPQZkQEQq8xQOXpcpe4ePtrZueAM+wv2PN8Yo/5OZDPFGfHiTlTgMGWZ3 vrQP64bk8BjvLeYzJ26S4AoOAti7oeqmr+eMD/FGkcRuyrKUBoqsDG5PC+axIsFj9GqX xZnLiVEjfJbq4xSjuAOuMSYeL2c5XPkEpLB6DSWjFVCpKBNWxpwhdDzDx01NwXAsNlZx GKy/uzsiI03aZaaLlbRd2FeD2xQBGUDXSH4El+TImbuBkv3gGIqIOnXM3hZUm/l/mBWP IOnmJGNqGaoXVyNY+9CJCFQJn4omGShSsKyW2I7pq+Of5gIuTQ/3lEwROmCLJZvp31L4 NRfg== X-Gm-Message-State: AFeK/H2RD/Z3OiLn3veYlGcMq6csnQZJQmsDk8GXAlY8s88bR+SFSxgW UH5nJ7/acorA+0Fb X-Received: by 10.28.220.132 with SMTP id t126mr9471356wmg.140.1491398713679; Wed, 05 Apr 2017 06:25:13 -0700 (PDT) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= To: dovgaluk@ispras.ru, rth@twiddle.net, pbonzini@redhat.com Date: Wed, 5 Apr 2017 14:25:03 +0100 Message-Id: <20170405132503.32125-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170405132503.32125-1-alex.bennee@linaro.org> References: <20170405132503.32125-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::233 Subject: [Qemu-devel] [PATCH v2 12/12] replay: assert time only goes forward 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: mttcg@listserver.greensocs.com, peter.maydell@linaro.org, nikunj@linux.vnet.ibm.com, a.rigo@virtualopensystems.com, qemu-devel@nongnu.org, cota@braap.org, bobby.prani@gmail.com, =?UTF-8?q?Alex=20Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 If we find ourselves trying to add an event to the log where time has gone backwards it is because a vCPU event has occurred and the main-loop is not yet aware of time moving forward. This should not happen and if it does its better to fail early than generate a log that will have weird behaviour. Signed-off-by: Alex Benn=C3=A9e --- replay/replay-internal.c | 4 ++++ replay/replay.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/replay/replay-internal.c b/replay/replay-internal.c index bea7b4aa6b..fca8514012 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -195,6 +195,10 @@ void replay_save_instructions(void) if (replay_file && replay_mode =3D=3D REPLAY_MODE_RECORD) { replay_mutex_lock(); int diff =3D (int)(replay_get_current_step() - replay_state.curren= t_step); + + /* Time can only go forward */ + assert(diff >=3D 0); + if (diff > 0) { replay_put_event(EVENT_INSTRUCTION); replay_put_dword(diff); diff --git a/replay/replay.c b/replay/replay.c index 9e0724e756..f810628cac 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -84,6 +84,10 @@ void replay_account_executed_instructions(void) if (replay_state.instructions_count > 0) { int count =3D (int)(replay_get_current_step() - replay_state.current_step); + + /* Time can only go forward */ + assert(count >=3D 0); + replay_state.instructions_count -=3D count; replay_state.current_step +=3D count; if (replay_state.instructions_count =3D=3D 0) { --=20 2.11.0