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=-0.6 required=5.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SORTED_RECIPS autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28308 invoked from network); 19 May 2021 10:59:26 -0000 Received: from mother.openwall.net (195.42.179.200) by inbox.vuxu.org with ESMTPUTF8; 19 May 2021 10:59:26 -0000 Received: (qmail 9644 invoked by uid 550); 19 May 2021 10:59:23 -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 9601 invoked from network); 19 May 2021 10:59:23 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=qSDquWF5C/3kPSaisv5VvJ1hs65zlvqZ/KYndLXZBHA=; b=UTkT1J4sM7q+60Slm44Nc34SGgZppdCky+kG+U0w6IHxdZqOozXUhBnDf634kQsZE9 stagF2SzjdN6bP1a0sdhTYCyvFmhZrzLDUdTBz6Ddm+lpmnVBanrYxO/3KZwENLBPCc1 yO0Ys0hlwSwIMmwDKupVUe87eTPQe1IF+BPKUZJtKIHJpb2jOWtZCIUSV1ayH6RU5AZI B/+OTymu/jC771VJ7deDGbNi77c3hegXjZU1FXeAX4OtGBfRjrkYTY2GuHXyXi+E2K3i +uuYCpchPxOn+EaiU6hyDpwdgBymfQopity5cUs4T3KiB8J5sFPP5jKiqgtOh1JZLgtX g1lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=qSDquWF5C/3kPSaisv5VvJ1hs65zlvqZ/KYndLXZBHA=; b=H3wCaEXpYuydekfoPK98vnnvSKJTFcj3nBz+xURiAHA+nFJ8WMouc7AHDG81QnGGjC ND+Suej4XWVSr/Ylmwex5WBZe94AtuJnYMCxoVp6V24f2Yed6m5N31ooXKxk0RIXPNmP ui0gVB6b9HenM5Q6/ABYavGsjQZyTT6hM6dDZCMS+z4+ChxMr7yoTeQlNiHIA8gfj6B+ B2EMJAlz/0PNL00uXvPOdsgymDzFEIIArZQuIC0lPeS/UZH52ntEOTyv0kaqR/dpwIjI RtR/oLIEe6Un8zLXOx2Is9suem3br28IUqsl0E+10VYWnijcPyk6jAGJXRZmqa1jqXm4 RWvg== X-Gm-Message-State: AOAM533ezY5l6nvUzyLGLgo46dWTcfe30qoyA2K0LCCr+w7VqP/GD6uO HmljfKTlyAC4Uvb+PPcJvRk= X-Google-Smtp-Source: ABdhPJzasKvvWtp1iiKJ1oNvcHYkSjfgkycSA7T5giWeXtEipqymW1BGFzU8Y2yuUSLENyMzmOaqLg== X-Received: by 2002:aa7:8a56:0:b029:27d:957f:5993 with SMTP id n22-20020aa78a560000b029027d957f5993mr9862449pfa.27.1621421950920; Wed, 19 May 2021 03:59:10 -0700 (PDT) Date: Wed, 19 May 2021 20:59:05 +1000 From: Nicholas Piggin To: "Dmitry V. Levin" Cc: libc-alpha@sourceware.org, libc-dev@lists.llvm.org, linux-api@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, Michael Ellerman , Matheus Castanho , musl@lists.openwall.com References: <20200611081203.995112-1-npiggin@gmail.com> <20210518231331.GA8464@altlinux.org> <1621385544.nttlk5qugb.astroid@bobo.none> <20210519102403.GA15207@altlinux.org> In-Reply-To: <20210519102403.GA15207@altlinux.org> MIME-Version: 1.0 Message-Id: <1621421721.r9fefebis8.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [musl] Re: Linux powerpc new system call instruction and ABI Excerpts from Dmitry V. Levin's message of May 19, 2021 8:24 pm: > On Wed, May 19, 2021 at 12:50:24PM +1000, Nicholas Piggin wrote: > [...] >> With this patch, I think the ptrace ABI should mostly be fixed. I think=20 >> a problem remains with applications that look at system call return=20 >> registers directly and have powerpc specific error cases. Those probably >> will just need to be updated unfortunately. Michael thought it might be >> possible to return an indication via ptrace somehow that the syscall is >> using a new ABI, so such apps can be updated to test for it. I don't=20 >> know how that would be done. >=20 > Is there any sane way for these applications to handle the scv case? > How can they tell that the scv semantics is being used for the given > syscall invocation? Can this information be obtained e.g. from struct > pt_regs? Not that I know of. Michael suggested there might be a way to add=20 something. ptrace_syscall_info has some pad bytes, could we use one for flags bits and set a bit for "new system call ABI"? As a more hacky thing you could make a syscall with -1 and see how the error looks, and then assume all syscalls will be the same. Thanks, Nick >=20 > For example, in strace we have the following powerpc-specific code used > for syscall tampering: >=20 > $ cat src/linux/powerpc/set_error.c > /* > * Copyright (c) 2016-2021 The strace developers. > * All rights reserved. > * > * SPDX-License-Identifier: LGPL-2.1-or-later > */ >=20 > static int > arch_set_r3_ccr(struct tcb *tcp, const unsigned long r3, > const unsigned long ccr_set, const unsigned long ccr_clear) > { > if (ptrace_syscall_info_is_valid() && > upeek(tcp, sizeof(long) * PT_CCR, &ppc_regs.ccr)) > return -1; > const unsigned long old_ccr =3D ppc_regs.ccr; > ppc_regs.gpr[3] =3D r3; > ppc_regs.ccr |=3D ccr_set; > ppc_regs.ccr &=3D ~ccr_clear; > if (ppc_regs.ccr !=3D old_ccr && > upoke(tcp, sizeof(long) * PT_CCR, ppc_regs.ccr)) > return -1; > return upoke(tcp, sizeof(long) * (PT_R0 + 3), ppc_regs.gpr[3]); > } >=20 > static int > arch_set_error(struct tcb *tcp) > { > return arch_set_r3_ccr(tcp, tcp->u_error, 0x10000000, 0); > } >=20 > static int > arch_set_success(struct tcb *tcp) > { > return arch_set_r3_ccr(tcp, tcp->u_rval, 0, 0x10000000); > } >=20 >=20 > --=20 > ldv >=20