From patchwork Wed Sep 6 16:05:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111799 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1113898qge; Wed, 6 Sep 2017 09:06:51 -0700 (PDT) X-Received: by 10.237.60.239 with SMTP id e44mr4452797qtf.310.1504714011406; Wed, 06 Sep 2017 09:06:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504714011; cv=none; d=google.com; s=arc-20160816; b=QCC/pizmlG6mTwdXE9igP3fInCWKdYpXNlAyDC/VxySCs3nBPCBnpD38uuBBOUVHM2 Flz14ZgK3M6N3FE1XbLchEvrIo0k0dudAck97gs4qiUFKn0v7UuXVMT1/r0Q1cl1QTsa 9xt4oitn+BJzn6fdyuSeFPmLrbdCLqjyPGwNcQ6RzGkGya1vrKVugWL/GL0IKLYzNnsm Z4VqJqHndRC5AygznVAevyv7R4/ttkkfAo7RZ6fg/sUd4aqlUJOkEcyuijOJ8pNPeg5i EVhYbkfVCZMsZrMVQdhGfQYX6K2Ht/UpFqh5dq/Z5A48fKN4N2QoQx3YVfCIhULolpB7 gZFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=oktER+wQnBzv+YFYPe9eDSwDzOT9j+VLlJ0DA6KaCfc=; b=Mi+WjglGM2URt8oQLgDu9cyLZf0reQvKyvIQ2j1j3/Bhzu2fPh7awnQ8hmyUxca34Y p3CBfFnP3QCwgFeppwCcmCCGhd/cwCf2o/4ztnUcl4MtFITXBOmbPWeZ+e+P2KCIDECf a+83Jq2OHWjbvYiij6QP9uwQnLUIKXt3LJej0tCSYhYOUj3lPXrfGN35FGq/e3kAJfy6 i2Jt4hK54HkTUi6MROCAyc7pjwf4kt6ejsEOwDkdelTXauMVmFAXIMGaaCK1v/FHYho8 ZtagcboV3/vt3JX+tdY8dqzuGIkhOjePeTEfR+sbLO0dFLUDLA9mF+Io+SaUjYJ5p+ue Dxvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QP4/mR22; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k5si192694qkh.328.2017.09.06.09.06.50 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 06 Sep 2017 09:06:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QP4/mR22; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36958 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcqm-0008NO-MJ for patch@linaro.org; Wed, 06 Sep 2017 12:06:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41542) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcqL-0008MH-5d for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpcqI-0001V2-IS for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:21 -0400 Received: from mail-pf0-x22c.google.com ([2607:f8b0:400e:c00::22c]:34779) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpcqI-0001UB-At for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:18 -0400 Received: by mail-pf0-x22c.google.com with SMTP id m1so13484072pfk.1 for ; Wed, 06 Sep 2017 09:06:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=oktER+wQnBzv+YFYPe9eDSwDzOT9j+VLlJ0DA6KaCfc=; b=QP4/mR22W97tNZeuIsjeUS1wcN5dzNYXiM02/CctYzMSO/pc6R24rnx0DqBLLKCl7J xo9bGZegILi3ytnnim1C2qT0XXzzKOEtsZAB0d3G0USXTFnGO7tnlTRybZcQH0Qa3lUM J8ZDNgb26Yr/yGQagGS1PjnKcFe7JRnoy2u7c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=oktER+wQnBzv+YFYPe9eDSwDzOT9j+VLlJ0DA6KaCfc=; b=dOF9rxo9uwpUsAXJpCB+tFMScme/FIEEbcpLu+HsMHcuv9OA6GiDOIXUoJlZf1tNt0 4wVW8mgEGZXGa+hBxYWOuRBCT248toxFd7Dq2xubUKpteRcnjtPJ2ky5GA1AMGqYVNcF ZvZckUFIZJ6+OBoP4WwTIxqJp8JTXhDEADa5t3Kvp2BzxLiiAbK21VD9vjCusUHbCRPY jNdL6H52w8Q4CmQsFUO697Zy3jTOi0zMbXX3+Wjzgo2cp3oOafKCJXWGVnupS3QpRFy1 O3Daf2AhK1DApHKIJqN2zTmWP2u0A5FPV6xBWygAt4SvlIFZb4bE5dKuCwT2YehNm6ay sVoA== X-Gm-Message-State: AHPjjUhPHeKLDjyOeR8S5QyR9uoCL0MZ1bHVOkCyjwC3phxvQOBNqho8 ghQ6btVXaAJKtbZmJC7vSQ== X-Google-Smtp-Source: ADKCNb5HrxweZeF6botC2mBMtGXtfgFqKHrEz080ysQfRMWWPwkAAVGSZ/NtVMc1XnRr5JIaHXdSWQ== X-Received: by 10.99.126.84 with SMTP id o20mr8271426pgn.137.1504713976979; Wed, 06 Sep 2017 09:06:16 -0700 (PDT) Received: from bigtime.twiddle.net (97-126-108-236.tukw.qwest.net. [97.126.108.236]) by smtp.gmail.com with ESMTPSA id t65sm262863pfk.59.2017.09.06.09.06.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 09:06:16 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Sep 2017 09:05:42 -0700 Message-Id: <20170906160612.22769-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20170906160612.22769-1-richard.henderson@linaro.org> References: <20170906160612.22769-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22c Subject: [Qemu-devel] [PULL 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: peter.maydell@linaro.org, Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson 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(-) -- 2.13.5 diff --git a/target/i386/translate.c b/target/i386/translate.c index 5fdadf98cf..26e8002433 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); @@ -6943,7 +6945,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 */ @@ -7188,7 +7190,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: @@ -7371,7 +7373,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 */