From patchwork Wed May 19 12:51:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gibson X-Patchwork-Id: 442403 Delivered-To: patch@linaro.org Received: by 2002:a02:7a1b:0:0:0:0:0 with SMTP id a27csp1305473jac; Wed, 19 May 2021 06:09:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7ss3c+Gf2fuove4N92qkVcuXs898fjPy5I8N71OhJ85VCN4XbxoIAMt2uiY2qYiIOl+rf X-Received: by 2002:a05:6e02:92a:: with SMTP id o10mr10608884ilt.270.1621429767422; Wed, 19 May 2021 06:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621429767; cv=none; d=google.com; s=arc-20160816; b=aW50UnmFe1SqQ5YpBzw0QdSRultPMT3nSe2GbiWGKUwCzR9a0GyssW74fZEiIRDneB DK/h/S0VzSPFltiwglXr1Rjb+ZLbxr3Zo8I2qWMD+UnP3i2bOOCsGMWud0MKCPmB+8Po 5SgJL3ht7PaWS2LT/f0bR0B/Ap1liwORN4FsVJ8hnDOKVfUp5+0DSgznxu08HddL+3Ks KnW1xs0JSdBxhd09ITr0n3r1RFtxYt1055n941KnPZ9Ou+9swLvPThoZ/LV0ogICp/Xi fmrvtmAqmDeg2zk/X8ciE1GhbWM0aS3BEILwSXwjypSsOFY6Fhc0uRNCRX/iQ0kFmVpX vbqQ== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=QMNfG6lcCChKNmPA2MyN+9YQHocijoh7XX4bP3fhmuU=; b=PfIDk93LD+H1uppPr7fP4DeCMehTeoO+Kuqu5AeD4dyqd8qrgNQxR6lKFF2crN7lai FS+O8vpi0bnK7AMPMAFIZaZVtwU+dEF5I1kohdDAUKKqiY14SywqMs1OeJwGoRvjICNj u9A4kTEhXP9zN8gxLw5+4pTvXppfSDn4GT0eplgZvxNwRe8xzzW1K2ZkNR6E6OQfzL68 vbMYSqk1WMmMKDOhMXH48SdiqJ5HJA231/iTFaU/9yM4LAqx4Bp9lxp0GKlhepRiXYF/ XDQ2Q3fZ7spAx0BBT9ukW29yjEDquT0B1T1+YXrT+Sq/UfB8GhBSlRcpR4Oo6T12F200 tDHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=YDfCL1z1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x2si26394805iom.61.2021.05.19.06.09.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Wed, 19 May 2021 06:09:27 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@gibson.dropbear.id.au header.s=201602 header.b=YDfCL1z1; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org" Received: from localhost ([::1]:44822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ljLx0-0007da-OM for patch@linaro.org; Wed, 19 May 2021 09:09:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33332) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljLgv-00013f-VJ; Wed, 19 May 2021 08:52:49 -0400 Received: from bilbo.ozlabs.org ([203.11.71.1]:41919 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ljLgo-0001Hi-8i; Wed, 19 May 2021 08:52:49 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 4FlXng45kdz9t10; Wed, 19 May 2021 22:52:07 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1621428727; bh=uNWtWZMeGVAzANT243kMUW21wxxT7EYTMKvQONb/t3U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YDfCL1z1YBx7fQ8uZ6GZqDAOSFroN2mbUgHrUg3wJsL9Vlq0WenYKw4psjGDbrKUp RiMeETKPBXYLkdD95/6p2sKtV4ir/s5hWWyfXT2+55gHHv8uV2kVS65Pl6I25Tnu+q 3b/GY45/go3nlz+5DrHvNXi1BJSWvg6xAxmHDsbU= From: David Gibson To: peter.maydell@linaro.org, groug@kaod.org Subject: [PULL 22/48] target/ppc: Introduce DISAS_{EXIT,CHAIN}{,_UPDATE} Date: Wed, 19 May 2021 22:51:22 +1000 Message-Id: <20210519125148.27720-23-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210519125148.27720-1-david@gibson.dropbear.id.au> References: <20210519125148.27720-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Received-SPF: pass client-ip=203.11.71.1; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: richard.henderson@linaro.org, David Gibson , qemu-ppc@nongnu.org, qemu-devel@nongnu.org, Matheus Ferst Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Rewrite ppc_tr_tb_stop to handle these new codes. Convert ctx->exception into these new codes at the end of ppc_tr_translate_insn, prior to pushing the change back throughout translate.c. Signed-off-by: Richard Henderson Signed-off-by: Matheus Ferst Message-Id: <20210512185441.3619828-8-matheus.ferst@eldorado.org.br> Signed-off-by: David Gibson --- target/ppc/translate.c | 75 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 10 deletions(-) -- 2.31.1 diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 5590a93ad5..c879b47dc6 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -185,6 +185,11 @@ struct DisasContext { uint64_t insns_flags2; }; +#define DISAS_EXIT DISAS_TARGET_0 /* exit to main loop, pc updated */ +#define DISAS_EXIT_UPDATE DISAS_TARGET_1 /* exit to main loop, pc stale */ +#define DISAS_CHAIN DISAS_TARGET_2 /* lookup next tb, pc updated */ +#define DISAS_CHAIN_UPDATE DISAS_TARGET_3 /* lookup next tb, pc stale */ + /* Return true iff byteswap is needed in a scalar memop */ static inline bool need_byteswap(const DisasContext *ctx) { @@ -9226,28 +9231,78 @@ static void ppc_tr_translate_insn(DisasContextBase *dcbase, CPUState *cs) opc3(ctx->opcode), opc4(ctx->opcode), ctx->opcode); } - if (ctx->base.is_jmp == DISAS_NEXT - && ctx->exception != POWERPC_EXCP_NONE) { - ctx->base.is_jmp = DISAS_TOO_MANY; + if (ctx->base.is_jmp == DISAS_NEXT) { + switch (ctx->exception) { + case POWERPC_EXCP_NONE: + break; + case POWERPC_EXCP_BRANCH: + ctx->base.is_jmp = DISAS_NORETURN; + break; + case POWERPC_EXCP_SYNC: + case POWERPC_EXCP_STOP: + ctx->base.is_jmp = DISAS_EXIT; + break; + default: + /* Every other ctx->exception should have set NORETURN. */ + g_assert_not_reached(); + } } } static void ppc_tr_tb_stop(DisasContextBase *dcbase, CPUState *cs) { DisasContext *ctx = container_of(dcbase, DisasContext, base); + DisasJumpType is_jmp = ctx->base.is_jmp; + target_ulong nip = ctx->base.pc_next; - if (ctx->base.is_jmp == DISAS_NORETURN) { + if (is_jmp == DISAS_NORETURN) { + /* We have already exited the TB. */ return; } - if (ctx->exception == POWERPC_EXCP_NONE) { - gen_goto_tb(ctx, 0, ctx->base.pc_next); - } else if (ctx->exception != POWERPC_EXCP_BRANCH) { - if (unlikely(ctx->base.singlestep_enabled)) { - gen_debug_exception(ctx); + /* Honor single stepping. */ + if (unlikely(ctx->base.singlestep_enabled)) { + switch (is_jmp) { + case DISAS_TOO_MANY: + case DISAS_EXIT_UPDATE: + case DISAS_CHAIN_UPDATE: + gen_update_nip(ctx, nip); + break; + case DISAS_EXIT: + case DISAS_CHAIN: + break; + default: + g_assert_not_reached(); } - /* Generate the return instruction */ + gen_debug_exception(ctx); + return; + } + + switch (is_jmp) { + case DISAS_TOO_MANY: + if (use_goto_tb(ctx, nip)) { + tcg_gen_goto_tb(0); + gen_update_nip(ctx, nip); + tcg_gen_exit_tb(ctx->base.tb, 0); + break; + } + /* fall through */ + case DISAS_CHAIN_UPDATE: + gen_update_nip(ctx, nip); + /* fall through */ + case DISAS_CHAIN: + tcg_gen_lookup_and_goto_ptr(); + break; + + case DISAS_EXIT_UPDATE: + gen_update_nip(ctx, nip); + /* fall through */ + case DISAS_EXIT: tcg_gen_exit_tb(NULL, 0); + break; + + default: + g_assert_not_reached(); } }