From patchwork Wed Sep 6 16:06:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111827 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1140230qge; Wed, 6 Sep 2017 09:23:53 -0700 (PDT) X-Received: by 10.200.10.12 with SMTP id b12mr4306103qti.152.1504715033411; Wed, 06 Sep 2017 09:23:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504715033; cv=none; d=google.com; s=arc-20160816; b=Y5EKPKU5dX1Y69/im+0XL29XfzI2ttFm6Ruhea6M3DPyp38ICHqorCMy8wFD+ILc+G G+AOlXyi0rb5WY7E5rie8bzBJRVgBLTOJ/5ogY9B+d+2R4zFmrsShpHzzsh9pYQ5NWcr ZW8e6h9S5R98+tZX5vsE6W4IwUfDN0+Sa1SFSCQUmz+VX0venab19WMxsdVAeKUY0JOL 8WYNf1jl+06qLKJ/jFZx4o7aUU1lZSU5nx+U4QVnFXYnVak+ZJcvaQYI0NTk4AAod2bw lFMOR4Ed1k9omKVECX8nlzB/YNU5MHBo7VdCQCCTuR7+y4jROgCtPx6Lo10SeZCWl5ol DLgQ== 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=FcT2poeH+q1L1w+cKeuwQSS5u5zh9VSMqgupWpqmAAU=; b=O/ZF7EVVTXyDtUvMxs7PRtjc7RY8ZkaAc1p/O1HBJ6xFVyTopKoNhDEl3Y6zBFcRH6 u2vh/gZiy38WBx6nAwNg36oGtCg9aebfnQF0e5hPEbeEulhChxcoodwLSR+PT+YN/wIW HLzdtCMsH9P1GwJfWIKWgMQ83mi7CNh89wuw1/qwrbBa4DQcQKegDu/ZkTyuWiKyM2NH kVhyZjXAiTdX9181H2TaXnWNE9hBX34/TATgsNIrNbC3EqoFyXfxGyff1tyjEI1Dbns7 L/+H531MYB0Jj1CGQu89b32LR6lhJv1+UOfbr2c/CdQIiY3fJlb3/oHQ8v3PCn24xvHu vA6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=WEZRS3Zj; 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 f129si244471qke.18.2017.09.06.09.23.52 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 06 Sep 2017 09:23:53 -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=WEZRS3Zj; 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]:37027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpd7H-0006IC-07 for patch@linaro.org; Wed, 06 Sep 2017 12:23:51 -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) 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) 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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.13.5 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(DisasContextBase *dcbase, max_insns = 1; } + /* ARM is a fixed-length ISA. Bound the number of insns to execute + to those left on the page. */ + if (!dc->thumb) { + int bound = (dc->next_page_start - dc->base.pc_first) / 4; + max_insns = MIN(max_insns, bound); + } + cpu_F0s = tcg_temp_new_i32(); cpu_F1s = tcg_temp_new_i32(); cpu_F0d = tcg_temp_new_i64(); @@ -12015,34 +12022,12 @@ static bool arm_pre_translate_insn(DisasContext *dc) return false; } -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 = 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 == DISAS_NEXT - && (dc->pc >= dc->next_page_start - || (dc->pc >= dc->next_page_start - 3 - && insn_crosses_page(env, dc)))) { - dc->base.is_jmp = DISAS_TOO_MANY; - } - dc->base.pc_next = dc->pc; translator_loop_temp_check(&dc->base); } @@ -12061,7 +12046,10 @@ static void arm_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) dc->pc += 4; disas_arm_insn(dc, insn); - 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. */ } static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) @@ -12085,7 +12073,27 @@ static void thumb_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) } } - 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 == DISAS_NEXT + && (dc->pc >= dc->next_page_start + || (dc->pc >= dc->next_page_start - 3 + && insn_crosses_page(env, dc)))) { + dc->base.is_jmp = DISAS_TOO_MANY; + } } static void arm_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu)