Skip to content

Commit

Permalink
target/loongarch: Fix qemu-loongarch64 hang when executing 'll.d $t0,…
Browse files Browse the repository at this point in the history
… $t0, 0'

On gen_ll, if a->imm is zero, make_address_x return src1,
but the load to destination may clobber src1. We use a new
destination to fix this problem.

Fixes: c5af662 (target/loongarch: Extract make_address_i() helper)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Suggested-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Song Gao <gaosong@loongson.cn>
Message-Id: <20240320013955.1561311-1-gaosong@loongson.cn>
(cherry picked from commit 77642f9)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
  • Loading branch information
gaosong-loongson authored and Michael Tokarev committed Mar 22, 2024
1 parent 242370f commit 5b51920
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions target/loongarch/insn_trans/trans_atomic.c.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

static bool gen_ll(DisasContext *ctx, arg_rr_i *a, MemOp mop)
{
TCGv dest = gpr_dst(ctx, a->rd, EXT_NONE);
TCGv t1 = tcg_temp_new();
TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE);
TCGv t0 = make_address_i(ctx, src1, a->imm);

tcg_gen_qemu_ld_i64(dest, t0, ctx->mem_idx, mop);
tcg_gen_qemu_ld_i64(t1, t0, ctx->mem_idx, mop);
tcg_gen_st_tl(t0, tcg_env, offsetof(CPULoongArchState, lladdr));
tcg_gen_st_tl(dest, tcg_env, offsetof(CPULoongArchState, llval));
gen_set_gpr(a->rd, dest, EXT_NONE);
tcg_gen_st_tl(t1, tcg_env, offsetof(CPULoongArchState, llval));
gen_set_gpr(a->rd, t1, EXT_NONE);

return true;
}
Expand Down

0 comments on commit 5b51920

Please sign in to comment.