From nobody Mon Feb 9 08:56:57 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 1500929886701475.97452095654603; Mon, 24 Jul 2017 13:58:06 -0700 (PDT) Received: from localhost ([::1]:56985 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZkQW-0001pG-AR for importer@patchew.org; Mon, 24 Jul 2017 16:58:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dZjyK-0003pz-VX for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:29:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dZjyJ-0001zy-QK for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:56 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:37037) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dZjyJ-0001zY-LW for qemu-devel@nongnu.org; Mon, 24 Jul 2017 16:28:55 -0400 Received: by mail-qk0-x241.google.com with SMTP id q130so10952104qka.4 for ; Mon, 24 Jul 2017 13:28:55 -0700 (PDT) Received: from bigtime.com ([71.217.194.233]) by smtp.gmail.com with ESMTPSA id p52sm9196808qtc.74.2017.07.24.13.28.53 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Jul 2017 13:28:54 -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=ULGx1hm3vm7hEFGAN/Y+PpUCPind+PI1XZ1/4R7XC0U=; b=MpJhA9G6wsZnlSUafuJvIwgDMBk4h6cN1PHWP3SSgyNUcaPBa1QgnGxP+CsIaYjdMc SqolnlB/LLp7fJwVNOyKZd0FTMQwdyNOsZMpvuVd8UMpoF/arqXguOhofE5BtjTkvC4k y7IK+YLBoVRBIMJi6LlRi6T6omvsYtx0BMdaSoq+kuEgCP6ikE+xP3kCfA3xgGHYC4I4 kxv/9cVzBkt3eyloEvGCCjC7OWlILL/gZitk2wUe+d5X6dknrEGXth/4BmbssHshQS1D S7ajoJDvfa3bJUN8ZN6QnXLBKOsitqcPN10UI14/+QPprRFgBhIR2fZ9IlofPDob0xui rR+g== 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=ULGx1hm3vm7hEFGAN/Y+PpUCPind+PI1XZ1/4R7XC0U=; b=kvgvkRJbpYCS5FZsj0vAynfQM3LhkPhCwAjUC53Z8+rCJ1R5oPvEdhoEqIBOwEk6XL JtNtf8qCrlCdruJgbkQxHmcmzcUnTdc6FkghLVKljEcC8YaomNYr4nIaDuk7ViK+omPa XfdBdIldMQMOQNHCOZD1sSgzOD82vF9aX1Scb3XNm11rQ8N4ZEagOSdHUpdA/z5zVx6y jIjCP1kuMyXBhats0oG28f3LU8SndbJ6gzHXpvha1NPVi3f6UrETM0wi1a0IvGTWOzos inr9eNTCI4c1Mi0ftQglOngvHeLTFzQzwiWv1s3HeKKw9Wp2qY0JjCs5wIJ3E9rRqiFP qfqQ== X-Gm-Message-State: AIVw112ZVVVMDQeEfKrN/f2riiZq3h03rBFThZKG98OLpthqvM/P38Y0 TL5GfZmOeD6lSEy4Els= X-Received: by 10.233.237.211 with SMTP id c202mr21679004qkg.1.1500928134788; Mon, 24 Jul 2017 13:28:54 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 24 Jul 2017 13:27:28 -0700 Message-Id: <20170724202728.25960-33-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::241 Subject: [Qemu-devel] [PATCH v15 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: cota@braap.org, vilanova@ac.upc.edu 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" 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 554b05816b..875c9985d1 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -11858,6 +11858,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(); @@ -11985,34 +11992,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); } @@ -12031,7 +12016,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) @@ -12055,7 +12043,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.3