From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59317) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCSxt-0002u1-Qv for qemu-devel@nongnu.org; Tue, 07 Jul 2015 09:31:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCSxo-0007jN-CM for qemu-devel@nongnu.org; Tue, 07 Jul 2015 09:31:13 -0400 Received: from mail.ispras.ru ([83.149.199.45]:60895) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCSxo-0007jA-5Y for qemu-devel@nongnu.org; Tue, 07 Jul 2015 09:31:08 -0400 From: Pavel Dovgalyuk Date: Tue, 07 Jul 2015 16:31:09 +0300 Message-ID: <20150707133108.11808.2663.stgit@PASHA-ISP.def.inno> In-Reply-To: <20150707133055.11808.93250.stgit@PASHA-ISP.def.inno> References: <20150707133055.11808.93250.stgit@PASHA-ISP.def.inno> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH v6 02/10] cpu-exec: introduce loop exit with restore function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: rth7680@gmail.com, agraf@suse.de, pavel.dovgaluk@ispras.ru, pbonzini@redhat.com, leon.alrae@imgtec.com, aurelien@aurel32.net This patch introduces loop exit function, which also restores guest CPU state according to the value of host program counter. Reviewed-by: Richard Henderson Reviewed-by: Aurelien Jarno Signed-off-by: Pavel Dovgalyuk --- cpu-exec.c | 9 +++++++++ include/exec/exec-all.h | 1 + 2 files changed, 10 insertions(+), 0 deletions(-) diff --git a/cpu-exec.c b/cpu-exec.c index 2ffeb6e..cad1563 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -133,6 +133,15 @@ void cpu_loop_exit(CPUState *cpu) siglongjmp(cpu->jmp_env, 1); } +void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc) +{ + if (pc) { + cpu_restore_state(cpu, pc); + } + cpu->current_tb = NULL; + siglongjmp(cpu->jmp_env, 1); +} + /* exit the current TB from a signal handler. The host registers are restored in a state compatible with the CPU emulator */ diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 2573e8c..0d038ba 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -90,6 +90,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu, int cflags); void cpu_exec_init(CPUArchState *env); void QEMU_NORETURN cpu_loop_exit(CPUState *cpu); +void QEMU_NORETURN cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc); #if !defined(CONFIG_USER_ONLY) bool qemu_in_vcpu_thread(void);