From patchwork Thu Jul 31 12:55:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Dovgalyuk X-Patchwork-Id: 375269 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 C45EA14012B for ; Thu, 31 Jul 2014 23:06:35 +1000 (EST) Received: from localhost ([::1]:56417 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCq41-00084m-PE for incoming@patchwork.ozlabs.org; Thu, 31 Jul 2014 09:06:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCpth-0007KA-2C for qemu-devel@nongnu.org; Thu, 31 Jul 2014 08:55:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XCpta-0005ob-M1 for qemu-devel@nongnu.org; Thu, 31 Jul 2014 08:55:52 -0400 Received: from mail.ispras.ru ([83.149.199.45]:54733) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XCpta-0005oX-8C for qemu-devel@nongnu.org; Thu, 31 Jul 2014 08:55:46 -0400 Received: from PASHA-ISP.novsu.ac.ru (unknown [80.250.189.177]) by mail.ispras.ru (Postfix) with ESMTPSA id 56E0C540151; Thu, 31 Jul 2014 16:55:45 +0400 (MSK) To: qemu-devel@nongnu.org From: Pavel Dovgalyuk Date: Thu, 31 Jul 2014 16:55:49 +0400 Message-ID: <20140731125548.1600.11780.stgit@PASHA-ISP.novsu.ac.ru> In-Reply-To: <20140731125321.1600.46604.stgit@PASHA-ISP.novsu.ac.ru> References: <20140731125321.1600.46604.stgit@PASHA-ISP.novsu.ac.ru> 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 Cc: peter.maydell@linaro.org, peter.crosthwaite@xilinx.com, mark.burton@greensocs.com, real@ispras.ru, batuzovk@ispras.ru, maria.klimushenkova@ispras.ru, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, afaerber@suse.de, fred.konrad@greensocs.com Subject: [Qemu-devel] [RFC PATCH v3 25/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 6e7d96f..4c8c785 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 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