From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 5438 invoked from network); 11 Feb 2023 14:01:19 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 11 Feb 2023 14:01:19 -0000 Received: (qmail 19824 invoked by uid 550); 11 Feb 2023 14:01:16 -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 19792 invoked from network); 11 Feb 2023 14:01:15 -0000 Date: Sat, 11 Feb 2023 09:01:03 -0500 From: Rich Felker To: Bastian Bittorf Cc: musl@lists.openwall.com, mailinglist Message-ID: <20230211140103.GE4163@brightrain.aerifal.cx> References: <20230211125147.7ud3rx2ozflm7zsb@email> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="V88s5gaDVPzZ0KCq" Content-Disposition: inline In-Reply-To: <20230211125147.7ud3rx2ozflm7zsb@email> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] busybox problem on powerpc PPC/32bit (hardware TP-Link-WDR-4900-v1) --V88s5gaDVPzZ0KCq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Feb 11, 2023 at 12:51:47PM +0000, Bastian Bittorf wrote: > With OpenWRT i recognized a strange behavior of ash-shell scripts. > It happens only on target PowerPC, e.g. m68k, arm, mips, x86 are > unaffected. > > The visible strange behavior in 'ash' is: > > $ test A -gt 5 && echo OK > ash: A: out of range > OK > > Ofcourse this wrong returncode leads to all sorts of things... > > I tested several busybox releases (1.33.2, 1.35.0, 1.36.0) and > crosscompiled with musl-git-b76f37f (from musl.cc) and > crosscompiled with glibc: powerpc-linux-gnu-gcc (Debian-12.2.0) > (it's the same for all versions) > > The resulting linux + busybox images ready for QEMU are here: > http://intercity-vpn.de/mpc85xx/ > > If needed i can provide build instructions. > Maybe somebody with more powerpc assembly knowledge can help here. > > The underlying code is here: > https://git.busybox.net/busybox/tree/coreutils/test.c#n488 > But i can not spot the error: > > static number_t getn(const char *s) > { > char *p; > errno = 0; > r = strtol(s, &p, 10); > if (errno != 0) > syntax(s, "out of range"); > return r; > } > > Best Greetings, > Bastian Bittorf It looks like the powerpc spe longjmp code is clobbering the value argument. Try the attached patch. --V88s5gaDVPzZ0KCq Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="ppc-spe-longjmp-fix.diff" diff --git a/src/setjmp/powerpc/longjmp.S b/src/setjmp/powerpc/longjmp.S index 611389fe..465e4cd7 100644 --- a/src/setjmp/powerpc/longjmp.S +++ b/src/setjmp/powerpc/longjmp.S @@ -42,10 +42,10 @@ longjmp: bl 1f .hidden __hwcap .long __hwcap-. -1: mflr 4 - lwz 5, 0(4) - lwzx 4, 4, 5 - andis. 4, 4, 0x80 +1: mflr 6 + lwz 5, 0(6) + lwzx 6, 6, 5 + andis. 6, 6, 0x80 beq 1f .long 0x11c35b01 /* evldd 14,88(3) */ .long 0x11e36301 /* ... */ --V88s5gaDVPzZ0KCq--