From: Pavel Dovgalyuk <Pavel.Dovgaluk@ispras.ru>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com,
igor.rubinov@gmail.com, alex.bennee@linaro.org,
mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru,
maria.klimushenkova@ispras.ru, pavel.dovgaluk@ispras.ru,
pbonzini@redhat.com, hines@cert.org, fred.konrad@greensocs.com
Subject: [Qemu-devel] [PATCH v16 06/21] replay: introduce icount event
Date: Tue, 04 Aug 2015 11:44:23 +0300 [thread overview]
Message-ID: <20150804084423.7280.2021.stgit@PASHA-ISP> (raw)
In-Reply-To: <20150804084345.7280.75100.stgit@PASHA-ISP>
This patch adds icount event to the replay subsystem. This event corresponds
to execution of several instructions and used to synchronize input events
in the replay phase.
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>
---
replay/replay-internal.c | 24 ++++++++++++++++++++++++
replay/replay-internal.h | 21 +++++++++++++++++++++
replay/replay.c | 34 ++++++++++++++++++++++++++++++++++
replay/replay.h | 7 +++++++
stubs/cpu-get-icount.c | 5 +++++
5 files changed, 91 insertions(+), 0 deletions(-)
diff --git a/replay/replay-internal.c b/replay/replay-internal.c
index b2ee141..ee3db05 100755
--- a/replay/replay-internal.c
+++ b/replay/replay-internal.c
@@ -10,6 +10,7 @@
*/
#include "qemu-common.h"
+#include "replay.h"
#include "replay-internal.h"
#include "qemu/error-report.h"
#include "sysemu/sysemu.h"
@@ -36,6 +37,7 @@ void replay_put_byte(uint8_t byte)
void replay_put_event(uint8_t event)
{
+ assert(event < EVENT_COUNT);
replay_put_byte(event);
}
@@ -149,8 +151,15 @@ void replay_fetch_data_kind(void)
if (replay_file) {
if (!replay_has_unread_data) {
replay_data_kind = replay_get_byte();
+ if (replay_data_kind == EVENT_INSTRUCTION) {
+ replay_state.instructions_count = replay_get_dword();
+ }
replay_check_error();
replay_has_unread_data = 1;
+ if (replay_data_kind >= EVENT_COUNT) {
+ error_report("Replay: unknown event kind %d", replay_data_kind);
+ exit(1);
+ }
}
}
}
@@ -180,3 +189,18 @@ void replay_mutex_unlock(void)
{
qemu_mutex_unlock(&lock);
}
+
+/*! Saves cached instructions. */
+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);
+ if (first_cpu != NULL && diff > 0) {
+ replay_put_event(EVENT_INSTRUCTION);
+ replay_put_dword(diff);
+ replay_state.current_step += diff;
+ }
+ replay_mutex_unlock();
+ }
+}
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index 8a0de0d..acae7ac 100755
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -14,6 +14,20 @@
#include <stdio.h>
+enum ReplayEvents {
+ /* for instruction event */
+ EVENT_INSTRUCTION,
+ EVENT_COUNT
+};
+
+typedef struct ReplayState {
+ /*! Current step - number of processed instructions and timer events. */
+ uint64_t current_step;
+ /*! Number of instructions to be executed before other events happen. */
+ int instructions_count;
+} ReplayState;
+extern ReplayState replay_state;
+
extern unsigned int replay_data_kind;
/* File for replay writing */
@@ -50,4 +64,11 @@ void replay_finish_event(void);
replay_data_kind variable. */
void replay_fetch_data_kind(void);
+/*! Saves queued events (like instructions and sound). */
+void replay_save_instructions(void);
+
+/*! Skips async events until some sync event will be found.
+ \return true, if event was found */
+bool replay_next_event_is(int event);
+
#endif
diff --git a/replay/replay.c b/replay/replay.c
index 5ce066f..43798e1 100755
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -9,6 +9,40 @@
*
*/
+#include "qemu-common.h"
#include "replay.h"
+#include "replay-internal.h"
+#include "qemu/timer.h"
ReplayMode replay_mode = REPLAY_MODE_NONE;
+
+ReplayState replay_state;
+
+bool replay_next_event_is(int event)
+{
+ bool res = false;
+
+ /* nothing to skip - not all instructions used */
+ if (replay_state.instructions_count != 0) {
+ assert(replay_data_kind == EVENT_INSTRUCTION);
+ return event == EVENT_INSTRUCTION;
+ }
+
+ while (true) {
+ replay_fetch_data_kind();
+ if (event == replay_data_kind) {
+ res = true;
+ }
+ switch (replay_data_kind) {
+ default:
+ /* clock, time_t, checkpoint and other events */
+ return res;
+ }
+ }
+ return res;
+}
+
+uint64_t replay_get_current_step(void)
+{
+ return cpu_get_icount_raw();
+}
diff --git a/replay/replay.h b/replay/replay.h
index d6b73c3..a03c748 100755
--- a/replay/replay.h
+++ b/replay/replay.h
@@ -12,8 +12,15 @@
*
*/
+#include <stdbool.h>
+#include <stdint.h>
#include "qapi-types.h"
extern ReplayMode replay_mode;
+/* Processing the instructions */
+
+/*! Returns number of executed instructions. */
+uint64_t replay_get_current_step(void);
+
#endif
diff --git a/stubs/cpu-get-icount.c b/stubs/cpu-get-icount.c
index d685859..20ffe1c 100644
--- a/stubs/cpu-get-icount.c
+++ b/stubs/cpu-get-icount.c
@@ -7,3 +7,8 @@ int64_t cpu_get_icount(void)
{
abort();
}
+
+int64_t cpu_get_icount_raw(void)
+{
+ abort();
+}
next prev parent reply other threads:[~2015-08-04 8:44 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-04 8:43 [Qemu-devel] [PATCH v16 00/21] Deterministic replay core Pavel Dovgalyuk
2015-08-04 8:43 ` [Qemu-devel] [PATCH v16 01/21] i386: partial revert of interrupt poll fix Pavel Dovgalyuk
2015-08-04 8:44 ` [Qemu-devel] [PATCH v16 02/21] replay: global variables and function stubs Pavel Dovgalyuk
2015-08-04 8:44 ` [Qemu-devel] [PATCH v16 03/21] sysemu: system functions for replay Pavel Dovgalyuk
2015-08-04 8:44 ` [Qemu-devel] [PATCH v16 04/21] replay: internal functions for replay log Pavel Dovgalyuk
2015-08-04 8:44 ` [Qemu-devel] [PATCH v16 05/21] replay: introduce mutex to protect the " Pavel Dovgalyuk
2015-08-04 8:44 ` Pavel Dovgalyuk [this message]
2015-08-04 8:44 ` [Qemu-devel] [PATCH v16 07/21] cpu-exec: allow temporary disabling icount Pavel Dovgalyuk
2015-08-04 8:44 ` [Qemu-devel] [PATCH v16 08/21] cpu: replay instructions sequence Pavel Dovgalyuk
2015-08-04 8:44 ` [Qemu-devel] [PATCH v16 09/21] i386: interrupt poll processing Pavel Dovgalyuk
2015-08-04 8:44 ` [Qemu-devel] [PATCH v16 10/21] replay: interrupts and exceptions Pavel Dovgalyuk
2015-08-04 8:44 ` [Qemu-devel] [PATCH v16 11/21] replay: asynchronous events infrastructure Pavel Dovgalyuk
2015-08-04 8:44 ` [Qemu-devel] [PATCH v16 12/21] replay: recording and replaying clock ticks Pavel Dovgalyuk
2015-08-04 8:45 ` [Qemu-devel] [PATCH v16 13/21] replay: shutdown event Pavel Dovgalyuk
2015-08-04 8:45 ` [Qemu-devel] [PATCH v16 14/21] replay: checkpoints Pavel Dovgalyuk
2015-08-04 8:45 ` [Qemu-devel] [PATCH v16 15/21] bottom halves: introduce bh call function Pavel Dovgalyuk
2015-08-04 8:45 ` [Qemu-devel] [PATCH v16 16/21] replay: ptimer Pavel Dovgalyuk
2015-08-04 8:45 ` [Qemu-devel] [PATCH v16 17/21] typedef: add typedef for QemuOpts Pavel Dovgalyuk
2015-08-04 8:45 ` [Qemu-devel] [PATCH v16 18/21] replay: initialization and deinitialization Pavel Dovgalyuk
2015-08-04 8:45 ` [Qemu-devel] [PATCH v16 19/21] replay: replay blockers for devices Pavel Dovgalyuk
2015-08-04 8:45 ` [Qemu-devel] [PATCH v16 20/21] replay: command line options Pavel Dovgalyuk
2015-08-04 8:45 ` [Qemu-devel] [PATCH v16 21/21] replay: recording of the user input Pavel Dovgalyuk
2015-08-15 9:57 ` [Qemu-devel] [PATCH v16 00/21] Deterministic replay core Pavel Dovgalyuk
2015-08-15 10:03 ` Paolo Bonzini
2015-08-17 11:14 ` Paolo Bonzini
2015-08-27 13:04 ` Pavel Dovgaluk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150804084423.7280.2021.stgit@PASHA-ISP \
--to=pavel.dovgaluk@ispras.ru \
--cc=alex.bennee@linaro.org \
--cc=batuzovk@ispras.ru \
--cc=fred.konrad@greensocs.com \
--cc=hines@cert.org \
--cc=igor.rubinov@gmail.com \
--cc=maria.klimushenkova@ispras.ru \
--cc=mark.burton@greensocs.com \
--cc=pbonzini@redhat.com \
--cc=peter.crosthwaite@xilinx.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=real@ispras.ru \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.