mailing list of musl libc
 help / color / mirror / code / Atom feed
From: lixing <lixing@loongson.cn>
To: Leah Neukirchen <leah@vuxu.org>
Cc: musl@lists.openwall.com
Subject: Re: [musl] loongarch64 atomics not working?
Date: Fri, 15 Mar 2024 08:58:53 +0800	[thread overview]
Message-ID: <ab4a7e35-0499-86ab-531d-02277f1038d3@loongson.cn> (raw)
In-Reply-To: <87jzm5j5cs.fsf@vuxu.org>


在 2024/3/14 下午9:44, Leah Neukirchen 写道:
> lixing <lixing@loongson.cn> writes:
>
>> we checked the objdump binaries for -Os and -O2, the a_cas_p implement
>> looks ok for both.
>>
>> Also, we cross build the musl and mksh with -Os, the binary hang with
>> qemu user mode emulation , but not hang in the real hardware.
>>
>> so, maybe this is a qemu problem, we will let our qemu guys to check
>> this problem.
> Pretty surely it's a bug in QEMU.  qemu 8.1.5 works with mksh.Os,
> qemu 8.2.1 hangs.  I have bisected the issue down to:
>
> commit c5af6628f4be5d30800233e59ba3842ca19a12e6 (HEAD)
> Author: Jiajie Chen <c@jia.je>
> Date:   Tue Aug 22 09:13:52 2023 +0200
>
>      target/loongarch: Extract make_address_i() helper
>
> Reverting this hunk fixes it:
>
> diff --git a/target/loongarch/insn_trans/trans_atomic.c.inc b/target/loongarch/insn_trans/trans_atomic.c.inc
> index fbc081448d..bff3e7a74c 100644
> --- a/target/loongarch/insn_trans/trans_atomic.c.inc
> +++ b/target/loongarch/insn_trans/trans_atomic.c.inc
> @@ -7,8 +7,9 @@ static bool gen_ll(DisasContext *ctx, arg_rr_i *a, MemOp mop)
>   {
>       TCGv dest = gpr_dst(ctx, a->rd, EXT_NONE);
>       TCGv src1 = gpr_src(ctx, a->rj, EXT_NONE);
> -    TCGv t0 = make_address_i(ctx, src1, a->imm);
> +    TCGv t0 = tcg_temp_new();
>   
> +    tcg_gen_addi_tl(t0, src1, a->imm);
>       tcg_gen_qemu_ld_i64(dest, t0, ctx->mem_idx, mop);
>       tcg_gen_st_tl(t0, cpu_env, offsetof(CPULoongArchState, lladdr));
>       tcg_gen_st_tl(dest, cpu_env, offsetof(CPULoongArchState, llval));
>
> I think the issue is that make_address_i optimizes the addition away
> if a->imm is zero, but that's just from looking at the code for 15min.
>
> hth,


  Our qemu guys debuged the binary find that "ll.d $t0, $t0, 0" make the 
t0 reg turn to 0,that should be the qemu code problem.

thanks.

XingLi


  reply	other threads:[~2024-03-15  0:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12  0:51 Rich Felker
2024-03-12  2:06 ` Hongliang Wang
2024-03-12  8:31   ` lixing
2024-03-12 16:18     ` Waldemar Brodkorb
2024-03-12 16:47       ` Thorsten Glaser
2024-03-12 17:18         ` Waldemar Brodkorb
2024-03-13  1:42           ` lixing
2024-03-13 14:45             ` Waldemar Brodkorb
2024-03-13 14:52               ` Rich Felker
2024-03-14  5:44                 ` Waldemar Brodkorb
2024-03-14  6:45                   ` lixing
2024-03-14 13:44                     ` Leah Neukirchen
2024-03-15  0:58                       ` lixing [this message]
2024-03-12  8:48   ` Jingyun Hua

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab4a7e35-0499-86ab-531d-02277f1038d3@loongson.cn \
    --to=lixing@loongson.cn \
    --cc=leah@vuxu.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).