From patchwork Wed Sep 6 16:06:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111826 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1140108qge; Wed, 6 Sep 2017 09:23:48 -0700 (PDT) X-Received: by 10.55.36.3 with SMTP id w3mr4168532qkg.284.1504715028223; Wed, 06 Sep 2017 09:23:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504715028; cv=none; d=google.com; s=arc-20160816; b=aMoX5rdCND7wNshbU9SyqZjTJq9nTyvhw94V5BEyDsLUoWu7moyUyQdn01DMEKbTO1 5qg3O65IB9be7PjoqqIlGeNVLew+K116kOJN002y/KR3PvPo/qh7mxrPLkVi0eFeohlY XwuGPgLmUbh7KrVUnIaE8qfBgEDp8/JFaX0sRvEz+TsrHQB8kCGDqb2uSir95qljbqGw Smd1MnoiLYOnVL1W4iRDi+92lQ819QrnF2GKOepE32qUgAnuh0baDuk0td5nHE9YcMPj Id/Iw2+4V0F2DxB4NmP/lu5UCa03NmHAfCOOisyltVTn6ISelnE9YmGuTL2O5CL1T7l7 RXYw== 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 :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=xElHN/zfdPbhnMF3R21WRLSn0KBWPuHQqnySWytQRsM=; b=TmJIKdHwzk5AA9nktFXy3RHtAXWnJmIQoKnrOGg++eEc42b6N5OvXHS6B+ZVKYvXnr K41ONkawjk8LnVIBw86/WsTf5857s9ffVjiaioMNx7JyIk/EmV+zCWwK8p5VDBPhTvrX f8Nf8f5EfBPCRI0trb1Zk0YLXkT9tQKCqdo8pIXSQP2LBn48urqNIT12LgvBDRwYuPwR OzE1loAfI4njvoDiH64NoNZGDkJopdNQXDUY5Y8R5s/O8JU3i/JRr4nD3ALUP15hGo5b VPIXy5h7kF8qw27cZYIOBAH7gD/Q4xxs51GKTsdjV40DUI6Lm71vP3OlnzIUy5vS1+fb cFZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=OEq4M0Y3; 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 w1si211587qtw.531.2017.09.06.09.23.47 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 06 Sep 2017 09:23:48 -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=OEq4M0Y3; 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]:37022 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpd7B-0005oN-LQ for patch@linaro.org; Wed, 06 Sep 2017 12:23:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcqp-0000Pg-3Q for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpcqk-0002jS-Nu for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:51 -0400 Received: from mail-pf0-x22a.google.com ([2607:f8b0:400e:c00::22a]:34784) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpcqk-0002g9-GF for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:46 -0400 Received: by mail-pf0-x22a.google.com with SMTP id m1so13485921pfk.1 for ; Wed, 06 Sep 2017 09:06:46 -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 :mime-version:content-transfer-encoding; bh=xElHN/zfdPbhnMF3R21WRLSn0KBWPuHQqnySWytQRsM=; b=OEq4M0Y3GNXnaooOb9izY3AxbUALVbVgEJP0ZFGWFCTuuLMwDk9nHN3fOERsvB5wic /vF24fUxXYDmF8g9E1plHUrEOWlw+WjkvCpG1DQ4vT8jTK4WRXc9dBIJTyOhOxv6oLLE we4tep2AxCLHWx6biSJErfToFQwHfq8RX3cpc= 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:mime-version:content-transfer-encoding; bh=xElHN/zfdPbhnMF3R21WRLSn0KBWPuHQqnySWytQRsM=; b=IgnHoKkOx5OvV07nT0GZdowwFp9660ctaNSQRiLi1jbATbI6wFbhL4uJj3C1CarYhW IPkb0Tqd7bbOdCxPn0OLaS5mph2xF3ei/GyhWVpLZgg0dVkH/oFbAKXbbmKKTF9l61FX 0KaXBG61xqv7PRL18ccSKBo0ce9yNxJzkBBdxjqoI7jY1eMGI7sslCdJJ29ZBf8DZf5x Ti/bx7bUQR4vbkRFZlBRup4fJ6aPth+BpiYCFDy+nOyjMQW+w196aS0sw2/d7s9OesF0 MNzYcl762r4mEzevCOkMk0tyMHTGCxTYHdePdBioxgAm3p6zbOsPKCzbTU1fYiW3mnoY x+aw== X-Gm-Message-State: AHPjjUhndRIBs4weD45jlcuvHx8t7B5qjTJuRYbAnjcnP1h4EqLr72O7 IoCHNBTJsIkGpVP0NQHS6g== X-Google-Smtp-Source: ADKCNb6sV6V5nGz89otRgPFmobQosMDHBLs2SMUZ9N0B2abvHqpj4/vChMZvxvmQ/YcqvZ7n29g/bg== X-Received: by 10.84.234.197 with SMTP id i5mr8829617plt.184.1504714005315; Wed, 06 Sep 2017 09:06:45 -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.44 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 09:06:44 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Sep 2017 09:06:03 -0700 Message-Id: <20170906160612.22769-24-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> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::22a Subject: [Qemu-devel] [PULL 23/32] target/arm: [tcg, a64] Port to 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: peter.maydell@linaro.org, =?utf-8?q?Llu=C3=ADs_Vilanova?= , Richard Henderson Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Lluís Vilanova Incrementally paves the way towards using the generic instruction translation loop. Reviewed-by: Emilio G. Cota Signed-off-by: Lluís Vilanova Message-Id: <150002510079.22386.10164419868911710218.stgit@frigg.lan> [rth: Adjust for translate_insn interface change.] Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 71 ++++++++++++++++++++++++++++------------------ 1 file changed, 43 insertions(+), 28 deletions(-) -- 2.13.5 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index e94198280d..f959f4469a 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11254,6 +11254,9 @@ static int aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->is_ldex = false; dc->ss_same_el = (arm_debug_target_el(env) == dc->current_el); + dc->next_page_start = + (dc->base.pc_first & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; + init_tmp_a64_array(dc); return max_insns; @@ -11291,12 +11294,43 @@ static bool aarch64_tr_breakpoint_check(DisasContextBase *dcbase, CPUState *cpu, return true; } +static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) +{ + DisasContext *dc = container_of(dcbase, DisasContext, base); + CPUARMState *env = cpu->env_ptr; + + if (dc->ss_active && !dc->pstate_ss) { + /* Singlestep state is Active-pending. + * If we're in this state at the start of a TB then either + * a) we just took an exception to an EL which is being debugged + * and this is the first insn in the exception handler + * b) debug exceptions were masked and we just unmasked them + * without changing EL (eg by clearing PSTATE.D) + * In either case we're going to take a swstep exception in the + * "did not step an insn" case, and so the syndrome ISV and EX + * bits should be zero. + */ + assert(dc->base.num_insns == 1); + gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), + default_exception_el(dc)); + dc->base.is_jmp = DISAS_NORETURN; + } else { + disas_a64_insn(env, dc); + } + + if (dc->base.is_jmp == DISAS_NEXT) { + if (dc->ss_active || dc->pc >= dc->next_page_start) { + dc->base.is_jmp = DISAS_TOO_MANY; + } + } + + dc->base.pc_next = dc->pc; +} + void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs, TranslationBlock *tb) { - CPUARMState *env = cs->env_ptr; DisasContext *dc = container_of(dcbase, DisasContext, base); - target_ulong next_page_start; int max_insns; dc->base.tb = tb; @@ -11306,7 +11340,6 @@ void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs, dc->base.num_insns = 0; dc->base.singlestep_enabled = cs->singlestep_enabled; - next_page_start = (dc->base.pc_first & TARGET_PAGE_MASK) + TARGET_PAGE_SIZE; max_insns = dc->base.tb->cflags & CF_COUNT_MASK; if (max_insns == 0) { max_insns = CF_COUNT_MASK; @@ -11342,42 +11375,24 @@ void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs, gen_io_start(); } - if (dc->ss_active && !dc->pstate_ss) { - /* Singlestep state is Active-pending. - * If we're in this state at the start of a TB then either - * a) we just took an exception to an EL which is being debugged - * and this is the first insn in the exception handler - * b) debug exceptions were masked and we just unmasked them - * without changing EL (eg by clearing PSTATE.D) - * In either case we're going to take a swstep exception in the - * "did not step an insn" case, and so the syndrome ISV and EX - * bits should be zero. - */ - assert(dc->base.num_insns == 1); - gen_exception(EXCP_UDEF, syn_swstep(dc->ss_same_el, 0, 0), - default_exception_el(dc)); - dc->base.is_jmp = DISAS_NORETURN; - break; - } - - disas_a64_insn(env, dc); + aarch64_tr_translate_insn(&dc->base, cs); if (tcg_check_temp_count()) { fprintf(stderr, "TCG temporary leak before "TARGET_FMT_lx"\n", dc->pc); } + if (!dc->base.is_jmp && (tcg_op_buf_full() || cs->singlestep_enabled || + singlestep || dc->base.num_insns >= max_insns)) { + dc->base.is_jmp = DISAS_TOO_MANY; + } + /* 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. */ - } while (!dc->base.is_jmp && !tcg_op_buf_full() && - !cs->singlestep_enabled && - !singlestep && - !dc->ss_active && - dc->pc < next_page_start && - dc->base.num_insns < max_insns); + } while (!dc->base.is_jmp); if (dc->base.tb->cflags & CF_LAST_IO) { gen_io_end();