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=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 21958 invoked from network); 22 May 2021 10:48:30 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 22 May 2021 10:48:30 -0000 Received: (qmail 22492 invoked by uid 550); 22 May 2021 10:48:25 -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 5577 invoked from network); 21 May 2021 19:40:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=references : from : to : cc : subject : message-id : in-reply-to : date : content-type : mime-version; s=pp1; bh=qMykcIuYawdYRjvJyzIEJbpxErll2khR6P6J5+MZgDs=; b=EgOMDthDfsGaA+r3W+BTBQM2c9nsku0Y3ngQhWJCVvdAN7bm2EKJNTlxEGtbXUOp2TWc Xsj5wn1O9TaCh3UKRPZHqfUN2DI5wEAMx5G0etp2YxUxH/9oSaOkXojv7+3NzDwYr6sF Vy5HuZlAroBaReS6njXVaSghqfP77QZbqRhjhwJyKauW5JlKJdLo/s355TwqK+Rowq34 /SX7YKoLKdwJvi5ERsmpqq4Wr4sOKjGKPODbQD6XrVmX+9xW4Sp0q+gL/dunoEz5MosJ hyujCgmQKr1u1xo/rwEZJYVrSCaP3ibpGWG2U6+QsOlOQpZd8BgNTTDWBxEc0xf6/68O pQ== References: <20200611081203.995112-1-npiggin@gmail.com> <20210518231331.GA8464@altlinux.org> <1621385544.nttlk5qugb.astroid@bobo.none> <1621400263.gf0mbqhkrf.astroid@bobo.none> User-agent: mu4e 1.4.10; emacs 27.2 From: Matheus Castanho To: Nicholas Piggin Cc: "Dmitry V. Levin" , Michael Ellerman , libc-alpha@sourceware.org, libc-dev@lists.llvm.org, linux-api@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, musl@lists.openwall.com Message-ID: <87a6oo4312.fsf@linux.ibm.com> In-reply-to: <1621400263.gf0mbqhkrf.astroid@bobo.none> Date: Fri, 21 May 2021 16:40:30 -0300 Content-Type: text/plain X-TM-AS-GCONF: 00 X-Proofpoint-GUID: FmX8gShoI7DNy5B3IP4XWytJ3AtWUCi7 X-Proofpoint-ORIG-GUID: HyvNHvMilIbfmniBGeykewaTqxRx90wx X-Proofpoint-UnRewURL: 0 URL was un-rewritten MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.391,18.0.761 definitions=2021-05-21_08:2021-05-20,2021-05-21 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 adultscore=0 mlxlogscore=999 bulkscore=0 priorityscore=1501 phishscore=0 impostorscore=0 malwarescore=0 mlxscore=0 suspectscore=0 lowpriorityscore=0 clxscore=1011 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2104190000 definitions=main-2105210103 Subject: [musl] Re: Linux powerpc new system call instruction and ABI Nicholas Piggin writes: > Excerpts from Nicholas Piggin's message of May 19, 2021 12:50 pm: >> Excerpts from Dmitry V. Levin's message of May 19, 2021 9:13 am: >>> Hi, >>> >>> On Thu, Jun 11, 2020 at 06:12:01PM +1000, Nicholas Piggin wrote: >>> [...] >>>> - Error handling: The consensus among kernel, glibc, and musl is to move to >>>> using negative return values in r3 rather than CR0[SO]=1 to indicate error, >>>> which matches most other architectures, and is closer to a function call. >>> >>> Apparently, the patchset merged by commit v5.9-rc1~100^2~164 was >>> incomplete: all functions defined in arch/powerpc/include/asm/ptrace.h and >>> arch/powerpc/include/asm/syscall.h that use ccr are broken when scv is used. >>> This includes syscall_get_error() and all its users including >>> PTRACE_GET_SYSCALL_INFO API, which in turn makes strace unusable >>> when scv is used. >>> >>> See also https://bugzilla.redhat.com/1929836 >> >> I see, thanks. Using latest strace from github.com, the attached kernel >> patch makes strace -k check results a lot greener. >> >> Some of the remaining failing tests look like this (I didn't look at all >> of them yet): >> >> signal(SIGUSR1, 0xfacefeeddeadbeef) = 0 (SIG_DFL) >> write(1, "signal(SIGUSR1, 0xfacefeeddeadbe"..., 50signal(SIGUSR1, 0xfacefeeddeadbeef) = 0 (SIG_DFL) >> ) = 50 >> signal(SIGUSR1, SIG_IGN) = 0xfacefeeddeadbeef >> write(2, "errno2name.c:461: unknown errno "..., 41errno2name.c:461: unknown errno 559038737) = 41 >> write(2, ": Unknown error 559038737\n", 26: Unknown error 559038737 >> ) = 26 >> exit_group(1) = ? >> >> I think the problem is glibc testing for -ve, but it should be comparing >> against -4095 (+cc Matheus) >> >> #define RET_SCV \ >> cmpdi r3,0; \ >> bgelr+; \ >> neg r3,r3; > > This glibc patch at least gets that signal test working. Haven't run the > full suite yet because of trouble making it work with a local glibc > install... > > Thanks, > Nick > > --- > > diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h > index c57bb1c05d..1ea4c3b917 100644 > --- a/sysdeps/powerpc/powerpc64/sysdep.h > +++ b/sysdeps/powerpc/powerpc64/sysdep.h > @@ -398,8 +398,9 @@ LT_LABELSUFFIX(name,_name_end): ; \ > #endif > > #define RET_SCV \ > - cmpdi r3,0; \ > - bgelr+; \ > + li r9,-4095; \ > + cmpld r3,r9; \ > + bltlr+; \ > neg r3,r3; > > #define RET_SC \ Hi Nick, I agree the current code is accepting more values as errors than it should. This change looks good to me. All glibc tests are passing with it. I also built strace and checked one of the failing tests against a glibc with your patch: ~/src/strace/tests$ uname -r 5.10.16-1-default ~/src/strace/tests$ /lib64/libc.so.6 GNU C Library (GNU libc) release release version 2.33 (git 9826b03b74). [...] ~/src/strace/tests$ ./signal.gen.test errno2name.c:461: unknown errno 559038737: Unknown error 559038737 signal.gen.test: failed test: ../signal failed with code 1 ~/src/strace/tests$ ./signal signal(SIGUSR1, SIG_IGN) = 0 (SIG_DFL) signal(SIGUSR1, SIG_DFL) = 0x1 (SIG_IGN) signal(SIGUSR1, 0xfacefeeddeadbeef) = 0 (SIG_DFL) errno2name.c:461: unknown errno 559038737: Unknown error 559038737 Running with glibc containing the patch: ~/src/strace/tests$ ~/build/glibc/testrun.sh ./signal signal(SIGUSR1, SIG_IGN) = 0 (SIG_DFL) signal(SIGUSR1, SIG_DFL) = 0x1 (SIG_IGN) signal(SIGUSR1, 0xfacefeeddeadbeef) = 0 (SIG_DFL) signal(SIGUSR1, SIG_IGN) = 0xfacefeeddeadbeef signal(-559038737, SIG_IGN) = -1 EINVAL (Invalid argument) +++ exited with 0 +++ If the patch below looks OK to you and no one objects, I'll commit it to glibc on Monday. Thanks, Matheus Castanho --- From: Nicholas Piggin Subject: [PATCH 1/1] powerpc: Fix handling of scv return error codes When using scv on templated ASM syscalls, current code interprets any negative return value as error, but the only valid error codes are in the range -4095..-1 according to the ABI. Reviewed-by: Matheus Castanho --- sysdeps/powerpc/powerpc64/sysdep.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sysdeps/powerpc/powerpc64/sysdep.h b/sysdeps/powerpc/powerpc64/sysdep.h index c57bb1c05d..1ea4c3b917 100644 --- a/sysdeps/powerpc/powerpc64/sysdep.h +++ b/sysdeps/powerpc/powerpc64/sysdep.h @@ -398,8 +398,9 @@ LT_LABELSUFFIX(name,_name_end): ; \ #endif #define RET_SCV \ - cmpdi r3,0; \ - bgelr+; \ + li r9,-4095; \ + cmpld r3,r9; \ + bltlr+; \ neg r3,r3; #define RET_SC \ -- 2.31.1