From nobody Tue Feb 10 11:33:15 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1619745501; cv=none; d=zohomail.com; s=zohoarc; b=LuVkzLdK/REYlFnFCEZOCFMZjxzEHjJqkgG2L00fN7pVh3YLTBJlL0QMvwM47nqkrRFrY8eMn7o28qkPHYqAdoYP/3237Sz0K2ZE9KPm6xhkwpotAzfF93NJN3KcWvTtaoeV49sSVOm+BvvoInQnsdDIGFnpTpY3tFrG2g60dBg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1619745501; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YEM6n015doJzA39th73BDUnIbToLU5l1fS3B+JAxb5o=; b=WZRr7mOycLLiiJbYHmAx+f2TGR8QMZVE9Zxu51I+Yptp8QLUA+arlZOcSBI8D6sMKyp7BGErh82qNjlyi+X3+ix9ImKVTOHhBHBb4d1vozQHyUdtUiQ8jqhRa/q64J73PVdSZxHpAwjYs+0a1tiw25gng8+4v1wejJV7us4x+b0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1619745501774119.27582794117711; Thu, 29 Apr 2021 18:18:21 -0700 (PDT) Received: from localhost ([::1]:38190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lcHnQ-0005PG-LA for importer@patchew.org; Thu, 29 Apr 2021 21:18:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33780) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lcHlC-0002lI-Fj for qemu-devel@nongnu.org; Thu, 29 Apr 2021 21:16:02 -0400 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]:44857) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lcHkz-0007Ul-Jl for qemu-devel@nongnu.org; Thu, 29 Apr 2021 21:16:02 -0400 Received: by mail-pf1-x42e.google.com with SMTP id m11so4195441pfc.11 for ; Thu, 29 Apr 2021 18:15:48 -0700 (PDT) Received: from localhost.localdomain ([71.212.144.24]) by smtp.gmail.com with ESMTPSA id 1sm161277pjx.46.2021.04.29.18.15.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Apr 2021 18:15:47 -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=YEM6n015doJzA39th73BDUnIbToLU5l1fS3B+JAxb5o=; b=aoEClCkNrPFhQ2eNSMcj/QoGU2kQxrQgQ1NecUFg7zCGXXEyuNjQjt6EjTS4hkoCfr u8gRolDMmEfjkcazfrNhkA+TrawN9O+eUISEj65/ozyBJTiJnerahMGWu8EoWHRRH2ix 17dVCnItmW53K9CH3Y32cVvXLR6lRBZgWvEKeqvlhacJ3YMnknUXmNr8kucsQvFrrf3I NCyAOWNi6MHr6ssPjhjRF6Mk9R5RX7IHOOEgkNjptJRRtYvLZhmpAp3G1SL1N4EqcU17 BObrJSwHEHTJ+CfyEmXDqDHUtxwOQzWiFb+dync0CQezx9X0wByMcEUT49iU2cf/KqVK gysQ== 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=YEM6n015doJzA39th73BDUnIbToLU5l1fS3B+JAxb5o=; b=MM4xkPAQC5tIMYm4B731ET7qFWnAE73QswT0t0cML2rk8Fw9TtzcEIB9C54lCOONGN 09srG9Qw58NTUYLGvHeNNmUfblsNtTGM7mOeW96S2SRlPaL888zT52xR0dhbg7JiTeED /NL96yLuvzDt5UCDbKeyRRQ+vKdulPacm0XViBCm2zTf3L8lHbYY58jfOuzW/GaBhLhF jtHHz2BuzvulQJ9d5GQ3KbZOoVvVAjtfbmccJZLDVHCfAHlT7fcvCh42T+AQYZZ4PfDw 02fkYV2+SibJd4s1DemYFHW5pRD85QAY/unT5Muw9XHs+auLD1GbVsh0vB3ItsyInI3q KhTA== X-Gm-Message-State: AOAM533znqt6BO39fx8hntPv3SP62TKi68p6aFv6xFFhakRTMbRpMlmU cE3sAMoobyy9Wn5lOpBKUIH7xyv4N/Y/Rw== X-Google-Smtp-Source: ABdhPJzOxE8X/QM0wpZYsPk3DjUgoWlQ1pWFjqp39uHEnYKWHCj0P6RXJmzz5KhBBgfRIwAUuaIAcw== X-Received: by 2002:a63:ee0f:: with SMTP id e15mr2342220pgi.310.1619745347924; Thu, 29 Apr 2021 18:15:47 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v3 05/30] target/ppc: Add cia field to DisasContext Date: Thu, 29 Apr 2021 18:15:18 -0700 Message-Id: <20210430011543.1017113-6-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::42e; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42e.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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Richard Henderson Reviewed-by: Bruno Larsen (billionai) Reviewed-by: Luis Pires --- target/ppc/translate.c | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/target/ppc/translate.c b/target/ppc/translate.c index 0984ce637b..ee25badba2 100644 --- a/target/ppc/translate.c +++ b/target/ppc/translate.c @@ -154,6 +154,7 @@ void ppc_translate_init(void) /* internal defines */ struct DisasContext { DisasContextBase base; + target_ulong cia; /* current instruction address */ uint32_t opcode; uint32_t exception; /* Routine used to access memory */ @@ -254,7 +255,7 @@ static void gen_exception_err(DisasContext *ctx, uint32= _t excp, uint32_t error) * faulting instruction */ if (ctx->exception =3D=3D POWERPC_EXCP_NONE) { - gen_update_nip(ctx, ctx->base.pc_next - 4); + gen_update_nip(ctx, ctx->cia); } t0 =3D tcg_const_i32(excp); t1 =3D tcg_const_i32(error); @@ -273,7 +274,7 @@ static void gen_exception(DisasContext *ctx, uint32_t e= xcp) * faulting instruction */ if (ctx->exception =3D=3D POWERPC_EXCP_NONE) { - gen_update_nip(ctx, ctx->base.pc_next - 4); + gen_update_nip(ctx, ctx->cia); } t0 =3D tcg_const_i32(excp); gen_helper_raise_exception(cpu_env, t0); @@ -3113,7 +3114,7 @@ static void gen_eieio(DisasContext *ctx) */ if (!(ctx->insns_flags2 & PPC2_ISA300)) { qemu_log_mask(LOG_GUEST_ERROR, "invalid eieio using bit 6 at @" - TARGET_FMT_lx "\n", ctx->base.pc_next - 4); + TARGET_FMT_lx "\n", ctx->cia); } else { bar =3D TCG_MO_ST_LD; } @@ -3782,14 +3783,14 @@ static void gen_b(DisasContext *ctx) li =3D LI(ctx->opcode); li =3D (li ^ 0x02000000) - 0x02000000; if (likely(AA(ctx->opcode) =3D=3D 0)) { - target =3D ctx->base.pc_next + li - 4; + target =3D ctx->cia + li; } else { target =3D li; } if (LK(ctx->opcode)) { gen_setlr(ctx, ctx->base.pc_next); } - gen_update_cfar(ctx, ctx->base.pc_next - 4); + gen_update_cfar(ctx, ctx->cia); gen_goto_tb(ctx, 0, target); } =20 @@ -3888,11 +3889,11 @@ static void gen_bcond(DisasContext *ctx, int type) } tcg_temp_free_i32(temp); } - gen_update_cfar(ctx, ctx->base.pc_next - 4); + gen_update_cfar(ctx, ctx->cia); if (type =3D=3D BCOND_IM) { target_ulong li =3D (target_long)((int16_t)(BD(ctx->opcode))); if (likely(AA(ctx->opcode) =3D=3D 0)) { - gen_goto_tb(ctx, 0, ctx->base.pc_next + li - 4); + gen_goto_tb(ctx, 0, ctx->cia + li); } else { gen_goto_tb(ctx, 0, li); } @@ -4008,7 +4009,7 @@ static void gen_rfi(DisasContext *ctx) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } - gen_update_cfar(ctx, ctx->base.pc_next - 4); + gen_update_cfar(ctx, ctx->cia); gen_helper_rfi(cpu_env); gen_sync_exception(ctx); #endif @@ -4025,7 +4026,7 @@ static void gen_rfid(DisasContext *ctx) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } - gen_update_cfar(ctx, ctx->base.pc_next - 4); + gen_update_cfar(ctx, ctx->cia); gen_helper_rfid(cpu_env); gen_sync_exception(ctx); #endif @@ -4042,7 +4043,7 @@ static void gen_rfscv(DisasContext *ctx) if (tb_cflags(ctx->base.tb) & CF_USE_ICOUNT) { gen_io_start(); } - gen_update_cfar(ctx, ctx->base.pc_next - 4); + gen_update_cfar(ctx, ctx->cia); gen_helper_rfscv(cpu_env); gen_sync_exception(ctx); #endif @@ -4338,7 +4339,7 @@ static inline void gen_op_mfspr(DisasContext *ctx) if (sprn !=3D SPR_PVR) { qemu_log_mask(LOG_GUEST_ERROR, "Trying to read privileged = spr " "%d (0x%03x) at " TARGET_FMT_lx "\n", sprn, = sprn, - ctx->base.pc_next - 4); + ctx->cia); } gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG); } @@ -4352,7 +4353,7 @@ static inline void gen_op_mfspr(DisasContext *ctx) /* Not defined */ qemu_log_mask(LOG_GUEST_ERROR, "Trying to read invalid spr %d (0x%03x) at " - TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - = 4); + TARGET_FMT_lx "\n", sprn, sprn, ctx->cia); =20 /* * The behaviour depends on MSR:PR and SPR# bit 0x10, it can @@ -4516,7 +4517,7 @@ static void gen_mtspr(DisasContext *ctx) /* Privilege exception */ qemu_log_mask(LOG_GUEST_ERROR, "Trying to write privileged spr= " "%d (0x%03x) at " TARGET_FMT_lx "\n", sprn, sprn, - ctx->base.pc_next - 4); + ctx->cia); gen_priv_exception(ctx, POWERPC_EXCP_PRIV_REG); } } else { @@ -4530,7 +4531,7 @@ static void gen_mtspr(DisasContext *ctx) /* Not defined */ qemu_log_mask(LOG_GUEST_ERROR, "Trying to write invalid spr %d (0x%03x) at " - TARGET_FMT_lx "\n", sprn, sprn, ctx->base.pc_next - = 4); + TARGET_FMT_lx "\n", sprn, sprn, ctx->cia); =20 =20 /* @@ -8002,6 +8003,7 @@ static void ppc_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cs) LOG_DISAS("nip=3D" TARGET_FMT_lx " super=3D%d ir=3D%d\n", ctx->base.pc_next, ctx->mem_idx, (int)msr_ir); =20 + ctx->cia =3D ctx->base.pc_next; ctx->opcode =3D translator_ldl_swap(env, ctx->base.pc_next, need_byteswap(ctx)); =20 @@ -8031,7 +8033,7 @@ static void ppc_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cs) TARGET_FMT_lx " %d\n", opc1(ctx->opcode), opc2(ctx->opcode), opc3(ctx->opcode), opc4(ctx->opcode), - ctx->opcode, ctx->base.pc_next - 4, (int)msr_ir); + ctx->opcode, ctx->cia, (int)msr_ir); } else { uint32_t inval; =20 @@ -8048,7 +8050,7 @@ static void ppc_tr_translate_insn(DisasContextBase *d= cbase, CPUState *cs) TARGET_FMT_lx "\n", ctx->opcode & inval, opc1(ctx->opcode), opc2(ctx->opcode), opc3(ctx->opcode), opc4(ctx->opcode), - ctx->opcode, ctx->base.pc_next - 4); + ctx->opcode, ctx->cia); gen_inval_exception(ctx, POWERPC_EXCP_INVAL_INVAL); ctx->base.is_jmp =3D DISAS_NORETURN; return; --=20 2.25.1