From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33603) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dEGNt-0007j1-NJ for qemu-devel@nongnu.org; Fri, 26 May 2017 10:38:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dEGNs-0000bU-5M for qemu-devel@nongnu.org; Fri, 26 May 2017 10:38:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39614) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dEGNr-0000Yq-VA for qemu-devel@nongnu.org; Fri, 26 May 2017 10:38:32 -0400 From: Paolo Bonzini Date: Fri, 26 May 2017 16:38:25 +0200 Message-Id: <20170526143826.27780-3-pbonzini@redhat.com> In-Reply-To: <20170526143826.27780-1-pbonzini@redhat.com> References: <20170526143826.27780-1-pbonzini@redhat.com> Subject: [Qemu-devel] [PULL 21/22] i386: fix read/write cr with icount option List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Mihail Abakumov From: Mihail Abakumov Running Windows with icount causes a crash in instruction of write cr. This patch fixes it. Reading and writing cr cause an icount read because there are called cpu_get_apic_tpr and cpu_set_apic_tpr functions. So, there is need gen_io_start()/gen_io_end() calls. Signed-off-by: Mihail Abakumov Message-Id: Signed-off-by: Paolo Bonzini --- target/i386/translate.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/target/i386/translate.c b/target/i386/translate.c index 1d1372fb43..39912f369f 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -7914,14 +7914,26 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, gen_update_cc_op(s); gen_jmp_im(pc_start - s->cs_base); if (b & 2) { + if (s->tb->cflags & CF_USE_ICOUNT) { + gen_io_start(); + } gen_op_mov_v_reg(ot, cpu_T0, rm); gen_helper_write_crN(cpu_env, tcg_const_i32(reg), cpu_T0); + if (s->tb->cflags & CF_USE_ICOUNT) { + gen_io_end(); + } gen_jmp_im(s->pc - s->cs_base); gen_eob(s); } else { + if (s->tb->cflags & CF_USE_ICOUNT) { + gen_io_start(); + } gen_helper_read_crN(cpu_T0, cpu_env, tcg_const_i32(reg)); gen_op_mov_reg_v(ot, rm, cpu_T0); + if (s->tb->cflags & CF_USE_ICOUNT) { + gen_io_end(); + } } break; default: -- 2.13.0