From patchwork Thu Jul 17 11:04:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 371145 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7B731140177 for ; Thu, 17 Jul 2014 23:46:34 +1000 (EST) Received: from localhost ([::1]:44374 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7m12-0000gX-LY for incoming@patchwork.ozlabs.org; Thu, 17 Jul 2014 09:46:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50238) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7jdB-00066p-Bd for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:13:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X7jd4-0007kk-Ke for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:13:45 -0400 Received: from mail.ispras.ru ([83.149.199.45]:47502) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X7jU6-00056i-DB for qemu-devel@nongnu.org; Thu, 17 Jul 2014 07:04:22 -0400 Received: from [10.10.150.172] (unknown [80.250.189.177]) by mail.ispras.ru (Postfix) with ESMTPSA id 9BFF6540151; Thu, 17 Jul 2014 15:04:21 +0400 (MSK) To: qemu-devel@nongnu.org From: Pavel Dovgalyuk Date: Thu, 17 Jul 2014 15:04:25 +0400 Message-ID: <20140717110425.8352.18733.stgit@PASHA-ISP> In-Reply-To: <20140717110153.8352.80175.stgit@PASHA-ISP> References: <20140717110153.8352.80175.stgit@PASHA-ISP> User-Agent: StGit/0.16 MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 83.149.199.45 X-Mailman-Approved-At: Thu, 17 Jul 2014 09:36:33 -0400 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, fred.konrad@greensocs.com Subject: [Qemu-devel] [RFC PATCH v2 26/49] replay: interrupts and exceptions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- 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 9ebfa83..019ae20 100755 --- a/replay/replay-internal.h +++ b/replay/replay-internal.h @@ -15,6 +15,10 @@ #include #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 8a9826e..41a27a9 100755 --- a/replay/replay.c +++ b/replay/replay.c @@ -159,3 +159,45 @@ uint64_t replay_get_current_step(void) } return replay_state.current_step; } + +bool replay_exception(void) +{ + if (replay_mode == REPLAY_SAVE) { + replay_save_instructions(); + replay_put_event(EVENT_EXCEPTION); + return true; + } else if (replay_mode == REPLAY_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_SAVE) { + replay_save_instructions(); + replay_put_event(EVENT_INTERRUPT); + return true; + } else if (replay_mode == REPLAY_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_PLAY) { + return skip_async_events(EVENT_INTERRUPT); + } + return false; +} diff --git a/replay/replay.h b/replay/replay.h index 1ce7f78..10e6681 100755 --- a/replay/replay.h +++ b/replay/replay.h @@ -45,4 +45,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