[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH v3 25/49] replay: interrupts and exceptions
From: |
Pavel Dovgalyuk |
Subject: |
[Qemu-devel] [RFC PATCH v3 25/49] replay: interrupts and exceptions |
Date: |
Thu, 31 Jul 2014 16:55:49 +0400 |
User-agent: |
StGit/0.16 |
This patch includes modifications of common cpu files. All interrupts and
exceptions occured during recording are written into the replay log.
These events allow correct replaying the execution by kicking cpu thread
when one of these events is found in the log.
Signed-off-by: Pavel Dovgalyuk <address@hidden>
---
cpu-exec.c | 14 +++++++++++---
replay/replay-internal.h | 4 ++++
replay/replay.c | 42 ++++++++++++++++++++++++++++++++++++++++++
replay/replay.h | 14 ++++++++++++++
4 files changed, 71 insertions(+), 3 deletions(-)
diff --git a/cpu-exec.c b/cpu-exec.c
index 13c0ec6..fcde7ce 100644
--- a/cpu-exec.c
+++ b/cpu-exec.c
@@ -23,6 +23,7 @@
#include "qemu/atomic.h"
#include "sysemu/qtest.h"
#include "qemu/main-loop.h"
+#include "replay/replay.h"
void cpu_loop_exit(CPUState *cpu)
{
@@ -314,8 +315,14 @@ int cpu_exec(CPUArchState *env)
ret = cpu->exception_index;
break;
#else
- cc->do_interrupt(cpu);
- cpu->exception_index = -1;
+ if (replay_exception()) {
+ cc->do_interrupt(cpu);
+ cpu->exception_index = -1;
+ } else if (!replay_has_interrupt()) {
+ /* give a chance to iothread in replay mode */
+ ret = EXCP_REPLAY;
+ break;
+ }
#endif
}
}
@@ -323,7 +330,8 @@ int cpu_exec(CPUArchState *env)
next_tb = 0; /* force lookup of first TB */
for(;;) {
interrupt_request = cpu->interrupt_request;
- if (unlikely(interrupt_request)) {
+ if (unlikely((interrupt_request & CPU_INTERRUPT_DEBUG)
+ || (interrupt_request && replay_interrupt()))) {
if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) {
/* Mask out external interrupts for this step. */
interrupt_request &= ~CPU_INTERRUPT_SSTEP_MASK;
diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index 6e7d96f..4c8c785 100755
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -15,6 +15,10 @@
#include <stdio.h>
#include "sysemu/sysemu.h"
+/* for software interrupt */
+#define EVENT_INTERRUPT 15
+/* for emulated exceptions */
+#define EVENT_EXCEPTION 23
/* for async events */
#define EVENT_ASYNC 24
/* for instruction event */
diff --git a/replay/replay.c b/replay/replay.c
index 10c67f7..6988994 100755
--- a/replay/replay.c
+++ b/replay/replay.c
@@ -158,3 +158,45 @@ uint64_t replay_get_current_step(void)
}
return replay_state.current_step;
}
+
+bool replay_exception(void)
+{
+ if (replay_mode == REPLAY_MODE_RECORD) {
+ replay_save_instructions();
+ replay_put_event(EVENT_EXCEPTION);
+ return true;
+ } else if (replay_mode == REPLAY_MODE_PLAY) {
+ if (skip_async_events(EVENT_EXCEPTION)) {
+ replay_has_unread_data = 0;
+ return true;
+ }
+ return false;
+ }
+
+ return true;
+}
+
+bool replay_interrupt(void)
+{
+ if (replay_mode == REPLAY_MODE_RECORD) {
+ replay_save_instructions();
+ replay_put_event(EVENT_INTERRUPT);
+ return true;
+ } else if (replay_mode == REPLAY_MODE_PLAY) {
+ if (skip_async_events(EVENT_INTERRUPT)) {
+ replay_has_unread_data = 0;
+ return true;
+ }
+ return false;
+ }
+
+ return true;
+}
+
+bool replay_has_interrupt(void)
+{
+ if (replay_mode == REPLAY_MODE_PLAY) {
+ return skip_async_events(EVENT_INTERRUPT);
+ }
+ return false;
+}
diff --git a/replay/replay.h b/replay/replay.h
index b764df7..37edf54 100755
--- a/replay/replay.h
+++ b/replay/replay.h
@@ -35,4 +35,18 @@ bool replay_has_async_request(void);
/*! Returns non-zero if next event is instruction. */
bool replay_has_instruction(void);
+/* Interrupts and exceptions */
+
+/*! Called by exception handler to write or read
+ exception processing events. */
+bool replay_exception(void);
+/*! Called by interrupt handlers to write or read
+ interrupt processing events.
+ \return true if interrupt should be processed */
+bool replay_interrupt(void);
+/*! Tries to read interrupt event from the file.
+ Returns true, when interrupt request is pending */
+bool replay_has_interrupt(void);
+
+
#endif
- [Qemu-devel] [RFC PATCH v3 15/49] softmmu: fixing usage of cpu_st/ld* from helpers, (continued)
- [Qemu-devel] [RFC PATCH v3 15/49] softmmu: fixing usage of cpu_st/ld* from helpers, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 16/49] target-i386: update fp status fix, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 17/49] migration: add vmstate for int8 and char arrays, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 18/49] replay: global variables and function stubs, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 19/49] block: add suffix parameter to bdrv_open functions, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 20/49] sysemu: system functions for replay, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 21/49] replay: internal functions for replay log, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 22/49] cpu: invent instruction count for accurate replay, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 23/49] target-arm: instructions counting code for replay, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 24/49] target-i386: instructions counting code for replay, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 25/49] replay: interrupts and exceptions,
Pavel Dovgalyuk <=
- [Qemu-devel] [RFC PATCH v3 26/49] vga: do not use virtual clock for blinking cursor, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 27/49] replay: asynchronous events infrastructure, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 28/49] replay: recording and replaying clock ticks, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 29/49] replay: recording and replaying different timers, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 30/49] replay: shutdown event, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 31/49] replay: checkpoints, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 32/49] vmclock: add virtual clock based on replay icount, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 33/49] replay: bottom halves, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 34/49] replay: replay aio requests, Pavel Dovgalyuk, 2014/07/31
- [Qemu-devel] [RFC PATCH v3 35/49] replay: thread pool, Pavel Dovgalyuk, 2014/07/31