From nobody Sun May 19 19:10:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564044314; cv=none; d=zoho.com; s=zohoarc; b=Q3alf/6Z/Fmfq1d8k9I3gk70/yWeSm330FDCht1VmeCjs6DsS0hyfFJJIPt45Q1cpSbTBtHzg+namsibacxZKXevaEaOLRcIhmopM4vBZ/6L0EIY5ryXJmrCZ+NcEIStyAkOoR2qI1byN45T/O2NO+A0Au7ex0siPUbBY5zeg/I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564044314; 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:ARC-Authentication-Results; bh=buPsL5PLrDwxxgpsn9NBvoRVU78cNf46I1QhIpZJ/uU=; b=hu5GrHgR5BvGiKpYfLuC55OOXHbey0+Kxt7Ajk7FBSxtgEwKakXhcfP3+Byw8SVz+zquWP1renMMTNyKEQu2I3qD34KdNYKUJgjjbq68CEI9zvECdKsuyIjepQTYbTrdvMHIGOpwo6vkF975tMWc5TDRxwEMFoej9PWTWG8oSPA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1564044314740709.5161118519292; Thu, 25 Jul 2019 01:45:14 -0700 (PDT) Received: from localhost ([::1]:57184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZNB-0001Ud-BK for importer@patchew.org; Thu, 25 Jul 2019 04:45:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50067) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZMH-0006gi-R3 for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqZMG-0008Qz-Re for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:17 -0400 Received: from mail.ispras.ru ([83.149.199.45]:56916) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hqZMG-0008Qh-KW for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:16 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id C358754006A; Thu, 25 Jul 2019 11:44:15 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 25 Jul 2019 11:44:15 +0300 Message-ID: <156404425561.18669.13015037579222450241.stgit@pasha-Precision-3630-Tower> In-Reply-To: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> References: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [for-4.2 PATCH v2 1/8] replay: add missing fix for internal function 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: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: pbonzini@redhat.com This is a fix which was missed by patch 74c0b816adfc6aa1b01b4426fdf385e32e35cbac, which added current_step parameter to the replay_advance_current_step function. Signed-off-by: Pavel Dovgalyuk --- replay/replay-internal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/replay/replay-internal.c b/replay/replay-internal.c index 9e41ed1dcf..979f3a0b39 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -228,7 +228,7 @@ void replay_mutex_unlock(void) =20 void replay_advance_current_step(uint64_t current_step) { - int diff =3D (int)(replay_get_current_step() - replay_state.current_st= ep); + int diff =3D (int)(current_step - replay_state.current_step); =20 /* Time can only go forward */ assert(diff >=3D 0); From nobody Sun May 19 19:10:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564044299; cv=none; d=zoho.com; s=zohoarc; b=h95THFKBNuhpFfakH46TRaIKTxEYsoajp/LiNi2LLROn3rzrMoO8iyOWSrSXj0elbEh36PK6zADE7GmgdHNWyCw2jtiVcI6corfchk1aWyhIKHHvT2FBPXhfnR+tKBaegXqOcP3kmHT93mtLk6bfod9lcDRx1H/qWbBdHiEkA6k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564044299; 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:ARC-Authentication-Results; bh=8ihHEaEmEQs266HY8i9RIsFrv0NlHuRc3X6MKQwEvPs=; b=RwSXE4aoDI/9zoog5D9iF6hbE1UCsEpb8VAs59cO7AwvS4UtiZyK7zfcrS5TS7OW7i7QT4zbmpXWN01xo6oEk8qCwi//oggoCnMU2XetAKnLRPXP0t1Ke8CmihwWrgwoysJu9DNvaOEayaCqjmV2xkN3Khy5j/uEISzFHwLTehY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1564044299329123.7020964034092; Thu, 25 Jul 2019 01:44:59 -0700 (PDT) Received: from localhost ([::1]:57174 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZMv-0000Vq-Oc for importer@patchew.org; Thu, 25 Jul 2019 04:44:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50086) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZMO-0007CZ-LJ for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqZMM-0008Sx-Ir for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:24 -0400 Received: from mail.ispras.ru ([83.149.199.45]:56932) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hqZMM-0008Sk-8l for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:22 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 5F89C54006A; Thu, 25 Jul 2019 11:44:21 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 25 Jul 2019 11:44:21 +0300 Message-ID: <156404426119.18669.6707258931552832854.stgit@pasha-Precision-3630-Tower> In-Reply-To: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> References: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [for-4.2 PATCH v2 2/8] replay: document development rules 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: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Pavel Dovgalyuk This patch introduces docs/devel/replay.txt which describes the rules that should be followed to make virtual devices usable in record/replay mod= e. Signed-off-by: Pavel Dovgalyuk -- v9: fixed external virtual clock description (reported by Artem Pisarenko) --- docs/devel/replay.txt | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 docs/devel/replay.txt diff --git a/docs/devel/replay.txt b/docs/devel/replay.txt new file mode 100644 index 0000000000..e641c35add --- /dev/null +++ b/docs/devel/replay.txt @@ -0,0 +1,46 @@ +Record/replay mechanism, that could be enabled through icount mode, expects +the virtual devices to satisfy the following requirements. + +The main idea behind this document is that everything that affects +the guest state during execution in icount mode should be deterministic. + +Timers +=3D=3D=3D=3D=3D=3D + +All virtual devices should use virtual clock for timers that change the gu= est +state. Virtual clock is deterministic, therefore such timers are determini= stic +too. + +Virtual devices can also use realtime clock for the events that do not cha= nge +the guest state directly. When the clock ticking should depend on VM execu= tion +speed, use virtual clock with EXTERNAL attribute. It is not deterministic, +but its speed depends on the guest execution. This clock is used by +the virtual devices (e.g., slirp routing device) that lie outside the +replayed guest. + +Bottom halves +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Bottom half callbacks, that affect the guest state, should be invoked thro= ugh +replay_bh_schedule_event or replay_bh_schedule_oneshot_event functions. +Their invocations are saved in record mode and synchronized with the exist= ing +log in replay mode. + +Saving/restoring the VM state +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D + +All fields in the device state structure (including virtual timers) +should be restored by loadvm to the same values they had before savevm. + +Avoid accessing other devices' state, because the order of saving/restoring +is not defined. It means that you should not call functions like +'update_irq' in post_load callback. Save everything explicitly to avoid +the dependencies that may make restoring the VM state non-deterministic. + +Stopping the VM +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Stopping the guest should not interfere with its state (with the exception +of the network connections, that could be broken by the remote timeouts). +VM can be stopped at any moment of replay by the user. Restarting the VM +after that stop should not break the replay by the unneeded guest state ch= ange. From nobody Sun May 19 19:10:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564044311; cv=none; d=zoho.com; s=zohoarc; b=SP5vapk1NdSeuvWCO9TVIVPmxzLu59OmBsI4iWbnFba5P5bfU8dEcwFGD9ZdAB89uaspIa/VlrzToGDvhoHWF+elxR4ianHOQumq4Hy/HTzJox3LhvnMjZChyL+LH+G891n1EQupRzr93imec4nnpA8qYvx4L3K57mA5oCgY5vs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564044311; 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:ARC-Authentication-Results; bh=qqnQn+RfdB5aTwe3mvWMu1lE4XvVgmOGNHZNhiS3R70=; b=MO18z/DfnZTlWqMdQbVOS0E4ET+LOeF3tQqVTarZVV3gDIzVF7Bt4DHjjW3Wwe8U03s7jlnFFPHQyM+DhOWLGLXRWHPgqMmlNzJPBF72hvLRV4PiGd0xjLjQnvEI4X9/SA8Q1l3XRzokiC1GFmfl94hENsTq8fcmzqvk/PaYk4c= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1564044311045255.78964628413905; Thu, 25 Jul 2019 01:45:11 -0700 (PDT) Received: from localhost ([::1]:57178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZN7-00018L-8P for importer@patchew.org; Thu, 25 Jul 2019 04:45:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50113) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZMU-0007cn-KJ for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqZMS-0008VI-VI for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:30 -0400 Received: from mail.ispras.ru ([83.149.199.45]:56954) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hqZMS-0008Uj-Ig for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:28 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 02ABC54006A; Thu, 25 Jul 2019 11:44:26 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 25 Jul 2019 11:44:26 +0300 Message-ID: <156404426682.18669.17014100602930969222.stgit@pasha-Precision-3630-Tower> In-Reply-To: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> References: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [for-4.2 PATCH v2 3/8] util/qemu-timer: refactor deadline calculation for external timers 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: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Pavel Dovgalyuk icount-based record/replay uses qemu_clock_deadline_ns_all to measure the period until vCPU may be interrupted. This function takes in account the virtual timers, because they belong to the virtual devices that may generate interrupt request or affect the virtual machine state. However, there are a subset of virtual timers, that are marked with 'external' flag. These do not change the virtual machine state and only based on virtual clock. Calculating the deadling using the external timers breaks the determinism, because they do not belong to the replayed part of the virtual machine. This patch fixes the deadline calculation for this case by adding new parameter for skipping the external timers when it is needed. Signed-off-by: Pavel Dovgalyuk -- v2 changes: - added new parameter for timer attribute mask --- cpus.c | 17 ++++++++++++----- include/qemu/timer.h | 8 ++++++-- qtest.c | 3 ++- tests/ptimer-test-stubs.c | 4 ++-- tests/ptimer-test.c | 6 ++++-- util/qemu-timer.c | 30 +++++++++++++++++++++++++++--- 6 files changed, 53 insertions(+), 15 deletions(-) diff --git a/cpus.c b/cpus.c index 927a00aa90..a7120ffbd5 100644 --- a/cpus.c +++ b/cpus.c @@ -553,7 +553,8 @@ void qtest_clock_warp(int64_t dest) assert(qtest_enabled()); aio_context =3D qemu_get_aio_context(); while (clock < dest) { - int64_t deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL= ); + int64_t deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); int64_t warp =3D qemu_soonest_timeout(dest - clock, deadline); =20 seqlock_write_lock(&timers_state.vm_clock_seqlock, @@ -613,7 +614,8 @@ void qemu_start_warp_timer(void) =20 /* We want to use the earliest deadline from ALL vm_clocks */ clock =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL_RT); - deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); + deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + ~QEMU_TIMER_ATTR_EXTERNAL); if (deadline < 0) { static bool notified; if (!icount_sleep && !notified) { @@ -1349,7 +1351,12 @@ static int64_t tcg_get_icount_limit(void) int64_t deadline; =20 if (replay_mode !=3D REPLAY_MODE_PLAY) { - deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); + /* + * Include all the timers, because they may need an attention. + * Too long CPU execution may create unnecessary delay in UI. + */ + deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); =20 /* Maintain prior (possibly buggy) behaviour where if no deadline * was set (as there is no QEMU_CLOCK_VIRTUAL timer) or it is more= than @@ -1370,8 +1377,8 @@ static void handle_icount_deadline(void) { assert(qemu_in_vcpu_thread()); if (use_icount) { - int64_t deadline =3D - qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); + int64_t deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); =20 if (deadline =3D=3D 0) { /* Wake up other AioContexts. */ diff --git a/include/qemu/timer.h b/include/qemu/timer.h index 5d978e1634..d7e378c8af 100644 --- a/include/qemu/timer.h +++ b/include/qemu/timer.h @@ -62,13 +62,15 @@ typedef enum { * The following attributes are available: * * QEMU_TIMER_ATTR_EXTERNAL: drives external subsystem + * QEMU_TIMER_ATTR_ALL: mask for all existing attributes * * Timers with this attribute do not recorded in rr mode, therefore it cou= ld be * used for the subsystems that operate outside the guest core. Applicable= only * with virtual clock type. */ =20 -#define QEMU_TIMER_ATTR_EXTERNAL BIT(0) +#define QEMU_TIMER_ATTR_EXTERNAL ((int)BIT(0)) +#define QEMU_TIMER_ATTR_ALL 0xffffffff =20 typedef struct QEMUTimerList QEMUTimerList; =20 @@ -177,6 +179,8 @@ bool qemu_clock_use_for_deadline(QEMUClockType type); /** * qemu_clock_deadline_ns_all: * @type: the clock type + * @attr_mask: mask for the timer attributes that are included + * in deadline calculation * * Calculate the deadline across all timer lists associated * with a clock (as opposed to just the default one) @@ -184,7 +188,7 @@ bool qemu_clock_use_for_deadline(QEMUClockType type); * * Returns: time until expiry in nanoseconds or -1 */ -int64_t qemu_clock_deadline_ns_all(QEMUClockType type); +int64_t qemu_clock_deadline_ns_all(QEMUClockType type, int attr_mask); =20 /** * qemu_clock_get_main_loop_timerlist: diff --git a/qtest.c b/qtest.c index 15e27e911f..4e208562ac 100644 --- a/qtest.c +++ b/qtest.c @@ -655,7 +655,8 @@ static void qtest_process_command(CharBackend *chr, gch= ar **words) int ret =3D qemu_strtoi64(words[1], NULL, 0, &ns); g_assert(ret =3D=3D 0); } else { - ns =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); + ns =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); } qtest_clock_warp(qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns); qtest_send_prefix(chr); diff --git a/tests/ptimer-test-stubs.c b/tests/ptimer-test-stubs.c index 54b3fd26f6..ed393d9082 100644 --- a/tests/ptimer-test-stubs.c +++ b/tests/ptimer-test-stubs.c @@ -88,9 +88,9 @@ int64_t qemu_clock_get_ns(QEMUClockType type) return ptimer_test_time_ns; } =20 -int64_t qemu_clock_deadline_ns_all(QEMUClockType type) +int64_t qemu_clock_deadline_ns_all(QEMUClockType type, int attr_mask) { - QEMUTimerList *timer_list =3D main_loop_tlg.tl[type]; + QEMUTimerList *timer_list =3D main_loop_tlg.tl[QEMU_CLOCK_VIRTUAL]; QEMUTimer *t =3D timer_list->active_timers.next; int64_t deadline =3D -1; =20 diff --git a/tests/ptimer-test.c b/tests/ptimer-test.c index b30aad0737..5b20e91599 100644 --- a/tests/ptimer-test.c +++ b/tests/ptimer-test.c @@ -50,13 +50,15 @@ static void ptimer_test_set_qemu_time_ns(int64_t ns) =20 static void qemu_clock_step(uint64_t ns) { - int64_t deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); + int64_t deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); int64_t advanced_time =3D qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ns; =20 while (deadline !=3D -1 && deadline <=3D advanced_time) { ptimer_test_set_qemu_time_ns(deadline); ptimer_test_expire_qemu_timers(deadline, QEMU_CLOCK_VIRTUAL); - deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL); + deadline =3D qemu_clock_deadline_ns_all(QEMU_CLOCK_VIRTUAL, + QEMU_TIMER_ATTR_ALL); } =20 ptimer_test_set_qemu_time_ns(advanced_time); diff --git a/util/qemu-timer.c b/util/qemu-timer.c index 1cc1b2f2c3..4b16ea3517 100644 --- a/util/qemu-timer.c +++ b/util/qemu-timer.c @@ -253,14 +253,38 @@ int64_t timerlist_deadline_ns(QEMUTimerList *timer_li= st) * ignore whether or not the clock should be used in deadline * calculations. */ -int64_t qemu_clock_deadline_ns_all(QEMUClockType type) +int64_t qemu_clock_deadline_ns_all(QEMUClockType type, int attr_mask) { int64_t deadline =3D -1; + int64_t delta; + int64_t expire_time; + QEMUTimer *ts; QEMUTimerList *timer_list; QEMUClock *clock =3D qemu_clock_ptr(type); + + if (!clock->enabled) { + return -1; + } + QLIST_FOREACH(timer_list, &clock->timerlists, list) { - deadline =3D qemu_soonest_timeout(deadline, - timerlist_deadline_ns(timer_list)); + qemu_mutex_lock(&timer_list->active_timers_lock); + ts =3D timer_list->active_timers; + /* Skip all external timers */ + while (ts && (ts->attributes & ~attr_mask)) { + ts =3D ts->next; + } + if (!ts) { + qemu_mutex_unlock(&timer_list->active_timers_lock); + continue; + } + expire_time =3D ts->expire_time; + qemu_mutex_unlock(&timer_list->active_timers_lock); + + delta =3D expire_time - qemu_clock_get_ns(type); + if (delta <=3D 0) { + delta =3D 0; + } + deadline =3D qemu_soonest_timeout(deadline, delta); } return deadline; } From nobody Sun May 19 19:10:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564044347; cv=none; d=zoho.com; s=zohoarc; b=cZTHl3zAn6zfou0pS7yVA7gNMKrGTN602DMqXZj4hnIkRJGJ3seH+KHPtIoFpK/L65t77AjxD5U6XV/ERgRBA4Ll2EOYvMRuFaS7BJrkxIxw+yum3syVIo1lmHjz0yawUDn0M8r6+TA9b6vgSV/lDbAw6eprBXNsbQTthjCQPhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564044347; 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:ARC-Authentication-Results; bh=kzmHwe/8qFSWkJO7cZpuLzgW75s2EsHMLFqSs6DJJjc=; b=lhQB2iH93t/DjNJtbxd7CqIYTfhXWXEwVDspSp560D0ywwyM4RWZQNekWYWi4FO5GhZkWgnL81jrUtFdKz0sHyWsO8oPJehhJLF005v+CR+A5IILiYkV2CUhZvi3Rz0IaO8jGQRNnETno/4hzne8wJ2ddjPQ6/h9TNnMFVstyv0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1564044347482194.42173054718785; Thu, 25 Jul 2019 01:45:47 -0700 (PDT) Received: from localhost ([::1]:57202 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZNi-0003x7-4R for importer@patchew.org; Thu, 25 Jul 2019 04:45:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50136) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZMY-0007ua-PM for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqZMX-00005l-LZ for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:34 -0400 Received: from mail.ispras.ru ([83.149.199.45]:56994) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hqZMX-00005T-Dk for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:33 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 8F95954006A; Thu, 25 Jul 2019 11:44:32 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 25 Jul 2019 11:44:32 +0300 Message-ID: <156404427238.18669.12378772823692338069.stgit@pasha-Precision-3630-Tower> In-Reply-To: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> References: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [for-4.2 PATCH v2 4/8] replay: fix replay shutdown 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: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Pavel Dovgalyuk This patch fixes shutdown of the replay process, which is terminated with the assert when shutdown event is read from the log. replay_finish_event reads new data_kind and therefore the value of data_kind should be preserved to be valid at qemu_system_shutdown_request call. Signed-off-by: Pavel Dovgalyuk --- replay/replay.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/replay/replay.c b/replay/replay.c index 8b172b2d1b..8d77a4ca4c 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -45,14 +45,14 @@ bool replay_next_event_is(int event) } =20 while (true) { - if (event =3D=3D replay_state.data_kind) { + unsigned int data_kind =3D replay_state.data_kind; + if (event =3D=3D data_kind) { res =3D true; } - switch (replay_state.data_kind) { + switch (data_kind) { case EVENT_SHUTDOWN ... EVENT_SHUTDOWN_LAST: replay_finish_event(); - qemu_system_shutdown_request(replay_state.data_kind - - EVENT_SHUTDOWN); + qemu_system_shutdown_request(data_kind - EVENT_SHUTDOWN); break; default: /* clock, time_t, checkpoint and other events */ From nobody Sun May 19 19:10:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564044365; cv=none; d=zoho.com; s=zohoarc; b=LQH2KpVbYFiI4b/l1WkEVWsSKvO3Wws+yVKZYQWQgO7YOQeFtSYy4nIMBJn9FR4ORklc6QLwlSK3W1ky1Qa3QxLaWINw2qX0Xv1jEmxxmczVYcZwrwOfh+w9KFGa6Dzs60xQGaZgFqjJt7/oJ2PZXtAClUxnZpIrjnWBesRJAyk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564044365; 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:ARC-Authentication-Results; bh=sfqjak1f3Z5qZI8/97nmf1t3HGsdYTPg4bICM4QTWx8=; b=N3jXdlhi99gi6zMwRACKul5UsXM8eJ75dzwoa5VakYdqGFOAaXXFC98ZWE8Au3S/O5pV+jBrOZ+36T9XTwVeF5WbX2EDjSGOQUOPTN7rOp8rIZd7VhtI9F0XbiOOdWhZ4RZLmW+4iO6FW4EBKDR8AVAnzezqn7hMoUhFgWRyPKg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1564044365455447.2028209721112; Thu, 25 Jul 2019 01:46:05 -0700 (PDT) Received: from localhost ([::1]:57212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZNz-0005F0-4q for importer@patchew.org; Thu, 25 Jul 2019 04:46:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50165) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZMe-0008KZ-I3 for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqZMd-00008E-Ff for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:40 -0400 Received: from mail.ispras.ru ([83.149.199.45]:57026) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hqZMd-000080-78 for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:39 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 3DA5154006A; Thu, 25 Jul 2019 11:44:38 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 25 Jul 2019 11:44:38 +0300 Message-ID: <156404427799.18669.8072341590511911277.stgit@pasha-Precision-3630-Tower> In-Reply-To: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> References: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [for-4.2 PATCH v2 5/8] replay: refine replay-time module 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: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Pavel Dovgalyuk This patch removes refactoring artifacts from the replay/replay-time.c Signed-off-by: Pavel Dovgalyuk --- replay/replay-time.c | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/replay/replay-time.c b/replay/replay-time.c index 5154cb0ce9..49c9e5d8b2 100644 --- a/replay/replay-time.c +++ b/replay/replay-time.c @@ -14,18 +14,19 @@ #include "replay-internal.h" #include "qemu/error-report.h" =20 -int64_t replay_save_clock(ReplayClockKind kind, int64_t clock, int64_t raw= _icount) +int64_t replay_save_clock(ReplayClockKind kind, int64_t clock, + int64_t raw_icount) { - if (replay_file) { - g_assert(replay_mutex_locked()); + g_assert(replay_file); + g_assert(replay_mutex_locked()); =20 - /* Due to the caller's locking requirements we get the icount from= it - * instead of using replay_save_instructions(). - */ - replay_advance_current_step(raw_icount); - replay_put_event(EVENT_CLOCK + kind); - replay_put_qword(clock); - } + /* + * Due to the caller's locking requirements we get the icount from it + * instead of using replay_save_instructions(). + */ + replay_advance_current_step(raw_icount); + replay_put_event(EVENT_CLOCK + kind); + replay_put_qword(clock); =20 return clock; } @@ -47,20 +48,15 @@ void replay_read_next_clock(ReplayClockKind kind) /*! Reads next clock event from the input. */ int64_t replay_read_clock(ReplayClockKind kind) { + int64_t ret; g_assert(replay_file && replay_mutex_locked()); =20 replay_account_executed_instructions(); =20 - if (replay_file) { - int64_t ret; - if (replay_next_event_is(EVENT_CLOCK + kind)) { - replay_read_next_clock(kind); - } - ret =3D replay_state.cached_clock[kind]; - - return ret; + if (replay_next_event_is(EVENT_CLOCK + kind)) { + replay_read_next_clock(kind); } + ret =3D replay_state.cached_clock[kind]; =20 - error_report("REPLAY INTERNAL ERROR %d", __LINE__); - exit(1); + return ret; } From nobody Sun May 19 19:10:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564044378; cv=none; d=zoho.com; s=zohoarc; b=QQj+p4MxBhqYaewD+lqXubjvqS0u+1bXnW+/Ad8RZ0aTdTaADOcIy4JthD6TSa8/jPZSPOuFBQt0TpIw8i6+vvZVgJwJtVyaVPGoJlRZN+lSROUE3TH6HMeoI+2T9BSlGNWqILePv3qdpdloxj6Zb6SgpYY7tmYIa2ZULlp1aOI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564044378; 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:ARC-Authentication-Results; bh=T9BUKUl5e+Z0XgvoJHaTOGYNoPk789Y9hiU6ODeC+J0=; b=jMS+ueYYWZ6jy7XsFpIbdN0MNsJ/OSxJLiqUaGqfYOCQ4zGBm78LYh/dubmKncgZZmtHksk4nF0xjPw+WI2TTH/xgWrGDGTsSqpBmXYNqPCLP82PKUCHrJBOp1cOL1Kv08N7ZGNMDLLASjQOA6krl/N1SM3TNw/G+WDX9Yy/r3k= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1564044378182799.5687850055537; Thu, 25 Jul 2019 01:46:18 -0700 (PDT) Received: from localhost ([::1]:57218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZOD-00065G-73 for importer@patchew.org; Thu, 25 Jul 2019 04:46:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50204) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZMl-0000Mi-1R for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqZMj-0000AR-8l for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:46 -0400 Received: from mail.ispras.ru ([83.149.199.45]:57046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hqZMi-0000A6-SS for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:45 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id F128754006A; Thu, 25 Jul 2019 11:44:43 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 25 Jul 2019 11:44:43 +0300 Message-ID: <156404428377.18669.15476429889039912070.stgit@pasha-Precision-3630-Tower> In-Reply-To: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> References: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [for-4.2 PATCH v2 6/8] replay: rename step-related variables and functions 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: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Pavel Dovgalyuk This patch renames replay_get_current_step() and related variables to make these names consistent with existing 'icount' command line option and future record/replay hmp/qmp commands. Signed-off-by: Pavel Dovgalyuk --- include/sysemu/replay.h | 2 +- replay/replay-events.c | 2 +- replay/replay-internal.c | 10 +++++----- replay/replay-internal.h | 10 +++++----- replay/replay-snapshot.c | 6 +++--- replay/replay-time.c | 2 +- replay/replay.c | 22 +++++++++++----------- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/sysemu/replay.h b/include/sysemu/replay.h index 3a7c58e423..28ce19e919 100644 --- a/include/sysemu/replay.h +++ b/include/sysemu/replay.h @@ -75,7 +75,7 @@ void replay_add_blocker(Error *reason); /* Processing the instructions */ =20 /*! Returns number of executed instructions. */ -uint64_t replay_get_current_step(void); +uint64_t replay_get_current_icount(void); /*! Returns number of instructions to execute in replay mode. */ int replay_get_instructions(void); /*! Updates instructions counter in replay mode. */ diff --git a/replay/replay-events.c b/replay/replay-events.c index 60d17f6edb..008e80f636 100644 --- a/replay/replay-events.c +++ b/replay/replay-events.c @@ -124,7 +124,7 @@ void replay_add_event(ReplayAsyncEventKind event_kind, void replay_bh_schedule_event(QEMUBH *bh) { if (events_enabled) { - uint64_t id =3D replay_get_current_step(); + uint64_t id =3D replay_get_current_icount(); replay_add_event(REPLAY_ASYNC_EVENT_BH, bh, NULL, id); } else { qemu_bh_schedule(bh); diff --git a/replay/replay-internal.c b/replay/replay-internal.c index 979f3a0b39..ac6c9017fc 100644 --- a/replay/replay-internal.c +++ b/replay/replay-internal.c @@ -172,7 +172,7 @@ void replay_fetch_data_kind(void) if (!replay_state.has_unread_data) { replay_state.data_kind =3D replay_get_byte(); if (replay_state.data_kind =3D=3D EVENT_INSTRUCTION) { - replay_state.instructions_count =3D replay_get_dword(); + replay_state.instruction_count =3D replay_get_dword(); } replay_check_error(); replay_state.has_unread_data =3D 1; @@ -226,9 +226,9 @@ void replay_mutex_unlock(void) } } =20 -void replay_advance_current_step(uint64_t current_step) +void replay_advance_current_icount(uint64_t current_icount) { - int diff =3D (int)(current_step - replay_state.current_step); + int diff =3D (int)(current_icount - replay_state.current_icount); =20 /* Time can only go forward */ assert(diff >=3D 0); @@ -236,7 +236,7 @@ void replay_advance_current_step(uint64_t current_step) if (diff > 0) { replay_put_event(EVENT_INSTRUCTION); replay_put_dword(diff); - replay_state.current_step +=3D diff; + replay_state.current_icount +=3D diff; } } =20 @@ -245,6 +245,6 @@ void replay_save_instructions(void) { if (replay_file && replay_mode =3D=3D REPLAY_MODE_RECORD) { g_assert(replay_mutex_locked()); - replay_advance_current_step(replay_get_current_step()); + replay_advance_current_icount(replay_get_current_icount()); } } diff --git a/replay/replay-internal.h b/replay/replay-internal.h index af6f4d55d4..afba9a3e0c 100644 --- a/replay/replay-internal.h +++ b/replay/replay-internal.h @@ -64,10 +64,10 @@ typedef enum ReplayAsyncEventKind ReplayAsyncEventKind; typedef struct ReplayState { /*! Cached clock values. */ int64_t cached_clock[REPLAY_CLOCK_COUNT]; - /*! Current step - number of processed instructions and timer events. = */ - uint64_t current_step; + /*! Current icount - number of processed instructions. */ + uint64_t current_icount; /*! Number of instructions to be executed before other events happen. = */ - int instructions_count; + int instruction_count; /*! Type of the currently executed event. */ unsigned int data_kind; /*! Flag which indicates that event is not processed yet. */ @@ -122,8 +122,8 @@ void replay_finish_event(void); data_kind variable. */ void replay_fetch_data_kind(void); =20 -/*! Advance replay_state.current_step to the specified value. */ -void replay_advance_current_step(uint64_t current_step); +/*! Advance replay_state.current_icount to the specified value. */ +void replay_advance_current_icount(uint64_t current_icount); /*! Saves queued events (like instructions and sound). */ void replay_save_instructions(void); =20 diff --git a/replay/replay-snapshot.c b/replay/replay-snapshot.c index 756f48bc02..97d026af30 100644 --- a/replay/replay-snapshot.c +++ b/replay/replay-snapshot.c @@ -41,7 +41,7 @@ static int replay_post_load(void *opaque, int version_id) } else if (replay_mode =3D=3D REPLAY_MODE_RECORD) { /* This is only useful for loading the initial state. Therefore reset all the counters. */ - state->instructions_count =3D 0; + state->instruction_count =3D 0; state->block_request_id =3D 0; } =20 @@ -56,8 +56,8 @@ static const VMStateDescription vmstate_replay =3D { .post_load =3D replay_post_load, .fields =3D (VMStateField[]) { VMSTATE_INT64_ARRAY(cached_clock, ReplayState, REPLAY_CLOCK_COUNT), - VMSTATE_UINT64(current_step, ReplayState), - VMSTATE_INT32(instructions_count, ReplayState), + VMSTATE_UINT64(current_icount, ReplayState), + VMSTATE_INT32(instruction_count, ReplayState), VMSTATE_UINT32(data_kind, ReplayState), VMSTATE_UINT32(has_unread_data, ReplayState), VMSTATE_UINT64(file_offset, ReplayState), diff --git a/replay/replay-time.c b/replay/replay-time.c index 49c9e5d8b2..43357c9f24 100644 --- a/replay/replay-time.c +++ b/replay/replay-time.c @@ -24,7 +24,7 @@ int64_t replay_save_clock(ReplayClockKind kind, int64_t c= lock, * Due to the caller's locking requirements we get the icount from it * instead of using replay_save_instructions(). */ - replay_advance_current_step(raw_icount); + replay_advance_current_icount(raw_icount); replay_put_event(EVENT_CLOCK + kind); replay_put_qword(clock); =20 diff --git a/replay/replay.c b/replay/replay.c index 8d77a4ca4c..6a62ec3811 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -39,7 +39,7 @@ bool replay_next_event_is(int event) bool res =3D false; =20 /* nothing to skip - not all instructions used */ - if (replay_state.instructions_count !=3D 0) { + if (replay_state.instruction_count !=3D 0) { assert(replay_state.data_kind =3D=3D EVENT_INSTRUCTION); return event =3D=3D EVENT_INSTRUCTION; } @@ -62,7 +62,7 @@ bool replay_next_event_is(int event) return res; } =20 -uint64_t replay_get_current_step(void) +uint64_t replay_get_current_icount(void) { return cpu_get_icount_raw(); } @@ -72,7 +72,7 @@ int replay_get_instructions(void) int res =3D 0; replay_mutex_lock(); if (replay_next_event_is(EVENT_INSTRUCTION)) { - res =3D replay_state.instructions_count; + res =3D replay_state.instruction_count; } replay_mutex_unlock(); return res; @@ -82,16 +82,16 @@ void replay_account_executed_instructions(void) { if (replay_mode =3D=3D REPLAY_MODE_PLAY) { g_assert(replay_mutex_locked()); - if (replay_state.instructions_count > 0) { - int count =3D (int)(replay_get_current_step() - - replay_state.current_step); + if (replay_state.instruction_count > 0) { + int count =3D (int)(replay_get_current_icount() + - replay_state.current_icount); =20 /* Time can only go forward */ assert(count >=3D 0); =20 - replay_state.instructions_count -=3D count; - replay_state.current_step +=3D count; - if (replay_state.instructions_count =3D=3D 0) { + replay_state.instruction_count -=3D count; + replay_state.current_icount +=3D count; + if (replay_state.instruction_count =3D=3D 0) { assert(replay_state.data_kind =3D=3D EVENT_INSTRUCTION); replay_finish_event(); /* Wake up iothread. This is required because @@ -273,8 +273,8 @@ static void replay_enable(const char *fname, int mode) replay_mutex_init(); =20 replay_state.data_kind =3D -1; - replay_state.instructions_count =3D 0; - replay_state.current_step =3D 0; + replay_state.instruction_count =3D 0; + replay_state.current_icount =3D 0; replay_state.has_unread_data =3D 0; =20 /* skip file header for RECORD and check it for PLAY */ From nobody Sun May 19 19:10:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564044393; cv=none; d=zoho.com; s=zohoarc; b=e0pT1GJvsXqG8BLf1AOaCg8KYsC7poOaCdlXZ6PugbqEZKoPAypv1MhdhuqJdvbZMhHzwMRHFduvMX0gFuk2NhR81UEls8LK7bn8IZARii0U6a4MEuibS8NZcuoSWuFoSAG9ghh1gTbFuh1vPwo2nDjBXb8UUFlLv1LY5x2ADHU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564044393; 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:ARC-Authentication-Results; bh=ctIy0/fcnqauCOzNWxkrBUxJpWmArUpudTjHaseJdhg=; b=B8z1ZiTVFcT+De+tZG8Z4Y5LPB3okps8VMeelfX1/sYY1JNsQ3e8y+ZL1q0vTndqIovDaHgo8j3qkQpC3ilRHKUr5gfY3rp4f88MfQtd1c46kyHHjV28dPpWRH/4UlejXxZHDhBkSsMUoupUOGMXxeylYl5Inl4sGC2au+EblsY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1564044393251818.1030787039177; Thu, 25 Jul 2019 01:46:33 -0700 (PDT) Received: from localhost ([::1]:57226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZOS-0006xk-AM for importer@patchew.org; Thu, 25 Jul 2019 04:46:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50247) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZMq-0000kB-0y for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqZMo-0000Ch-PP for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:51 -0400 Received: from mail.ispras.ru ([83.149.199.45]:57068) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hqZMo-0000CT-DY for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:50 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 9717354006B; Thu, 25 Jul 2019 11:44:49 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 25 Jul 2019 11:44:49 +0300 Message-ID: <156404428943.18669.15747009371169578935.stgit@pasha-Precision-3630-Tower> In-Reply-To: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> References: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [for-4.2 PATCH v2 7/8] icount: clean up cpu_can_io at the entry to the block 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: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Pavel Dovgalyuk Most of IO instructions can be executed only at the end of the block in icount mode. Therefore translator can set cpu_can_io flag when translating the last instruction. But when the blocks are chained, then this flag is not reset and may remain set at the beginning of the next block. This patch resets the flag at the entry of any translation block, making I/O operations impossible by default. Signed-off-by: Pavel Dovgalyuk -- v2 changes: - reset can_do_io at the start of every TB (suggested by Paolo Bonzini) --- accel/tcg/cpu-exec.c | 1 - include/exec/gen-icount.h | 38 ++++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 6c85c3ee1e..48272c781b 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -169,7 +169,6 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cp= u, TranslationBlock *itb) } #endif /* DEBUG_DISAS */ =20 - cpu->can_do_io =3D !use_icount; ret =3D tcg_qemu_tb_exec(env, tb_ptr); cpu->can_do_io =3D 1; last_tb =3D (TranslationBlock *)(ret & ~TB_EXIT_MASK); diff --git a/include/exec/gen-icount.h b/include/exec/gen-icount.h index f7669b6841..4004e6c9d0 100644 --- a/include/exec/gen-icount.h +++ b/include/exec/gen-icount.h @@ -7,6 +7,24 @@ =20 static TCGOp *icount_start_insn; =20 +static inline void gen_io_start(void) +{ + TCGv_i32 tmp =3D tcg_const_i32(1); + tcg_gen_st_i32(tmp, cpu_env, + offsetof(ArchCPU, parent_obj.can_do_io) - + offsetof(ArchCPU, env)); + tcg_temp_free_i32(tmp); +} + +static inline void gen_io_end(void) +{ + TCGv_i32 tmp =3D tcg_const_i32(0); + tcg_gen_st_i32(tmp, cpu_env, + offsetof(ArchCPU, parent_obj.can_do_io) - + offsetof(ArchCPU, env)); + tcg_temp_free_i32(tmp); +} + static inline void gen_tb_start(TranslationBlock *tb) { TCGv_i32 count, imm; @@ -40,6 +58,8 @@ static inline void gen_tb_start(TranslationBlock *tb) tcg_gen_st16_i32(count, cpu_env, offsetof(ArchCPU, neg.icount_decr.u16.low) - offsetof(ArchCPU, env)); + /* Disable I/O by default */ + gen_io_end(); } =20 tcg_temp_free_i32(count); @@ -57,22 +77,4 @@ static inline void gen_tb_end(TranslationBlock *tb, int = num_insns) tcg_gen_exit_tb(tb, TB_EXIT_REQUESTED); } =20 -static inline void gen_io_start(void) -{ - TCGv_i32 tmp =3D tcg_const_i32(1); - tcg_gen_st_i32(tmp, cpu_env, - offsetof(ArchCPU, parent_obj.can_do_io) - - offsetof(ArchCPU, env)); - tcg_temp_free_i32(tmp); -} - -static inline void gen_io_end(void) -{ - TCGv_i32 tmp =3D tcg_const_i32(0); - tcg_gen_st_i32(tmp, cpu_env, - offsetof(ArchCPU, parent_obj.can_do_io) - - offsetof(ArchCPU, env)); - tcg_temp_free_i32(tmp); -} - #endif From nobody Sun May 19 19:10:15 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; spf=pass (zoho.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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1564044413; cv=none; d=zoho.com; s=zohoarc; b=TVqBtei/oRwlJSJwM6ZFhfmMVItdcZgkHQFNZFOLl+vOvL4/nBrGJyFaUl9VxKlGdxNOsU6MJrItKYY+ANV7Mw/XPuBEL2Vv9XShG1QukkYeunc/hfZcmI6hzUwQB2DP7HBx8NuktqvnVPCyjFHCy40duNgtNwqcVhN3DuT1ihY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564044413; 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:ARC-Authentication-Results; bh=2GciTFzUBbHa8QiTWBC2X4GLsltzcYQzdDFAaFyPqDU=; b=PF2BDGSxTrddfARNNkJWIGC7/o9+lzWyXDdXB0sg278T2G4Jrpe5Chrmr5kwhSkWc67jY/6f3eTHXYuGgrVFI96dih0pMDilYG0jjNTm7hEJjn41PSs79S5hZ4t77cUhdd5XLQClNWRHxAwOCvvRPwMuLaqMzxh/l+6r18mpY/E= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.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 1564044413401475.1137289926579; Thu, 25 Jul 2019 01:46:53 -0700 (PDT) Received: from localhost ([::1]:57234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZOm-0007sC-68 for importer@patchew.org; Thu, 25 Jul 2019 04:46:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50291) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqZMx-0001IZ-Gz for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:45:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqZMu-0000FO-Np for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:59 -0400 Received: from mail.ispras.ru ([83.149.199.45]:57088) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hqZMu-0000Et-7l for qemu-devel@nongnu.org; Thu, 25 Jul 2019 04:44:56 -0400 Received: from [127.0.1.1] (unknown [85.142.117.226]) by mail.ispras.ru (Postfix) with ESMTPSA id 589C8540081; Thu, 25 Jul 2019 11:44:55 +0300 (MSK) From: Pavel Dovgalyuk To: qemu-devel@nongnu.org Date: Thu, 25 Jul 2019 11:44:55 +0300 Message-ID: <156404429499.18669.13404064982854123855.stgit@pasha-Precision-3630-Tower> In-Reply-To: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> References: <156404424989.18669.12696116045723475173.stgit@pasha-Precision-3630-Tower> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 Subject: [Qemu-devel] [for-4.2 PATCH v2 8/8] icount: remove unnecessary gen_io_end calls 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: kwolf@redhat.com, peter.maydell@linaro.org, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, quintela@redhat.com, ciro.santilli@gmail.com, jasowang@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com, mreitz@redhat.com, alex.bennee@linaro.org, maria.klimushenkova@ispras.ru, mst@redhat.com, kraxel@redhat.com, boost.lists@gmail.com, thomas.dullien@googlemail.com, dovgaluk@ispras.ru, artem.k.pisarenko@gmail.com, dgilbert@redhat.com, rth@twiddle.net Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Prior patch resets can_do_io flag at the TB entry. Therefore there is no need in resetting this flag at the end of the block. This patch removes redundant gen_io_end calls. Signed-off-by: Pavel Dovgalyuk --- accel/tcg/translator.c | 2 +- target/alpha/translate.c | 4 ++-- target/arm/translate-a64.c | 6 ++---- target/arm/translate.c | 10 +++------- target/cris/translate.c | 4 ++-- target/hppa/translate.c | 2 +- target/i386/translate.c | 18 ++++++++--------- target/lm32/translate.c | 12 +++--------- target/microblaze/translate.c | 4 ++-- target/mips/translate.c | 16 +++++----------- target/nios2/translate.c | 4 +--- target/ppc/translate.c | 18 +++++------------ target/ppc/translate_init.inc.c | 4 ++-- target/riscv/insn_trans/trans_rvi.inc.c | 2 +- target/sparc/translate.c | 32 ++++++++++++++++-----------= ---- target/unicore32/translate.c | 2 +- target/xtensa/translate.c | 20 +++++-------------- 17 files changed, 60 insertions(+), 100 deletions(-) diff --git a/accel/tcg/translator.c b/accel/tcg/translator.c index 9226a348a3..5849cd250c 100644 --- a/accel/tcg/translator.c +++ b/accel/tcg/translator.c @@ -90,7 +90,7 @@ void translator_loop(const TranslatorOps *ops, DisasConte= xtBase *db, /* Accept I/O on the last instruction. */ gen_io_start(); ops->translate_insn(db, cpu); - gen_io_end(); + /* No need for gen_io_end at the end of the block */ } else { ops->translate_insn(db, cpu); } diff --git a/target/alpha/translate.c b/target/alpha/translate.c index 2c9cccf6c1..97e7d55b4d 100644 --- a/target/alpha/translate.c +++ b/target/alpha/translate.c @@ -1332,7 +1332,7 @@ static DisasJumpType gen_mfpr(DisasContext *ctx, TCGv= va, int regno) if (use_icount) { gen_io_start(); helper(va); - gen_io_end(); + /* No need for gen_io_end at the end of the block */ return DISAS_PC_STALE; } else { helper(va); @@ -2398,7 +2398,7 @@ static DisasJumpType translate_one(DisasContext *ctx,= uint32_t insn) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(); gen_helper_load_pcc(va, cpu_env); - gen_io_end(); + /* No need for gen_io_end at the end of the block */ ret =3D DISAS_PC_STALE; } else { gen_helper_load_pcc(va, cpu_env); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index d3231477a2..20e4638d5f 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1797,7 +1797,7 @@ static void handle_sys(DisasContext *s, uint32_t insn= , bool isread, =20 if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO))= { /* I/O operations must end the TB here (whether read or write) */ - gen_io_end(); + /* No need for gen_io_end at the end of the block */ s->base.is_jmp =3D DISAS_UPDATE; } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { /* We default to ending the TB on a coprocessor register write, @@ -2104,9 +2104,7 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) =20 gen_helper_exception_return(cpu_env, dst); tcg_temp_free_i64(dst); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ /* Must exit loop to check un-masked IRQs */ s->base.is_jmp =3D DISAS_EXIT; return; diff --git a/target/arm/translate.c b/target/arm/translate.c index 7853462b21..c17e5a8c04 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -3245,9 +3245,7 @@ static void gen_rfe(DisasContext *s, TCGv_i32 pc, TCG= v_i32 cpsr) gen_io_start(); } gen_helper_cpsr_write_eret(cpu_env, cpsr); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ tcg_temp_free_i32(cpsr); /* Must exit loop to check un-masked IRQs */ s->base.is_jmp =3D DISAS_EXIT; @@ -7338,7 +7336,7 @@ static int disas_coproc_insn(DisasContext *s, uint32_= t insn) =20 if ((tb_cflags(s->base.tb) & CF_USE_ICOUNT) && (ri->type & ARM_CP_= IO)) { /* I/O operations must end the TB here (whether read or write)= */ - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_lookup_tb(s); } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { /* We default to ending the TB on a coprocessor register write, @@ -9207,9 +9205,7 @@ static void disas_arm_insn(DisasContext *s, unsigned = int insn) gen_io_start(); } gen_helper_cpsr_write_eret(cpu_env, tmp); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ tcg_temp_free_i32(tmp); /* Must exit loop to check un-masked IRQs */ s->base.is_jmp =3D DISAS_EXIT; diff --git a/target/cris/translate.c b/target/cris/translate.c index 3429a3b768..eeba534b29 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3225,8 +3225,8 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb, int max_insns) =20 npc =3D dc->pc; =20 - if (tb_cflags(tb) & CF_LAST_IO) - gen_io_end(); + /* No need for gen_io_end at the end of the block */ + /* Force an update if the per-tb cpu state has changed. */ if (dc->is_jmp =3D=3D DISAS_NEXT && (dc->cpustate_changed || !dc->flagx_known diff --git a/target/hppa/translate.c b/target/hppa/translate.c index 188fe688cb..695a1fdfb0 100644 --- a/target/hppa/translate.c +++ b/target/hppa/translate.c @@ -2161,7 +2161,7 @@ static bool trans_mfctl(DisasContext *ctx, arg_mfctl = *a) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(); gen_helper_read_interval_timer(tmp); - gen_io_end(); + /* No need for gen_io_end at the end of the block */ ctx->base.is_jmp =3D DISAS_IAQ_N_STALE; } else { gen_helper_read_interval_timer(tmp); diff --git a/target/i386/translate.c b/target/i386/translate.c index 03150a86e2..b5469142cf 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -5381,7 +5381,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) gen_op_mov_reg_v(s, dflag, rm, s->T0); set_cc_op(s, CC_OP_EFLAGS); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_jmp(s, s->pc - s->cs_base); } break; @@ -6443,7 +6443,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) gen_op_mov_reg_v(s, ot, R_EAX, s->T1); gen_bpt_io(s, s->tmp2_i32, ot); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_jmp(s, s->pc - s->cs_base); } break; @@ -6464,7 +6464,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) gen_helper_out_func(ot, s->tmp2_i32, s->tmp3_i32); gen_bpt_io(s, s->tmp2_i32, ot); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_jmp(s, s->pc - s->cs_base); } break; @@ -6482,7 +6482,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) gen_op_mov_reg_v(s, ot, R_EAX, s->T1); gen_bpt_io(s, s->tmp2_i32, ot); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_jmp(s, s->pc - s->cs_base); } break; @@ -6502,7 +6502,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) gen_helper_out_func(ot, s->tmp2_i32, s->tmp3_i32); gen_bpt_io(s, s->tmp2_i32, ot); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_jmp(s, s->pc - s->cs_base); } break; @@ -7206,7 +7206,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) } gen_helper_rdtsc(cpu_env); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_jmp(s, s->pc - s->cs_base); } break; @@ -7666,7 +7666,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) } gen_helper_rdtscp(cpu_env); if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_jmp(s, s->pc - s->cs_base); } break; @@ -8036,9 +8036,7 @@ static target_ulong disas_insn(DisasContext *s, CPUSt= ate *cpu) gen_op_mov_v_reg(s, ot, s->T0, rm); gen_helper_write_crN(cpu_env, tcg_const_i32(reg), s->T0); - if (tb_cflags(s->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ gen_jmp_im(s, s->pc - s->cs_base); gen_eob(s); } else { diff --git a/target/lm32/translate.c b/target/lm32/translate.c index b9f2f2c4a7..d844177ced 100644 --- a/target/lm32/translate.c +++ b/target/lm32/translate.c @@ -885,9 +885,7 @@ static void dec_wcsr(DisasContext *dc) } gen_helper_wcsr_im(cpu_env, cpu_R[dc->r1]); tcg_gen_movi_tl(cpu_pc, dc->pc + 4); - if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ dc->is_jmp =3D DISAS_UPDATE; break; case CSR_IP: @@ -897,9 +895,7 @@ static void dec_wcsr(DisasContext *dc) } gen_helper_wcsr_ip(cpu_env, cpu_R[dc->r1]); tcg_gen_movi_tl(cpu_pc, dc->pc + 4); - if (tb_cflags(dc->tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ dc->is_jmp =3D DISAS_UPDATE; break; case CSR_ICC: @@ -1111,9 +1107,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb, int max_insns) && (dc->pc - page_start < TARGET_PAGE_SIZE) && num_insns < max_insns); =20 - if (tb_cflags(tb) & CF_LAST_IO) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ =20 if (unlikely(cs->singlestep_enabled)) { if (dc->is_jmp =3D=3D DISAS_NEXT) { diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index 9ce65f3bcf..ac4ee375f2 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1724,8 +1724,8 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb, int max_insns) npc =3D dc->jmp_pc; } =20 - if (tb_cflags(tb) & CF_LAST_IO) - gen_io_end(); + /* No need for gen_io_end at the end of the block */ + /* Force an update if the per-tb cpu state has changed. */ if (dc->is_jmp =3D=3D DISAS_NEXT && (dc->cpustate_changed || org_flags !=3D dc->tb_flags)) { diff --git a/target/mips/translate.c b/target/mips/translate.c index ca628002ae..e6c0ee68b7 100644 --- a/target/mips/translate.c +++ b/target/mips/translate.c @@ -7126,9 +7126,7 @@ static void gen_mfc0(DisasContext *ctx, TCGv arg, int= reg, int sel) gen_io_start(); } gen_helper_mfc0_count(arg, cpu_env); - if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ /* * Break the TB to be able to take timer interrupts immediately * after reading count. DISAS_STOP isn't sufficient, we need to @@ -8293,7 +8291,7 @@ static void gen_mtc0(DisasContext *ctx, TCGv arg, int= reg, int sel) =20 /* For simplicity assume that all writes can cause interrupts. */ if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ /* * DISAS_STOP isn't sufficient, we need to ensure we break out of * translated code to check for pending interrupts. @@ -8604,9 +8602,7 @@ static void gen_dmfc0(DisasContext *ctx, TCGv arg, in= t reg, int sel) gen_io_start(); } gen_helper_mfc0_count(arg, cpu_env); - if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ /* * Break the TB to be able to take timer interrupts immediately * after reading count. DISAS_STOP isn't sufficient, we need to @@ -9745,7 +9741,7 @@ static void gen_dmtc0(DisasContext *ctx, TCGv arg, in= t reg, int sel) =20 /* For simplicity assume that all writes can cause interrupts. */ if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ /* * DISAS_STOP isn't sufficient, we need to ensure we break out of * translated code to check for pending interrupts. @@ -12810,9 +12806,7 @@ static void gen_rdhwr(DisasContext *ctx, int rt, in= t rd, int sel) gen_io_start(); } gen_helper_rdhwr_cc(t0, cpu_env); - if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ gen_store_gpr(t0, rt); /* * Break the TB to be able to take timer interrupts immediately diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 17d8f1877c..9798184468 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -862,9 +862,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlo= ck *tb, int max_insns) !tcg_op_buf_full() && num_insns < max_insns); =20 - if (tb_cflags(tb) & CF_LAST_IO) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ =20 /* Indicate where the next block should start */ switch (dc->is_jmp) { diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 4a5de28036..fce3243f10 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -1860,7 +1860,7 @@ static void gen_darn(DisasContext *ctx) gen_helper_darn64(cpu_gpr[rD(ctx->opcode)]); } if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_stop_exception(ctx); } } @@ -3990,9 +3990,7 @@ static void gen_rfi(DisasContext *ctx) gen_update_cfar(ctx, ctx->base.pc_next - 4); gen_helper_rfi(cpu_env); gen_sync_exception(ctx); - if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ #endif } =20 @@ -4010,9 +4008,7 @@ static void gen_rfid(DisasContext *ctx) gen_update_cfar(ctx, ctx->base.pc_next - 4); gen_helper_rfid(cpu_env); gen_sync_exception(ctx); - if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ #endif } =20 @@ -4388,9 +4384,7 @@ static void gen_mtmsrd(DisasContext *ctx) /* Must stop the translation as machine state (may have) changed */ /* Note that mtmsr is not always defined as context-synchronizing = */ gen_stop_exception(ctx); - if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ } #endif /* !defined(CONFIG_USER_ONLY) */ } @@ -4428,9 +4422,7 @@ static void gen_mtmsr(DisasContext *ctx) tcg_gen_mov_tl(msr, cpu_gpr[rS(ctx->opcode)]); #endif gen_helper_store_msr(cpu_env, msr); - if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ tcg_temp_free(msr); /* Must stop the translation as machine state (may have) changed */ /* Note that mtmsr is not always defined as context-synchronizing = */ diff --git a/target/ppc/translate_init.inc.c b/target/ppc/translate_init.in= c.c index 86fc8f2e31..3e7a55987b 100644 --- a/target/ppc/translate_init.inc.c +++ b/target/ppc/translate_init.inc.c @@ -189,7 +189,7 @@ static void spr_read_decr(DisasContext *ctx, int gprn, = int sprn) } gen_helper_load_decr(cpu_gpr[gprn], cpu_env); if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_stop_exception(ctx); } } @@ -201,7 +201,7 @@ static void spr_write_decr(DisasContext *ctx, int sprn,= int gprn) } gen_helper_store_decr(cpu_env, cpu_gpr[gprn]); if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); + /* No need for gen_io_end at the end of the block */ gen_stop_exception(ctx); } } diff --git a/target/riscv/insn_trans/trans_rvi.inc.c b/target/riscv/insn_tr= ans/trans_rvi.inc.c index ea6473111c..c70cb68ffc 100644 --- a/target/riscv/insn_trans/trans_rvi.inc.c +++ b/target/riscv/insn_trans/trans_rvi.inc.c @@ -511,7 +511,7 @@ static bool trans_fence_i(DisasContext *ctx, arg_fence_= i *a) } while (0) =20 #define RISCV_OP_CSR_POST do {\ - gen_io_end(); \ + /* No need for gen_io_end at the end of the block */ \ gen_set_gpr(a->rd, dest); \ tcg_gen_movi_tl(cpu_pc, ctx->pc_succ_insn); \ exit_tb(ctx); \ diff --git a/target/sparc/translate.c b/target/sparc/translate.c index 091bab53af..f5b83e46f8 100644 --- a/target/sparc/translate.c +++ b/target/sparc/translate.c @@ -4412,10 +4412,10 @@ static void disas_sparc_insn(DisasContext * dc, uns= igned int insn) gen_helper_tick_set_limit(r_tickptr, cpu_tick_cmp= r); tcg_temp_free_ptr(r_tickptr); - if (tb_cflags(dc->base.tb) & - CF_USE_ICOUNT) { - gen_io_end(); - } + /* + * No need for gen_io_end + * at the end of the block + */ /* End TB to handle timer interrupt */ dc->base.is_jmp =3D DISAS_EXIT; } @@ -4440,10 +4440,10 @@ static void disas_sparc_insn(DisasContext * dc, uns= igned int insn) gen_helper_tick_set_count(r_tickptr, cpu_tmp0); tcg_temp_free_ptr(r_tickptr); - if (tb_cflags(dc->base.tb) & - CF_USE_ICOUNT) { - gen_io_end(); - } + /* + * No need for gen_io_end + * at the end of the block + */ /* End TB to handle timer interrupt */ dc->base.is_jmp =3D DISAS_EXIT; } @@ -4468,10 +4468,10 @@ static void disas_sparc_insn(DisasContext * dc, uns= igned int insn) gen_helper_tick_set_limit(r_tickptr, cpu_stick_cm= pr); tcg_temp_free_ptr(r_tickptr); - if (tb_cflags(dc->base.tb) & - CF_USE_ICOUNT) { - gen_io_end(); - } + /* + * No need for gen_io_end + * at the end of the block + */ /* End TB to handle timer interrupt */ dc->base.is_jmp =3D DISAS_EXIT; } @@ -4588,10 +4588,10 @@ static void disas_sparc_insn(DisasContext * dc, uns= igned int insn) gen_helper_tick_set_count(r_tickptr, cpu_tmp0); tcg_temp_free_ptr(r_tickptr); - if (tb_cflags(dc->base.tb) & - CF_USE_ICOUNT) { - gen_io_end(); - } + /* + * No need for gen_io_end + * at the end of the block + */ /* End TB to handle timer interrupt */ dc->base.is_jmp =3D DISAS_EXIT; } diff --git a/target/unicore32/translate.c b/target/unicore32/translate.c index d27451eed3..11e6c2d266 100644 --- a/target/unicore32/translate.c +++ b/target/unicore32/translate.c @@ -1931,7 +1931,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb, int max_insns) code. */ cpu_abort(cs, "IO on conditional branch instruction"); } - gen_io_end(); + /* No need for gen_io_end at the end of the block */ } =20 /* At this stage dc->condjmp will only be set when the skipped diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 6f1da87875..1baf340289 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -540,9 +540,7 @@ static void gen_waiti(DisasContext *dc, uint32_t imm4) gen_io_start(); } gen_helper_waiti(cpu_env, pc, intlevel); - if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ tcg_temp_free(pc); tcg_temp_free(intlevel); } @@ -2216,9 +2214,7 @@ static void translate_rsr_ccount(DisasContext *dc, co= nst OpcodeArg arg[], } gen_helper_update_ccount(cpu_env); tcg_gen_mov_i32(arg[0].out, cpu_SR[par[0]]); - if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ #endif } =20 @@ -2608,9 +2604,7 @@ static void translate_wsr_ccompare(DisasContext *dc, = const OpcodeArg arg[], tcg_gen_mov_i32(cpu_SR[par[0]], arg[0].in); gen_helper_update_ccompare(cpu_env, tmp); tcg_temp_free(tmp); - if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ #endif } =20 @@ -2622,9 +2616,7 @@ static void translate_wsr_ccount(DisasContext *dc, co= nst OpcodeArg arg[], gen_io_start(); } gen_helper_wsr_ccount(cpu_env, arg[0].in); - if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ #endif } =20 @@ -2831,9 +2823,7 @@ static void translate_xsr_ccount(DisasContext *dc, co= nst OpcodeArg arg[], tcg_gen_mov_i32(arg[0].out, tmp); tcg_temp_free(tmp); =20 - if (tb_cflags(dc->base.tb) & CF_USE_ICOUNT) { - gen_io_end(); - } + /* No need for gen_io_end at the end of the block */ #endif } =20