From patchwork Wed Sep 6 16:06:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 111815 Delivered-To: patch@linaro.org Received: by 10.140.94.166 with SMTP id g35csp1127400qge; Wed, 6 Sep 2017 09:15:16 -0700 (PDT) X-Received: by 10.200.39.188 with SMTP id w57mr4607988qtw.285.1504714516685; Wed, 06 Sep 2017 09:15:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1504714516; cv=none; d=google.com; s=arc-20160816; b=yJNqU1WmimNxhtiij4svpFj4phQ3C5J7Z8F4g88baPOncwpPLGR+B7XsicKcIflXvr 0/tvJz4+h6L95RNpeRPoSebpF2vs45/I8NvpymXP50xK8YPNpUlyIW9Zo2AHKwb59bnk IJZfnTXJSDiSRJnhIdIR61gWdRjU/75BJ8GECug20YlDPhP5/I0LTVGMHi5biLvjuS85 CmvNRu5Zq0TqbJ6/Ml/3cCW2mb4LeK5PNQ4XBYEmA746RqJHjwnFPJDix93hbjb6qKPf 3Fpiu6wN4mN12AmtglbmTcvf/EFEuOVz3CJiegNUOdjxPsuNa+IZ62y2wvb2iYigosLi K3QA== 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=Kl1r5WRPXIH5biKfH0poWfuspGHN5gu/mN6HurZuXOA=; b=VqDgsfAuMULZdYoeKK8NLP3Sj2PeH5rODw3irA40iLZH0TcKdGibu7X7Y3sOAwZwuD rjIRUJ5osRzDrj5YJ36ja2jIMm+i8spbcOFf6pkjrsXl8Frr/WkkcLnG4mW6x+KFrrPV ktGc3IvPAsscxFMdeuJcNBYL/lduMOI58zwwps2aDzOcqGfwTwMuTOR2w4lC+CvDYnkY qTG7gLx07Pf6d7CfH9K/Ne2ff6fuJvUhtrF/55uPc3ToiP2vJNdnTQkYPE/6OMrjrrt1 AnYj6ADjOfT0BzIYmUscxniVSyoZwRlRBZ1Zl35HCXc+Kz83sArUTNKhgx8BsIt598zA Bicw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=ScF8CEj+; 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 e31si202381qtk.427.2017.09.06.09.15.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 06 Sep 2017 09:15:16 -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=ScF8CEj+; 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]:36988 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcyw-0007E8-69 for patch@linaro.org; Wed, 06 Sep 2017 12:15:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dpcqo-0000PB-M3 for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dpcqn-0002pU-Hn for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:50 -0400 Received: from mail-pg0-x236.google.com ([2607:f8b0:400e:c05::236]:38907) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dpcqn-0002kd-9X for qemu-devel@nongnu.org; Wed, 06 Sep 2017 12:06:49 -0400 Received: by mail-pg0-x236.google.com with SMTP id v66so15892327pgb.5 for ; Wed, 06 Sep 2017 09:06:49 -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=Kl1r5WRPXIH5biKfH0poWfuspGHN5gu/mN6HurZuXOA=; b=ScF8CEj+/7PwoGDDP5512SqRznakWZEUO0qi54V1orAcI63rCTdn/BXwZ+94/vwuqO Ssh7EBDWI5FRxYHYiJEehMonjqWMszQRmFALny8oOeGXucpm8nRfKzUyryrmf9+XPsOC J9A/kni8zKB5nspuGW6OCC635v9Mmsky2AVN4= 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=Kl1r5WRPXIH5biKfH0poWfuspGHN5gu/mN6HurZuXOA=; b=VxzQE7yuhcxLaoB2sq9DtAxkJgSCy2qOwI52bnalCFJCPMhdT1Ba+pEkFQQrSwyag3 gvqgAOHONEboCWJIy3hQgCxbIZtghswtcA0OYPHDNhrNQ3H51l9nnr6aeN/04EZJce6t GyNPtVbTBbGObSpsdHB4QTPLI/r+/MTktlu8D1uqrY84mU0LpwjtoEgoXbVNHJOlNLB1 3Ka0ee8lbZdKIQUJdjx9+YsmspmdrhuOhj134P0He52f0/iUl4ZjqzpsjNUpyCKaFMT5 oEpGL+ZoRM24kZLI5AJ2Wa/PyEAqtcggOuxTjSH6f6bF2123gMuUS+sbqTuYUOSMY9Wj ofEg== X-Gm-Message-State: AHPjjUhgIGsaRvTMY2sEUQ9Jo5StInDe0vATX3LBcIrjKa7PM5HY1cP+ eRU+rPOuZCKvovNS8dEKCw== X-Google-Smtp-Source: ADKCNb4hiHMct9SHgkQ27TgPBx2XSl5IKRiFEJcTNFjZM0QU8I6YNN1rBGfty5c3/Td73qtXE1+3PA== X-Received: by 10.84.211.106 with SMTP id b97mr8799686pli.148.1504714008014; Wed, 06 Sep 2017 09:06:48 -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.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Sep 2017 09:06:46 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 6 Sep 2017 09:06:05 -0700 Message-Id: <20170906160612.22769-26-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:c05::236 Subject: [Qemu-devel] [PULL 25/32] target/arm: [tcg,a64] Port to tb_stop 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 Reviewed-by: Richard Henderson Signed-off-by: Lluís Vilanova Message-Id: <150002558503.22386.1149037590886263349.stgit@frigg.lan> Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 127 ++++++++++++++++++++++++--------------------- 1 file changed, 67 insertions(+), 60 deletions(-) -- 2.13.5 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index f959f4469a..723e86c976 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -11327,6 +11327,72 @@ static void aarch64_tr_translate_insn(DisasContextBase *dcbase, CPUState *cpu) dc->base.pc_next = dc->pc; } +static void aarch64_tr_tb_stop(DisasContextBase *dcbase, CPUState *cpu) +{ + DisasContext *dc = container_of(dcbase, DisasContext, base); + + if (unlikely(dc->base.singlestep_enabled || dc->ss_active)) { + /* Note that this means single stepping WFI doesn't halt the CPU. + * For conditional branch insns this is harmless unreachable code as + * gen_goto_tb() has already handled emitting the debug exception + * (and thus a tb-jump is not possible when singlestepping). + */ + switch (dc->base.is_jmp) { + default: + gen_a64_set_pc_im(dc->pc); + /* fall through */ + case DISAS_JUMP: + if (dc->base.singlestep_enabled) { + gen_exception_internal(EXCP_DEBUG); + } else { + gen_step_complete_exception(dc); + } + break; + case DISAS_NORETURN: + break; + } + } else { + switch (dc->base.is_jmp) { + case DISAS_NEXT: + case DISAS_TOO_MANY: + gen_goto_tb(dc, 1, dc->pc); + break; + default: + case DISAS_UPDATE: + gen_a64_set_pc_im(dc->pc); + /* fall through */ + case DISAS_JUMP: + tcg_gen_lookup_and_goto_ptr(cpu_pc); + break; + case DISAS_EXIT: + tcg_gen_exit_tb(0); + break; + case DISAS_NORETURN: + case DISAS_SWI: + break; + case DISAS_WFE: + gen_a64_set_pc_im(dc->pc); + gen_helper_wfe(cpu_env); + break; + case DISAS_YIELD: + gen_a64_set_pc_im(dc->pc); + gen_helper_yield(cpu_env); + break; + case DISAS_WFI: + /* This is a special case because we don't want to just halt the CPU + * if trying to debug across a WFI. + */ + gen_a64_set_pc_im(dc->pc); + gen_helper_wfi(cpu_env); + /* The helper doesn't necessarily throw an exception, but we + * must go back to the main loop to check for interrupts anyway. + */ + tcg_gen_exit_tb(0); + break; + } + } +} + void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs, TranslationBlock *tb) { @@ -11398,66 +11464,7 @@ void gen_intermediate_code_a64(DisasContextBase *dcbase, CPUState *cs, gen_io_end(); } - if (unlikely(cs->singlestep_enabled || dc->ss_active)) { - /* Note that this means single stepping WFI doesn't halt the CPU. - * For conditional branch insns this is harmless unreachable code as - * gen_goto_tb() has already handled emitting the debug exception - * (and thus a tb-jump is not possible when singlestepping). - */ - switch (dc->base.is_jmp) { - default: - gen_a64_set_pc_im(dc->pc); - /* fall through */ - case DISAS_JUMP: - if (cs->singlestep_enabled) { - gen_exception_internal(EXCP_DEBUG); - } else { - gen_step_complete_exception(dc); - } - break; - case DISAS_NORETURN: - break; - } - } else { - switch (dc->base.is_jmp) { - case DISAS_NEXT: - case DISAS_TOO_MANY: - gen_goto_tb(dc, 1, dc->pc); - break; - case DISAS_JUMP: - tcg_gen_lookup_and_goto_ptr(cpu_pc); - break; - case DISAS_NORETURN: - case DISAS_SWI: - break; - case DISAS_WFE: - gen_a64_set_pc_im(dc->pc); - gen_helper_wfe(cpu_env); - break; - case DISAS_YIELD: - gen_a64_set_pc_im(dc->pc); - gen_helper_yield(cpu_env); - break; - case DISAS_WFI: - /* This is a special case because we don't want to just halt the CPU - * if trying to debug across a WFI. - */ - gen_a64_set_pc_im(dc->pc); - gen_helper_wfi(cpu_env); - /* The helper doesn't necessarily throw an exception, but we - * must go back to the main loop to check for interrupts anyway. - */ - tcg_gen_exit_tb(0); - break; - case DISAS_UPDATE: - gen_a64_set_pc_im(dc->pc); - /* fall through */ - case DISAS_EXIT: - default: - tcg_gen_exit_tb(0); - break; - } - } + aarch64_tr_tb_stop(&dc->base, cs); gen_tb_end(tb, dc->base.num_insns);