From patchwork Wed Apr 5 13:25:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 96859 Delivered-To: patch@linaro.org Received: by 10.182.246.10 with SMTP id xs10csp262161obc; Wed, 5 Apr 2017 06:33:47 -0700 (PDT) X-Received: by 10.55.87.198 with SMTP id l189mr26361582qkb.304.1491399226988; Wed, 05 Apr 2017 06:33:46 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id c38si17791419qte.183.2017.04.05.06.33.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 05 Apr 2017 06:33:46 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:40584 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cvl4E-0003AR-IV for patch@linaro.org; Wed, 05 Apr 2017 09:33:46 -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) 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) 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) From: =?utf-8?q?Alex_Benn=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 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_Benn=C3=A9e?= , fred.konrad@greensocs.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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ée --- replay/replay-internal.c | 4 ++++ replay/replay.c | 4 ++++ 2 files changed, 8 insertions(+) -- 2.11.0 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 == REPLAY_MODE_RECORD) { replay_mutex_lock(); int diff = (int)(replay_get_current_step() - replay_state.current_step); + + /* Time can only go forward */ + assert(diff >= 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 = (int)(replay_get_current_step() - replay_state.current_step); + + /* Time can only go forward */ + assert(count >= 0); + replay_state.instructions_count -= count; replay_state.current_step += count; if (replay_state.instructions_count == 0) {