From nobody Thu Apr 25 16:11:04 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685016090777781.0765240126291; Thu, 25 May 2023 05:01:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q29e5-0003pf-HV; Thu, 25 May 2023 08:00:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q29dn-0003n0-4M for qemu-devel@nongnu.org; Thu, 25 May 2023 08:00:25 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q29di-00076n-It for qemu-devel@nongnu.org; Thu, 25 May 2023 08:00:21 -0400 Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8BxGvLGTW9kQPsAAA--.2593S3; Thu, 25 May 2023 20:00:07 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by localhost.localdomain (Coremail) with SMTP id AQAAf8DxD7_GTW9kI2d3AA--.430S2; Thu, 25 May 2023 20:00:06 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: richard.henderson@linaro.org, peter.maydell@linaro.org, philmd@linaro.org, alex.bennee@linaro.org, maobibo@loongson.cn, yangxiaojuan@loongson.cn Subject: [PATCH v2] target/loongarch: Fix the vinsgr2vr/vpickve2gr instructions cause system coredump Date: Thu, 25 May 2023 20:00:05 +0800 Message-Id: <20230525120005.2223413-1-gaosong@loongson.cn> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable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I43ZEXa7xRE6wZ7UUUUU== 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=114.242.206.163; envelope-from=gaosong@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1685016093127100001 Content-Type: text/plain; charset="utf-8" The vinsgr2vr/vpickve2gr instructions need use get_src/get_dst to get gpr registers value, not cpu_gpr[]. The $zero register does not have cpu_gpr[0] allocated. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1662 Signed-off-by: Song Gao Reviewed-by: Richard Henderson --- target/loongarch/insn_trans/trans_lsx.c.inc | 39 ++++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/target/loongarch/insn_trans/trans_lsx.c.inc b/target/loongarch= /insn_trans/trans_lsx.c.inc index 0be2b5a3a8..68779daff6 100644 --- a/target/loongarch/insn_trans/trans_lsx.c.inc +++ b/target/loongarch/insn_trans/trans_lsx.c.inc @@ -3963,106 +3963,119 @@ TRANS(vsetallnez_d, gen_cv, gen_helper_vsetallnez= _d) =20 static bool trans_vinsgr2vr_b(DisasContext *ctx, arg_vr_i *a) { + TCGv src =3D gpr_src(ctx, a->rj, EXT_NONE); CHECK_SXE; - tcg_gen_st8_i64(cpu_gpr[a->rj], cpu_env, + tcg_gen_st8_i64(src, cpu_env, offsetof(CPULoongArchState, fpr[a->vd].vreg.B(a->imm))= ); return true; } =20 static bool trans_vinsgr2vr_h(DisasContext *ctx, arg_vr_i *a) { + TCGv src =3D gpr_src(ctx, a->rj, EXT_NONE); CHECK_SXE; - tcg_gen_st16_i64(cpu_gpr[a->rj], cpu_env, + tcg_gen_st16_i64(src, cpu_env, offsetof(CPULoongArchState, fpr[a->vd].vreg.H(a->imm))= ); return true; } =20 static bool trans_vinsgr2vr_w(DisasContext *ctx, arg_vr_i *a) { + TCGv src =3D gpr_src(ctx, a->rj, EXT_NONE); CHECK_SXE; - tcg_gen_st32_i64(cpu_gpr[a->rj], cpu_env, + tcg_gen_st32_i64(src, cpu_env, offsetof(CPULoongArchState, fpr[a->vd].vreg.W(a->imm)= )); return true; } =20 static bool trans_vinsgr2vr_d(DisasContext *ctx, arg_vr_i *a) { + TCGv src =3D gpr_src(ctx, a->rj, EXT_NONE); CHECK_SXE; - tcg_gen_st_i64(cpu_gpr[a->rj], cpu_env, + tcg_gen_st_i64(src, cpu_env, offsetof(CPULoongArchState, fpr[a->vd].vreg.D(a->imm))); return true; } =20 static bool trans_vpickve2gr_b(DisasContext *ctx, arg_rv_i *a) { + TCGv dst =3D gpr_dst(ctx, a->rd, EXT_NONE); CHECK_SXE; - tcg_gen_ld8s_i64(cpu_gpr[a->rd], cpu_env, + tcg_gen_ld8s_i64(dst, cpu_env, offsetof(CPULoongArchState, fpr[a->vj].vreg.B(a->imm)= )); return true; } =20 static bool trans_vpickve2gr_h(DisasContext *ctx, arg_rv_i *a) { + TCGv dst =3D gpr_dst(ctx, a->rd, EXT_NONE); CHECK_SXE; - tcg_gen_ld16s_i64(cpu_gpr[a->rd], cpu_env, + tcg_gen_ld16s_i64(dst, cpu_env, offsetof(CPULoongArchState, fpr[a->vj].vreg.H(a->imm= ))); return true; } =20 static bool trans_vpickve2gr_w(DisasContext *ctx, arg_rv_i *a) { + TCGv dst =3D gpr_dst(ctx, a->rd, EXT_NONE); CHECK_SXE; - tcg_gen_ld32s_i64(cpu_gpr[a->rd], cpu_env, + tcg_gen_ld32s_i64(dst, cpu_env, offsetof(CPULoongArchState, fpr[a->vj].vreg.W(a->imm= ))); return true; } =20 static bool trans_vpickve2gr_d(DisasContext *ctx, arg_rv_i *a) { + TCGv dst =3D gpr_dst(ctx, a->rd, EXT_NONE); CHECK_SXE; - tcg_gen_ld_i64(cpu_gpr[a->rd], cpu_env, + tcg_gen_ld_i64(dst, cpu_env, offsetof(CPULoongArchState, fpr[a->vj].vreg.D(a->imm))); return true; } =20 static bool trans_vpickve2gr_bu(DisasContext *ctx, arg_rv_i *a) { + TCGv dst =3D gpr_dst(ctx, a->rd, EXT_NONE); CHECK_SXE; - tcg_gen_ld8u_i64(cpu_gpr[a->rd], cpu_env, + tcg_gen_ld8u_i64(dst, cpu_env, offsetof(CPULoongArchState, fpr[a->vj].vreg.B(a->imm)= )); return true; } =20 static bool trans_vpickve2gr_hu(DisasContext *ctx, arg_rv_i *a) { + TCGv dst =3D gpr_dst(ctx, a->rd, EXT_NONE); CHECK_SXE; - tcg_gen_ld16u_i64(cpu_gpr[a->rd], cpu_env, + tcg_gen_ld16u_i64(dst, cpu_env, offsetof(CPULoongArchState, fpr[a->vj].vreg.H(a->imm= ))); return true; } =20 static bool trans_vpickve2gr_wu(DisasContext *ctx, arg_rv_i *a) { + TCGv dst =3D gpr_dst(ctx, a->rd, EXT_NONE); CHECK_SXE; - tcg_gen_ld32u_i64(cpu_gpr[a->rd], cpu_env, + tcg_gen_ld32u_i64(dst, cpu_env, offsetof(CPULoongArchState, fpr[a->vj].vreg.W(a->imm= ))); return true; } =20 static bool trans_vpickve2gr_du(DisasContext *ctx, arg_rv_i *a) { + TCGv dst =3D gpr_dst(ctx, a->rd, EXT_NONE); CHECK_SXE; - tcg_gen_ld_i64(cpu_gpr[a->rd], cpu_env, + tcg_gen_ld_i64(dst, cpu_env, offsetof(CPULoongArchState, fpr[a->vj].vreg.D(a->imm))); return true; } =20 static bool gvec_dup(DisasContext *ctx, arg_vr *a, MemOp mop) { + TCGv src =3D gpr_src(ctx, a->rj, EXT_NONE); CHECK_SXE; =20 tcg_gen_gvec_dup_i64(mop, vec_full_offset(a->vd), - 16, ctx->vl/8, cpu_gpr[a->rj]); + 16, ctx->vl/8, src); return true; } =20 --=20 2.39.1