Received: from eggs.gnu.org ([2001:4830:134:3::10]:50528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAGMG-0003Bs-Fi for qemu-devel@nongnu.org; Tue, 07 Jun 2016 08:43:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAGMC-0008Nk-BD for qemu-devel@nongnu.org; Tue, 07 Jun 2016 08:43:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:49008) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAGMC-0008NV-51 for qemu-devel@nongnu.org; Tue, 07 Jun 2016 08:43:44 -0400 References: <875.280801165168$1465286930@news.gmane.org> <85433aee-e2f1-1b29-ca7e-d2056da39a0d@redhat.com> <002001d1c0b5$2f5e2e50$8e1a8af0$@Poletaev@ispras.ru> From: Paolo Bonzini Message-ID: Date: Tue, 7 Jun 2016 14:43:36 +0200 MIME-Version: 1.0 In-Reply-To: <002001d1c0b5$2f5e2e50$8e1a8af0$@Poletaev@ispras.ru> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] target-i386: fix iret emulation correctness List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: poletaev , qemu-devel@nongnu.org Cc: Pavel.Dovgaluk@ispras.ru On 07/06/2016 14:07, poletaev wrote: >> Second, an IRET with HF_NMI_MASK set can be translated to _only_ the >> reset of NMI mask followed by end of basic block. An IRET without >> HF_NMI_MASK instead can be translated the same way as now. > > I want to make it like this, but it seems to me it can lead to zero tb size > and introduce bad side effect. What I do wrong? > > case 0xcf: /* iret */ > gen_svm_check_intercept(s, pc_start, SVM_EXIT_IRET); > if (!s->pe) { > /* real mode */ > gen_helper_iret_real(cpu_env, tcg_const_i32(dflag - 1)); > set_cc_op(s, CC_OP_EFLAGS); > } else if (s->vm86) { > if (s->iopl != 3) { > if (s->flags & HF_NMI_MASK) { > gen_reset_hflag(s, HF_NMI_MASK); > s->pc = pc_start; > gen_jmp_im(pc_start - s->cs_base); > } else { > gen_exception(s, EXCP0D_GPF, pc_start - s->cs_base); > } > } else { > gen_helper_iret_real(cpu_env, tcg_const_i32(dflag - 1)); > set_cc_op(s, CC_OP_EFLAGS); > } > } else { > gen_helper_iret_protected(cpu_env, tcg_const_i32(dflag - 1), > tcg_const_i32(s->pc - s->cs_base)); > set_cc_op(s, CC_OP_EFLAGS); > } > gen_eob(s); > break; I think it's okay to make it count as a one instruction tb, just like a tb with a "jmp ." instruction. Thanks, Paolo