From patchwork Fri Apr 30 01:15:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 429727 Delivered-To: patch@linaro.org Received: by 2002:a02:c901:0:0:0:0:0 with SMTP id t1csp2104292jao; Thu, 29 Apr 2021 18:20:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzDAN7roSUCgoTuuoyoEU+0iwk62d9szWHwPtGrBl488uO3P/D7qT3uFVZlAugqOGnQQQ+ X-Received: by 2002:a02:b788:: with SMTP id f8mr2501816jam.113.1619745623194; Thu, 29 Apr 2021 18:20:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619745623; cv=none; d=google.com; s=arc-20160816; b=AYGr+NsSemS9x8H1RW71ceFUQ98hRng7EBB2BxkeBL67C5UO+LoOBUVxhlPIgY1x7x iKOahOYWDeds4ryOgeoeBdX/lIo2oC2SwsCKoR0rkr/qbKRd1mWBHsb3462aQ5cznaG1 6Ni/VuIx9XG0xc9X0kVHwZrVMUBs4jIcx0gLufcC2jwKa25JGCXaJz7oU4MLJLxbFap/ a5OKP8yxP+7Y17BuKb6BgMSUaEbDKvvl/m2NSSfQm3Uvy8NM2nOMVlLjN0JDyfQJxGV1 lLPgj/qY9AWlF8uxTYNKG1O1AGYd6viwtM9zI8wXTTm0uSXrzT0/Jcx/oYvWurGOfXLt U3HQ== 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=GtzxgNF32jBOW0rDu46zgnrIq+Tr4i7MyBybLCPP5F4=; b=0k47PM3pTvYX3yKOz3bQaX+n5qbZYT3y4ltT5w/bDKtmS9AznbNbHvUuANZwKJTbSr g85fOv/RrT3PFGGjdIye1jBOL3xpr5IGAfJNTnTgd1qEZIBMX4n/wslSov1tEb1phSNV Eq8q5EEPDmsrpLELbuP4RPv4oDL7gDhi7SAnhxlF+X4vMNh8l66o3I2xGJ7qrEMCKR0M w35s8D1C2XlB69pUH5fq08FaMgF7Yk6rhPuDBZAu29+xdmnpdlmRFv4qRfcRc88/8A+V Y0/ozcUYAXvYFh4YLBQ/jioHKZrR7DHNMJAovScefHE+HZVgHUfSezG2O91fIaXJXwdS T/gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=pVeWUI2y; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w25si458239jal.57.2021.04.29.18.20.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 29 Apr 2021 18:20:23 -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=@linaro.org header.s=google header.b=pVeWUI2y; 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"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:44238 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcHpN-0007os-Mo for patch@linaro.org; Thu, 29 Apr 2021 21:20:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34016) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcHlL-00030o-SH for qemu-devel@nongnu.org; Thu, 29 Apr 2021 21:16:12 -0400 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]:54844) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lcHl5-0007XD-8k for qemu-devel@nongnu.org; Thu, 29 Apr 2021 21:16:11 -0400 Received: by mail-pj1-x102a.google.com with SMTP id t13so9516082pji.4 for ; Thu, 29 Apr 2021 18:15:52 -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=GtzxgNF32jBOW0rDu46zgnrIq+Tr4i7MyBybLCPP5F4=; b=pVeWUI2yN7WtPNi2VOm/Oo874xvs4K82CUJ8V7aJbKlWDd2TzXcMSiY8p3iqseb5YB F4358xlolmbHkmEsNPjwRyqXU/OC+Yr5vZHYdYV0YYy1MGJt3MedY5KEuSTyCAxfegG2 MuYB7l55/yHnuWTxVEbzMfNgkclOHwilSLHb0+HfwgRo8LVo7W0L/jv56AhcaXPKpmcl 6okhB0SDfoMLgIit33Hhia/eKojCFKPWpX1cetzazSyYslHU2e2XYguFy9jaEYsBo8fc XS1ed64kH1wE0MK1LmqEqO5iCPWD71gz4EyCD3LuT92TrdEbxv4ai2od/Kqss6NVW0x1 zcKA== 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=GtzxgNF32jBOW0rDu46zgnrIq+Tr4i7MyBybLCPP5F4=; b=fv0GsxRGgVbAiYuFyRRp6//fNCsZM1LUZwa0LqQmguwJZn89Q4Zudb4D4tWys+3WTb 2LD8/DD6JRdeYPTYBwUSCxqdR6DxOBnE35ywYmdtZBxBcpt+1Tmba9BNeGn2VkcvWlgZ 9bb8G2MRJ2GH5ygTtGQaVPVqLqjZv/uE4G2v18EwMHKVDN7CG5brricmF2XJLFl1qAVj 8yI5R4QnYqfmOPhSU5rFaHNKIk028YNkVHDxsgc3IrzSRZiT/sE3SyQAFWrgxmLowtHR SATh2/bVlf6Ce1TpP7LxajgM5PApiHqhdPpx5qqAXUPH1by04N896R0TuZab5qIpJEba 0iqw== X-Gm-Message-State: AOAM533NDGesXBKrIuY8ABgSOdHLZbFcSPOoLMnZPHmy1Naal9SVWJL3 ybkzpXxeOJQnwrBLCH/ghdN7ButqmeRt9w== X-Received: by 2002:a17:90b:b05:: with SMTP id bf5mr2848277pjb.123.1619745351990; Thu, 29 Apr 2021 18:15:51 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id 1sm161277pjx.46.2021.04.29.18.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Apr 2021 18:15:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 11/30] target/ppc: Introduce DISAS_{EXIT, CHAIN}{, _UPDATE} Date: Thu, 29 Apr 2021 18:15:24 -0700 Message-Id: <20210430011543.1017113-12-richard.henderson@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210430011543.1017113-1-richard.henderson@linaro.org> References: <20210430011543.1017113-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102a; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x102a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: f4bug@amsat.org, luis.pires@eldorado.org.br, qemu-ppc@nongnu.org, lagarcia@br.ibm.com, bruno.larsen@eldorado.org.br, matheus.ferst@eldorado.org.br, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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 --- target/ppc/translate.c | 75 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 65 insertions(+), 10 deletions(-) -- 2.25.1 diff --git a/target/ppc/translate.c b/target/ppc/translate.c index b58e2ac8dc..7dbdf3d047 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -183,6 +183,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) { @@ -8080,28 +8085,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(); } }