From nobody Tue Feb 10 13:17:38 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 1504715124821156.4402450999977; Wed, 6 Sep 2017 09:25:24 -0700 (PDT) Received: from localhost ([::1]:37032 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpd8l-0007fO-N0 for importer@patchew.org; Wed, 06 Sep 2017 12:25:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcqx-0000aP-Q8 for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:07:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpcqw-0003A3-JE for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:59 -0400 Received: from mail-pg0-x22c.google.com ([2607:f8b0:400e:c05::22c]:37876) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpcqw-00038p-Dg for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:58 -0400 Received: by mail-pg0-x22c.google.com with SMTP id d8so15976971pgt.4 for ; Wed, 06 Sep 2017 09:06:58 -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.55 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 09:06:56 -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=FcT2poeH+q1L1w+cKeuwQSS5u5zh9VSMqgupWpqmAAU=; b=WEZRS3Zj3SvIUobu2mj0kXoOJdlc+XtUNXXRUocuCXCAZJqyVlCBxmwo1khSzT91B4 53Uv8i8fMyhrSlBKr8Ch0VNw97Q8igCw0HmWV45diW+iCNZ5Lm1kUSSith2UrcHnM94y vlW/3hmVWIZyD4UnqXfn/2bZMUgrfVsscsm7M= 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=FcT2poeH+q1L1w+cKeuwQSS5u5zh9VSMqgupWpqmAAU=; b=VSEcTrF3ckPeawb8guAkvWkJo4DU1jJHke5/e9z/wAZ/otOGfN6ocjGMppf4zYVB1q zH7DsazXR8wwggGdxAJQ1Q8uG4d7FNT6CptsOKcH5XNFDdA8hKdPGQ3UG5RfsDh1RBrZ FMIBZ+bUzdclpKra3aT4PyQ9rAfcyAGCTuM+1lbxC3w+woytHuVUzsIxtxKUcL1qdT3B 2qJIYEps1Z48kA7GsfZxM41nlRflcPZBUhZ7L3C1yEXauRkSGWqrjvm7X6EYCZAU29Pd 4h026RIlD3lrHz6Qc5cnO6AexqqCEPR+6ffbVvHK7TIkjTuW182dOLPHkvBTP8e6zfRV gHsg== X-Gm-Message-State: AHPjjUjqVX05vtbDfUZthRAzVqGSRD0LOgT5HAtvM/fsM/gYTzVv8bmZ qnO6/9LxLiJgrtQushslgg== X-Google-Smtp-Source: ADKCNb4cF16fLGKFoJyLYeJ/KvF8lFeCYeDOiMsbgS7lHT6WwCvBxdDZ3LOltSC4GIVcaDAtlUfykg== X-Received: by 10.99.2.208 with SMTP id 199mr8129299pgc.441.1504714017250; Wed, 06 Sep 2017 09:06:57 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Sep 2017 09:06:12 -0700 Message-Id: <20170906160612.22769-33-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:c05::22c Subject: [Qemu-devel] [PULL 32/32] target/arm: Perform per-insn cross-page check only for Thumb 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+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" From: Richard Henderson ARM is a fixed-length ISA and we can compute the page crossing condition exactly once during init_disas_context. Reviewed-by: Emilio G. Cota Signed-off-by: Richard Henderson --- target/arm/translate.c | 58 ++++++++++++++++++++++++++++------------------= ---- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/target/arm/translate.c b/target/arm/translate.c index 9e7bfbcf0c..6946e56a3a 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -11888,6 +11888,13 @@ static int arm_tr_init_disas_context(DisasContextB= ase *dcbase, max_insns =3D 1; } =20 + /* ARM is a fixed-length ISA. Bound the number of insns to execute + to those left on the page. */ + if (!dc->thumb) { + int bound =3D (dc->next_page_start - dc->base.pc_first) / 4; + max_insns =3D MIN(max_insns, bound); + } + cpu_F0s =3D tcg_temp_new_i32(); cpu_F1s =3D tcg_temp_new_i32(); cpu_F0d =3D tcg_temp_new_i64(); @@ -12015,34 +12022,12 @@ static bool arm_pre_translate_insn(DisasContext *= dc) return false; } =20 -static void arm_post_translate_insn(CPUARMState *env, DisasContext *dc) +static void arm_post_translate_insn(DisasContext *dc) { if (dc->condjmp && !dc->base.is_jmp) { gen_set_label(dc->condlabel); dc->condjmp =3D 0; } - - /* 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; - } - dc->base.pc_next =3D dc->pc; translator_loop_temp_check(&dc->base); } @@ -12061,7 +12046,10 @@ static void arm_tr_translate_insn(DisasContextBase= *dcbase, CPUState *cpu) dc->pc +=3D 4; disas_arm_insn(dc, insn); =20 - arm_post_translate_insn(env, dc); + arm_post_translate_insn(dc); + + /* ARM is a fixed-length ISA. We performed the cross-page check + in init_disas_context by adjusting max_insns. */ } =20 static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cp= u) @@ -12085,7 +12073,27 @@ static void thumb_tr_translate_insn(DisasContextBa= se *dcbase, CPUState *cpu) } } =20 - arm_post_translate_insn(env, dc); + arm_post_translate_insn(dc); + + /* Thumb is a variable-length ISA. Stop translation when the next insn + * will touch a new page. This ensures that 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 static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) --=20 2.13.5