From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id DFC7D29C10 for ; Thu, 14 Mar 2024 06:44:44 +0100 (CET) Received: (qmail 21834 invoked by uid 550); 14 Mar 2024 05:40:27 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 21796 invoked from network); 14 Mar 2024 05:40:27 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=openadk.org; s=2022; t=1710395071; bh=R7I5muA6ZnEbk0EzqzWRl3r+OHyEFlJKRfrKKftxcMY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=IbgTHtt7vpoB1jhELhOFjb7JdYBQo8qx75Viie/7/4Z6moS2Z81370HQVd1OMq8ka NlQVHfLSflMrjQC7wOxgoQr7InuXELYqxU/F7xVTcXENsvgqH8f7BMNLqpVm1OeFtu eSwQ2pIJ3P+BeneIIwxFzGboZt/hyPq9p6rTHr/glFDu10Gdo5mzwKCc61kHdKQIUC U2fF4lDg3PNYIOKe9yD7HNOHDq1FsZ+jNz76x2VqI0oDjb77xKUFLqaj7jftfkAB9y ABqCJHAv/W7cfYTthlopmSXrK9jT7XvO5FZOZyO9Qh1Bgf09IyUsRPhShn/4vFy2PQ U8ZdcQUFoptFg== Date: Thu, 14 Mar 2024 06:44:31 +0100 From: Waldemar Brodkorb To: musl@lists.openwall.com Cc: Waldemar Brodkorb Message-ID: References: <20240312005150.GB4163@brightrain.aerifal.cx> <4f5abddd-09f9-f05f-6cc6-719fc365b449@loongson.cn> <20240313145215.GF4163@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240313145215.GF4163@brightrain.aerifal.cx> X-Operating-System: Linux 5.10.0-27-amd64 x86_64 Subject: Re: [musl] loongarch64 atomics not working? Hi, Rich Felker wrote, > > Yes I do. I found the reason why my mksh didn't worked. > > I compiled everything with -Os and then I get the deadlock. > > When I compile everything with -O2 musl mksh is working. > > > > So it seems some gcc problem code compiled with -Os. > > Let's look at the generated asm for the function using a_cas_p and see > if this is a gcc bug or if the asm argument constraints as written > allowed a transformation that's not actually valid. Broken mksh with -Os: 000000012003b970 : 12003b970: 02ff8063 addi.d $sp, $sp, -32 12003b974: 29c02077 st.d $s0, $sp, 8 12003b978: 27000078 stptr.d $s1, $sp, 0 12003b97c: 00150097 move $s0, $a0 12003b980: 001500b8 move $s1, $a1 12003b984: 1a000084 pcalau12i $a0, 4 12003b988: 1a000085 pcalau12i $a1, 4 12003b98c: 29c04076 st.d $fp, $sp, 16 12003b990: 29c06061 st.d $ra, $sp, 24 12003b994: 02c08076 addi.d $fp, $sp, 32 12003b998: 02c060a5 addi.d $a1, $a1, 24 12003b99c: 02c0c084 addi.d $a0, $a0, 48 12003b9a0: 54021400 bl 532 # 12003bbb4 <__vdsosym> 12003b9a4: 0015008e move $t2, $a0 12003b9a8: 38720000 dbar 0x0 12003b9ac: 1a00002d pcalau12i $t1, 1 12003b9b0: 1a00032f pcalau12i $t3, 25 12003b9b4: 02e5c1ad addi.d $t1, $t1, -1680 12003b9b8: 02ca21ec addi.d $t0, $t3, 648 12003b9bc: 2200018c ll.d $t0, $t0, 0 12003b9c0: 5c00198d bne $t0, $t1, 24 # 12003b9d8 12003b9c4: 001501cc move $t0, $t2 12003b9c8: 02ca21f0 addi.d $t4, $t3, 648 12003b9cc: 2300020c sc.d $t0, $t4, 0 12003b9d0: 0040818c slli.w $t0, $t0, 0x0 12003b9d4: 43ffe59f beqz $t0, -28 # 12003b9b8 12003b9d8: 38720000 dbar 0x0 12003b9dc: 400025c0 beqz $t2, 36 # 12003ba00 12003b9e0: 28c04076 ld.d $fp, $sp, 16 12003b9e4: 28c06061 ld.d $ra, $sp, 24 12003b9e8: 00150305 move $a1, $s1 12003b9ec: 001502e4 move $a0, $s0 12003b9f0: 26000078 ldptr.d $s1, $sp, 0 12003b9f4: 28c02077 ld.d $s0, $sp, 8 12003b9f8: 02c08063 addi.d $sp, $sp, 32 12003b9fc: 4c0001c0 jr $t2 12003ba00: 28c06061 ld.d $ra, $sp, 24 12003ba04: 28c04076 ld.d $fp, $sp, 16 12003ba08: 28c02077 ld.d $s0, $sp, 8 12003ba0c: 26000078 ldptr.d $s1, $sp, 0 12003ba10: 02bf6804 li.w $a0, -38 12003ba14: 02c08063 addi.d $sp, $sp, 32 12003ba18: 4c000020 ret Working mksh with -O2: 0000000120045f50 : 120045f50: 02ff8063 addi.d $sp, $sp, -32 120045f54: 29c02077 st.d $s0, $sp, 8 120045f58: 27000078 stptr.d $s1, $sp, 0 120045f5c: 00150097 move $s0, $a0 120045f60: 001500b8 move $s1, $a1 120045f64: 1a000084 pcalau12i $a0, 4 120045f68: 1a000085 pcalau12i $a1, 4 120045f6c: 29c04076 st.d $fp, $sp, 16 120045f70: 29c06061 st.d $ra, $sp, 24 120045f74: 02c08076 addi.d $fp, $sp, 32 120045f78: 02dbc0a5 addi.d $a1, $a1, 1776 120045f7c: 02dc2084 addi.d $a0, $a0, 1800 120045f80: 54024c00 bl 588 # 1200461cc <__vdsosym> 120045f84: 0015008f move $t3, $a0 120045f88: 38720000 dbar 0x0 120045f8c: 1a000030 pcalau12i $t4, 1 120045f90: 1a00036d pcalau12i $t1, 27 120045f94: 02fd4210 addi.d $t4, $t4, -176 120045f98: 50001400 b 20 # 120045fac 120045f9c: 02ca21ae addi.d $t2, $t1, 648 120045fa0: 230001cc sc.d $t0, $t2, 0 120045fa4: 0040818c slli.w $t0, $t0, 0x0 120045fa8: 44001580 bnez $t0, 20 # 120045fbc 120045fac: 02ca21ac addi.d $t0, $t1, 648 120045fb0: 2200018e ll.d $t2, $t0, 0 120045fb4: 001501ec move $t0, $t3 120045fb8: 5bffe60e beq $t4, $t2, -28 # 120045f9c 120045fbc: 38720000 dbar 0x0 120045fc0: 400025e0 beqz $t3, 36 # 120045fe4 120045fc4: 28c04076 ld.d $fp, $sp, 16 120045fc8: 28c06061 ld.d $ra, $sp, 24 120045fcc: 00150305 move $a1, $s1 120045fd0: 001502e4 move $a0, $s0 120045fd4: 26000078 ldptr.d $s1, $sp, 0 120045fd8: 28c02077 ld.d $s0, $sp, 8 120045fdc: 02c08063 addi.d $sp, $sp, 32 120045fe0: 4c0001e0 jr $t3 120045fe4: 28c06061 ld.d $ra, $sp, 24 120045fe8: 28c04076 ld.d $fp, $sp, 16 120045fec: 28c02077 ld.d $s0, $sp, 8 120045ff0: 26000078 ldptr.d $s1, $sp, 0 120045ff4: 02bf6804 li.w $a0, -38 120045ff8: 02c08063 addi.d $sp, $sp, 32 120045ffc: 4c000020 ret Does that help? Both binaries can be found on https://debug.openadk.org. best regards Waldemar