From nobody Mon Feb 9 09:34:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1500112998416141.75153270370083; Sat, 15 Jul 2017 03:03:18 -0700 (PDT) Received: from localhost ([::1]:41385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWJuu-000599-4a for importer@patchew.org; Sat, 15 Jul 2017 06:03:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38541) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dWJcG-0004nX-5G for qemu-devel@nongnu.org; Sat, 15 Jul 2017 05:44:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dWJcD-0003eU-EL for qemu-devel@nongnu.org; Sat, 15 Jul 2017 05:43:59 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:34412) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dWJcD-0003dp-6U for qemu-devel@nongnu.org; Sat, 15 Jul 2017 05:43:57 -0400 Received: by mail-pg0-x243.google.com with SMTP id j186so13347641pge.1 for ; Sat, 15 Jul 2017 02:43:57 -0700 (PDT) Received: from bigtime.twiddle.net (rrcs-173-197-98-123.west.biz.rr.com. [173.197.98.123]) by smtp.gmail.com with ESMTPSA id c63sm27368589pfk.79.2017.07.15.02.43.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 15 Jul 2017 02:43:55 -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=hgkRWlHheRzOSQRPPG25gT6IHlZZjWkX4uJCZO9Xo5Q=; b=SGDugFuUKha498hjLcc9TyNv0NIA9q50LCAzyNyEUKRbKC4PJHwVdHXGMYgnbfgJ8I hecztKbqMsnmyi33SRyK9SNy0Qa9GDrXQjfpLzOxNvAKfAyd8rTnmdvpivzrcKZJN/hh nDA4v5gG3iNlGTUqbOon6bO7i3qommkV639iE/aMWOhztqaQSzawjEkwha44Z3yC9sx9 9lKHxe1Zt71TxLKf7UBSnYzHW/WKpp03Zdqk/ALZ1X3PapSUrlPN7vTgyoLTXXjKUXAb fB6oE8cKZdGzkYm++N0ys0n9MlAMya5BcpdJ5SXcUQtVlD27V2fKuSnVJyZSymFtGDWK zU7g== 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=hgkRWlHheRzOSQRPPG25gT6IHlZZjWkX4uJCZO9Xo5Q=; b=mTlgTqbOTw+f78WKc2lNgdieNSFyJIAEDtjUIIVReoCMn+f4KG2GUYk2PSH16fbBjg dWs52XC+crT/1KeVOU8/ydEHDhwxtXTO0DTOFIy7iGzITOJV+2u3hhY79FjluS1KWnOE oNsamOwa3XHfLbk+T5oyDZms123NY+AJcVC49U7Oqp8zyB6PZaDLlF3SirtW1Yr67diI 4FSUYj+VVI6IABnTw3Bqfx/3hsM4gSOttm0KvB0kdTZJZr1QTHtFujHZxDMtyr1e24HS u0vFSxOPFHs8TaQPum044QqkqnVxZm3cK1BSY6OeH9heNOgdAcBKV5y5KekC9fH+Wbs8 3Qyg== X-Gm-Message-State: AIVw1117v5uYgEhtfj0mARpe7DXUk+ZjYtnwgnpQ/7vBdIt9bsxmp7cW DLodSWdK+SCQXTVvkVA= X-Received: by 10.98.201.75 with SMTP id k72mr9308018pfg.99.1500111835963; Sat, 15 Jul 2017 02:43:55 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 14 Jul 2017 23:42:42 -1000 Message-Id: <20170715094243.28371-34-rth@twiddle.net> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20170715094243.28371-1-rth@twiddle.net> References: <20170715094243.28371-1-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v14 33/34] target/arm: Split out thumb_tr_translate_insn 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: pbonzini@redhat.com, cota@braap.org, alex.bennee@linaro.org, vilanova@ac.upc.edu, crosthwaite.peter@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" We need not check for ARM vs Thumb state in order to dispatch disassembly of every instruction. Signed-off-by: Richard Henderson Reviewed-by: Emilio G. Cota --- target/arm/translate.c | 134 +++++++++++++++++++++++++++++++--------------= ---- 1 file changed, 86 insertions(+), 48 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index ebe1c1a..d7c3c10 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -11944,20 +11944,17 @@ static bool arm_tr_breakpoint_check(DisasContextB= ase *dcbase, CPUState *cpu, return true; } =20 -static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) +static bool arm_pre_translate_insn(DisasContext *dc) { - DisasContext *dc =3D container_of(dcbase, DisasContext, base); - CPUARMState *env =3D cpu->env_ptr; - #ifdef CONFIG_USER_ONLY - /* Intercept jump to the magic kernel page. */ - if (dc->pc >=3D 0xffff0000) { - /* We always get here via a jump, so know we are not in a - conditional execution block. */ - gen_exception_internal(EXCP_KERNEL_TRAP); - dc->base.is_jmp =3D DISAS_NORETURN; - return; - } + /* Intercept jump to the magic kernel page. */ + if (dc->pc >=3D 0xffff0000) { + /* We always get here via a jump, so know we are not in a + conditional execution block. */ + gen_exception_internal(EXCP_KERNEL_TRAP); + dc->base.is_jmp =3D DISAS_NORETURN; + return true; + } #endif =20 if (dc->ss_active && !dc->pstate_ss) { @@ -11975,54 +11972,82 @@ static void arm_tr_translate_insn(DisasContextBas= e *dcbase, CPUState *cpu) gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), default_exception_el(dc)); dc->base.is_jmp =3D DISAS_NORETURN; - return; + return true; } =20 - if (dc->thumb) { - disas_thumb_insn(env, dc); - if (dc->condexec_mask) { - dc->condexec_cond =3D (dc->condexec_cond & 0xe) - | ((dc->condexec_mask >> 4) & 1); - dc->condexec_mask =3D (dc->condexec_mask << 1) & 0x1f; - if (dc->condexec_mask =3D=3D 0) { - dc->condexec_cond =3D 0; - } - } - } else { - unsigned int insn =3D arm_ldl_code(env, dc->pc, dc->sctlr_b); - dc->pc +=3D 4; - disas_arm_insn(dc, insn); + return false; +} + +static void arm_post_translate_insn(CPUARMState *env, DisasContext *dc) +{ + /* Translation stops when a conditional branch is encountered. + * Otherwise the subsequent code could get translated several times. + * Also stop translation when a page boundary is reached. This + * ensures prefetch aborts occur at the right place. + * + * We want to stop the TB if the next insn starts in a new page, + * or if it spans between this page and the next. This means that + * if we're looking at the last halfword in the page we need to + * see if it's a 16-bit Thumb insn (which will fit in this TB) + * or a 32-bit Thumb insn (which won't). + * This is to avoid generating a silly TB with a single 16-bit insn + * in it at the end of this page (which would execute correctly + * but isn't very efficient). + */ + if (dc->base.is_jmp =3D=3D DISAS_NEXT + && (dc->pc >=3D dc->next_page_start + || (dc->pc >=3D dc->next_page_start - 3 + && insn_crosses_page(env, dc)))) { + dc->base.is_jmp =3D DISAS_TOO_MANY; } =20 if (dc->condjmp && !dc->base.is_jmp) { gen_set_label(dc->condlabel); dc->condjmp =3D 0; } + dc->base.pc_next =3D dc->pc; + translator_loop_temp_check(&dc->base); +} =20 - if (dc->base.is_jmp =3D=3D DISAS_NEXT) { - /* Translation stops when a conditional branch is encountered. - * Otherwise the subsequent code could get translated several time= s. - * Also stop translation when a page boundary is reached. This - * ensures prefetch aborts occur at the right place. */ - - if (dc->pc >=3D dc->next_page_start || - (dc->pc >=3D dc->next_page_start - 3 && - insn_crosses_page(env, dc))) { - /* We want to stop the TB if the next insn starts in a new pag= e, - * or if it spans between this page and the next. This means t= hat - * if we're looking at the last halfword in the page we need to - * see if it's a 16-bit Thumb insn (which will fit in this TB) - * or a 32-bit Thumb insn (which won't). - * This is to avoid generating a silly TB with a single 16-bit= insn - * in it at the end of this page (which would execute correctly - * but isn't very efficient). - */ - dc->base.is_jmp =3D DISAS_TOO_MANY; +static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) +{ + DisasContext *dc =3D container_of(dcbase, DisasContext, base); + CPUARMState *env =3D cpu->env_ptr; + unsigned int insn; + + if (arm_pre_translate_insn(dc)) { + return; + } + + insn =3D arm_ldl_code(env, dc->pc, dc->sctlr_b); + dc->pc +=3D 4; + disas_arm_insn(dc, insn); + + arm_post_translate_insn(env, dc); +} + +static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cp= u) +{ + DisasContext *dc =3D container_of(dcbase, DisasContext, base); + CPUARMState *env =3D cpu->env_ptr; + + if (arm_pre_translate_insn(dc)) { + return; + } + + disas_thumb_insn(env, dc); + + /* Advance the Thumb condexec condition. */ + if (dc->condexec_mask) { + dc->condexec_cond =3D ((dc->condexec_cond & 0xe) | + ((dc->condexec_mask >> 4) & 1)); + dc->condexec_mask =3D (dc->condexec_mask << 1) & 0x1f; + if (dc->condexec_mask =3D=3D 0) { + dc->condexec_cond =3D 0; } } =20 - dc->base.pc_next =3D dc->pc; - translator_loop_temp_check(&dc->base); + arm_post_translate_insn(env, dc); } =20 static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) @@ -12161,12 +12186,25 @@ static const TranslatorOps arm_translator_ops =3D= { .disas_log =3D arm_tr_disas_log, }; =20 +static const TranslatorOps thumb_translator_ops =3D { + .init_disas_context =3D arm_tr_init_disas_context, + .tb_start =3D arm_tr_tb_start, + .insn_start =3D arm_tr_insn_start, + .breakpoint_check =3D arm_tr_breakpoint_check, + .translate_insn =3D thumb_tr_translate_insn, + .tb_stop =3D arm_tr_tb_stop, + .disas_log =3D arm_tr_disas_log, +}; + /* generate intermediate code for basic block 'tb'. */ void gen_intermediate_code(CPUState *cpu, TranslationBlock *tb) { DisasContext dc; const TranslatorOps *ops =3D &arm_translator_ops; =20 + if (ARM_TBFLAG_THUMB(tb->flags)) { + ops =3D &thumb_translator_ops; + } #ifdef TARGET_AARCH64 if (ARM_TBFLAG_AARCH64_STATE(tb->flags)) { ops =3D &aarch64_translator_ops; --=20 2.9.4