From patchwork Mon Jul 24 20:26:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 9860365 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CDADC601A1 for ; Mon, 24 Jul 2017 20:29:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFB6128554 for ; Mon, 24 Jul 2017 20:29:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B45A7285BD; Mon, 24 Jul 2017 20:29:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 25DE8285BD for ; Mon, 24 Jul 2017 20:29:51 +0000 (UTC) Received: from localhost ([::1]:56820 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZjyq-0002zR-7X for patchwork-qemu-devel@patchwork.kernel.org; Mon, 24 Jul 2017 16:29:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47784) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZjxW-0002zD-Q0 for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZjxU-0000o0-HK for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:06 -0400 Received: from mail-qk0-x244.google.com ([2607:f8b0:400d:c09::244]:38314) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZjxU-0000ne-D1 for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:04 -0400 Received: by mail-qk0-x244.google.com with SMTP id t2so10964718qkc.5 for ; Mon, 24 Jul 2017 13:28:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=e1zLnPcSL+Y9rFMgvWrzrPQPf34ZcPJgWCo7PZOIVo0=; b=bLgvd1h1XZIlUz8FXnFK7FcRgeS1ixx7sNUzDoAU4kdf/RTy76Nnk3d5+cD8MxM3gi 9aemcGk3ABH4ecBlSqmtdlOh3tg4bFqNk0+3sKOUMc+H3XD9+LTrZMoeJ3Oao9khFRZC 70brOEa4WIFJTnqtZeEmPjBZkeI+nbV5tYE1bdHankSIahff/yiFPnkR6d5oU8/wvqwW RwhN27fmR0tr+LcQFy/bqYvn1h/0Y2aTtz2mQ7zDT6sCp5Ck5rJFkTdaG4vofI4MFmAb 7Gb3VwCFg/wh8KHVVJsnUdrc87K/LM8jEobSArBClVVXX/1ZiJpqmrL79wAZd7465TbE r2Jg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=e1zLnPcSL+Y9rFMgvWrzrPQPf34ZcPJgWCo7PZOIVo0=; b=j/3dyFdWEnrqb8rqbBOk4pGuj0A0gMcpMzCRXqw4Qgw6b1XJaKTbAvBPPxMcJ7/IpN V7QO2DImPCKdsXJtOgoC28WSzJx4uBjzYCpv7DBqns66UQKRxoc9nQaOyCvvT4WT5bqz H9PnnbBXCpwtvzAcjKOVuTLwm5p+v0jptk61D3OlH/EC/tTgVFmznw7x6PIr0lrr4caY L89OfY3gV72uSND/w871XTDTAY66noQK3zDrr2osX4aKixnQ1qNAYA/92DAMQCV/0nlh luQ/jqqLwc2fKTa6fvGMGYLML8zgseyXxqMIq8KheafCIAOGsh3WmPP1X4YjRT5/Yv1f SSjg== X-Gm-Message-State: AIVw111U4nKwj5ri9UsgOoLzFgHIQEk7uEfXouJyX90x+LiTqOnFiY6O UOvIfuZBLRA2DKy548U= X-Received: by 10.233.237.211 with SMTP id c202mr21675863qkg.1.1500928083349; Mon, 24 Jul 2017 13:28:03 -0700 (PDT) Received: from bigtime.com ([71.217.194.233]) by smtp.gmail.com with ESMTPSA id p52sm9196808qtc.74.2017.07.24.13.28.02 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2017 13:28:02 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 24 Jul 2017 13:26:58 -0700 Message-Id: <20170724202728.25960-3-rth@twiddle.net> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170724202728.25960-1-rth@twiddle.net> References: <20170724202728.25960-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c09::244 Subject: [Qemu-devel] [PATCH v15 02/32] target/i386: Use generic DISAS_* enumerators X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cota@braap.org, vilanova@ac.upc.edu Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This target is not sophisticated in its use of cleanups at the end of the translation loop. For the most part, any condition that exits the TB is dealt with by emitting the exiting opcode right then and there. Therefore the only is_jmp indicator that is needed is DISAS_NORETURN. For two stack segment modifying cases, we have not yet exited the TB (therefore DISAS_NORETURN feels wrong), but intend to exit. The caller of gen_movl_seg_T0 currently checks for any non-zero value, therefore DISAS_TOO_MANY seems acceptable for that usage. Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/i386/translate.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/target/i386/translate.c b/target/i386/translate.c index cab9e32f91..3ffbf1bb4e 100644 --- a/target/i386/translate.c +++ b/target/i386/translate.c @@ -31,6 +31,7 @@ #include "trace-tcg.h" #include "exec/log.h" +#define DISAS_TOO_MANY 5 #define PREFIX_REPZ 0x01 #define PREFIX_REPNZ 0x02 @@ -2153,6 +2154,7 @@ static inline void gen_goto_tb(DisasContext *s, int tb_num, target_ulong eip) tcg_gen_goto_tb(tb_num); gen_jmp_im(eip); tcg_gen_exit_tb((uintptr_t)s->tb + tb_num); + s->is_jmp = DISAS_NORETURN; } else { /* jump to another page */ gen_jmp_im(eip); @@ -2173,7 +2175,6 @@ static inline void gen_jcc(DisasContext *s, int b, gen_set_label(l1); gen_goto_tb(s, 1, val); - s->is_jmp = DISAS_TB_JUMP; } else { l1 = gen_new_label(); l2 = gen_new_label(); @@ -2243,12 +2244,14 @@ static void gen_movl_seg_T0(DisasContext *s, int seg_reg) because ss32 may change. For R_SS, translation must always stop as a special handling must be done to disable hardware interrupts for the next instruction */ - if (seg_reg == R_SS || (s->code32 && seg_reg < R_FS)) - s->is_jmp = DISAS_TB_JUMP; + if (seg_reg == R_SS || (s->code32 && seg_reg < R_FS)) { + s->is_jmp = DISAS_TOO_MANY; + } } else { gen_op_movl_seg_T0_vm(seg_reg); - if (seg_reg == R_SS) - s->is_jmp = DISAS_TB_JUMP; + if (seg_reg == R_SS) { + s->is_jmp = DISAS_TOO_MANY; + } } } @@ -2420,7 +2423,7 @@ static void gen_exception(DisasContext *s, int trapno, target_ulong cur_eip) gen_update_cc_op(s); gen_jmp_im(cur_eip); gen_helper_raise_exception(cpu_env, tcg_const_i32(trapno)); - s->is_jmp = DISAS_TB_JUMP; + s->is_jmp = DISAS_NORETURN; } /* Generate #UD for the current instruction. The assumption here is that @@ -2458,7 +2461,7 @@ static void gen_interrupt(DisasContext *s, int intno, gen_jmp_im(cur_eip); gen_helper_raise_interrupt(cpu_env, tcg_const_i32(intno), tcg_const_i32(next_eip - cur_eip)); - s->is_jmp = DISAS_TB_JUMP; + s->is_jmp = DISAS_NORETURN; } static void gen_debug(DisasContext *s, target_ulong cur_eip) @@ -2466,7 +2469,7 @@ static void gen_debug(DisasContext *s, target_ulong cur_eip) gen_update_cc_op(s); gen_jmp_im(cur_eip); gen_helper_debug(cpu_env); - s->is_jmp = DISAS_TB_JUMP; + s->is_jmp = DISAS_NORETURN; } static void gen_set_hflag(DisasContext *s, uint32_t mask) @@ -2541,7 +2544,7 @@ do_gen_eob_worker(DisasContext *s, bool inhibit, bool recheck_tf, TCGv jr) } else { tcg_gen_exit_tb(0); } - s->is_jmp = DISAS_TB_JUMP; + s->is_jmp = DISAS_NORETURN; } static inline void @@ -2580,7 +2583,6 @@ static void gen_jmp_tb(DisasContext *s, target_ulong eip, int tb_num) set_cc_op(s, CC_OP_DYNAMIC); if (s->jmp_opt) { gen_goto_tb(s, tb_num, eip); - s->is_jmp = DISAS_TB_JUMP; } else { gen_jmp_im(eip); gen_eob(s); @@ -6942,7 +6944,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, gen_update_cc_op(s); gen_jmp_im(pc_start - s->cs_base); gen_helper_pause(cpu_env, tcg_const_i32(s->pc - pc_start)); - s->is_jmp = DISAS_TB_JUMP; + s->is_jmp = DISAS_NORETURN; } break; case 0x9b: /* fwait */ @@ -7187,7 +7189,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, gen_update_cc_op(s); gen_jmp_im(pc_start - s->cs_base); gen_helper_hlt(cpu_env, tcg_const_i32(s->pc - pc_start)); - s->is_jmp = DISAS_TB_JUMP; + s->is_jmp = DISAS_NORETURN; } break; case 0x100: @@ -7370,7 +7372,7 @@ static target_ulong disas_insn(CPUX86State *env, DisasContext *s, gen_helper_vmrun(cpu_env, tcg_const_i32(s->aflag - 1), tcg_const_i32(s->pc - pc_start)); tcg_gen_exit_tb(0); - s->is_jmp = DISAS_TB_JUMP; + s->is_jmp = DISAS_NORETURN; break; case 0xd9: /* VMMCALL */